aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp20
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;
+}
+
/// \}
//===----------------------------------------------------------------------===//