aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
index b8584e8..770c46e 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
@@ -14,6 +14,7 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
+#include "llvm/Target/TargetMachine.h"
/// \file LiveDebugValues.cpp
///
@@ -40,7 +41,10 @@ public:
static char ID;
LiveDebugValues();
- ~LiveDebugValues() { delete TheImpl; }
+ ~LiveDebugValues() {
+ if (TheImpl)
+ delete TheImpl;
+ }
/// Calculate the liveness information for the given machine function.
bool runOnMachineFunction(MachineFunction &MF) override;
@@ -57,6 +61,7 @@ public:
private:
LDVImpl *TheImpl;
+ TargetPassConfig *TPC;
};
char LiveDebugValues::ID = 0;
@@ -69,10 +74,24 @@ INITIALIZE_PASS(LiveDebugValues, DEBUG_TYPE, "Live DEBUG_VALUE analysis", false,
/// Default construct and initialize the pass.
LiveDebugValues::LiveDebugValues() : MachineFunctionPass(ID) {
initializeLiveDebugValuesPass(*PassRegistry::getPassRegistry());
- TheImpl = llvm::makeVarLocBasedLiveDebugValues();
+ TheImpl = nullptr;
}
bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) {
- auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
+ if (!TheImpl) {
+ TPC = getAnalysisIfAvailable<TargetPassConfig>();
+
+ bool InstrRefBased = false;
+ if (TPC) {
+ auto &TM = TPC->getTM<TargetMachine>();
+ InstrRefBased = TM.Options.ValueTrackingVariableLocations;
+ }
+
+ if (InstrRefBased)
+ TheImpl = llvm::makeInstrRefBasedLiveDebugValues();
+ else
+ TheImpl = llvm::makeVarLocBasedLiveDebugValues();
+ }
+
return TheImpl->ExtendRanges(MF, TPC);
}