diff options
| author | Jeremy Morse <jeremy.morse@sony.com> | 2024-01-26 09:53:05 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-26 09:53:05 +0000 |
| commit | c23608b8d58bdeb0134d99168e6d0335da2c8366 (patch) | |
| tree | c8f09aabe9dcc7340d683969f22ea3e93bec8f9b /llvm/lib/IR/BasicBlock.cpp | |
| parent | 3ed98cb3de303c316c943da7d60b48472f7efdec (diff) | |
[DebugInfo][RemoveDIs] Don't pointlessly scan funcs for debug-info (#79327)
The utility functions this patch modifies are part of cleanly
transitioning from a context where we use dbg.value intrinsics to one
where we use DPValue objects to record debug-info, and back again.
However, this is a waste of time in non-debug builds (i.e. no -g on the
command line). We still have to call the function on all blocks though
to set the IsNewDbgInfoFormat flag.
To reduce the overhead of this, test whether there's any debug-info in
the function by checking whether the function has a DISubprogram, and
pass a flag down to the utility functions indicating whether they can
skip the scan.
It feels a bit dumb to me now that we're scanning and setting a flag in
a load of blocks when we don't have to -- however it's been really
valuable during development for working out where spurious dbg.value
intrinsics leak into a RemoveDIs context. Happily we'll be able to just
delete this flag entirely when RemoveDIs lands and sticks, and the
conversion routines will eventually be pushed down into the debug-info
autoupgrade path.
Diffstat (limited to 'llvm/lib/IR/BasicBlock.cpp')
| -rw-r--r-- | llvm/lib/IR/BasicBlock.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp index dca528328384..e9d15989b6e5 100644 --- a/llvm/lib/IR/BasicBlock.cpp +++ b/llvm/lib/IR/BasicBlock.cpp @@ -60,13 +60,17 @@ DPMarker *BasicBlock::createMarker(InstListType::iterator It) { return DPM; } -void BasicBlock::convertToNewDbgValues() { +void BasicBlock::convertToNewDbgValues(bool HasNoDebugInfo) { // Is the command line option set? if (!UseNewDbgInfoFormat) return; IsNewDbgInfoFormat = true; + // If the caller knows there's no debug-info in this function, do nothing. + if (HasNoDebugInfo) + return; + // Iterate over all instructions in the instruction list, collecting dbg.value // instructions and converting them to DPValues. Once we find a "real" // instruction, attach all those DPValues to a DPMarker in that instruction. @@ -93,10 +97,14 @@ void BasicBlock::convertToNewDbgValues() { } } -void BasicBlock::convertFromNewDbgValues() { +void BasicBlock::convertFromNewDbgValues(bool HasNoDebugInfo) { invalidateOrders(); IsNewDbgInfoFormat = false; + // If the caller knows there's no debug-info in this function, do nothing. + if (HasNoDebugInfo) + return; + // Iterate over the block, finding instructions annotated with DPMarkers. // Convert any attached DPValues to dbg.values and insert ahead of the // instruction. |
