forked from OSchip/llvm-project
Follow up to a3936a6c19
, correctly select LiveDebugValues implementation
Some functions get opted out of instruction referencing if they're being compiled with no optimisations, however the LiveDebugValues pass picks one implementation and then sticks with it through the rest of compilation. This leads to a segfault if we encounter a function that doesn't use instr-ref (because it's optnone, for example), but we've already decided to use InstrRefBasedLDV which expects to be passed a DomTree. Solution: keep both implementations around in the pass, and pick whichever one is appropriate to the current function.
This commit is contained in:
parent
05fb26062c
commit
e3e1da20d4
|
@ -60,10 +60,7 @@ public:
|
|||
static char ID;
|
||||
|
||||
LiveDebugValues();
|
||||
~LiveDebugValues() {
|
||||
if (TheImpl)
|
||||
delete TheImpl;
|
||||
}
|
||||
~LiveDebugValues() {}
|
||||
|
||||
/// Calculate the liveness information for the given machine function.
|
||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||
|
@ -79,7 +76,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
LDVImpl *TheImpl;
|
||||
std::unique_ptr<LDVImpl> InstrRefImpl;
|
||||
std::unique_ptr<LDVImpl> VarLocImpl;
|
||||
TargetPassConfig *TPC;
|
||||
MachineDominatorTree MDT;
|
||||
};
|
||||
|
@ -94,7 +92,9 @@ INITIALIZE_PASS(LiveDebugValues, DEBUG_TYPE, "Live DEBUG_VALUE analysis", false,
|
|||
/// Default construct and initialize the pass.
|
||||
LiveDebugValues::LiveDebugValues() : MachineFunctionPass(ID) {
|
||||
initializeLiveDebugValuesPass(*PassRegistry::getPassRegistry());
|
||||
TheImpl = nullptr;
|
||||
InstrRefImpl =
|
||||
std::unique_ptr<LDVImpl>(llvm::makeInstrRefBasedLiveDebugValues());
|
||||
VarLocImpl = std::unique_ptr<LDVImpl>(llvm::makeVarLocBasedLiveDebugValues());
|
||||
}
|
||||
|
||||
bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) {
|
||||
|
@ -102,19 +102,14 @@ bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) {
|
|||
// Allow the user to force selection of InstrRef LDV.
|
||||
InstrRefBased |= ForceInstrRefLDV;
|
||||
|
||||
if (!TheImpl) {
|
||||
TPC = getAnalysisIfAvailable<TargetPassConfig>();
|
||||
|
||||
if (InstrRefBased)
|
||||
TheImpl = llvm::makeInstrRefBasedLiveDebugValues();
|
||||
else
|
||||
TheImpl = llvm::makeVarLocBasedLiveDebugValues();
|
||||
}
|
||||
TPC = getAnalysisIfAvailable<TargetPassConfig>();
|
||||
LDVImpl *TheImpl = &*VarLocImpl;
|
||||
|
||||
MachineDominatorTree *DomTree = nullptr;
|
||||
if (InstrRefBased) {
|
||||
DomTree = &MDT;
|
||||
MDT.calculate(MF);
|
||||
TheImpl = &*InstrRefImpl;
|
||||
}
|
||||
|
||||
return TheImpl->ExtendRanges(MF, DomTree, TPC, InputBBLimit,
|
||||
|
|
Loading…
Reference in New Issue