diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2021-08-25 14:56:05 +0100 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2021-08-25 15:10:36 +0100 |
commit | 0116ed006929224a934d99bd3705812485969221 (patch) | |
tree | abb8beacf27ba95e592d6761b618ebca51595790 /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | 9b2c6c07b54ac627403d679b8de8f87e90715913 (diff) | |
download | llvm-0116ed006929224a934d99bd3705812485969221.zip llvm-0116ed006929224a934d99bd3705812485969221.tar.gz llvm-0116ed006929224a934d99bd3705812485969221.tar.bz2 |
[DebugInfo][InstrRef] Don't use instr-ref for unoptimised functions
InstrRefBasedLDV is marginally slower than VarlocBasedLDV when analysing
optimised code -- however, it's much slower when analysing code compiled
-O0.
To avoid this: don't use instruction referencing for -O0 functions. In the
"pure" case of unoptimised code, this won't really harm the debugging
experience because most variables won't have been promoted off the stack,
so can't go missing. It becomes more complicated when optimised code is
inlined into functions marked optnone; however these are rare, and as -O0
doesn't run many optimisations there should be little damage to the debug
experience as a result.
I've taken the opportunity to refactor testing for instruction-referencing
into a MachineFunction method, which seems the most appropriate place to
put it.
Differential Revision: https://reviews.llvm.org/D108585
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 88dc5a6..7da58fd 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -1174,7 +1174,7 @@ void MachineFunction::finalizeDebugInstrRefs() { MI.getOperand(0).setIsDebug(); }; - if (!getTarget().Options.ValueTrackingVariableLocations) + if (!useDebugInstrRef()) return; for (auto &MBB : *this) { @@ -1221,6 +1221,24 @@ void MachineFunction::finalizeDebugInstrRefs() { } } +bool MachineFunction::useDebugInstrRef() const { + // Disable instr-ref at -O0: it's very slow (in compile time). We can still + // have optimized code inlined into this unoptimized code, however with + // fewer and less aggressive optimizations happening, coverage and accuracy + // should not suffer. + if (getTarget().getOptLevel() == CodeGenOpt::None) + return false; + + // Don't use instr-ref if this function is marked optnone. + if (F.hasFnAttribute(Attribute::OptimizeNone)) + return false; + + if (getTarget().Options.ValueTrackingVariableLocations) + return true; + + return false; +} + /// \} //===----------------------------------------------------------------------===// |