diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2023-12-06 17:25:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-06 17:25:33 +0000 |
commit | d0858bffa11e418c257b2573acbf4a3901d5dcb1 (patch) | |
tree | 96131119ea3c0d762f00ee728ad1d76167117f22 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 7b83f69db4a57c63c230d45ca2dc52b024612c17 (diff) | |
download | llvm-d0858bffa11e418c257b2573acbf4a3901d5dcb1.zip llvm-d0858bffa11e418c257b2573acbf4a3901d5dcb1.tar.gz llvm-d0858bffa11e418c257b2573acbf4a3901d5dcb1.tar.bz2 |
[DebugInfo][RemoveDIs] Maintain DPValues on skipped instrs in CGP (#74602)
It turns out that CodeGenPrepare will skip over consecutive select
instructions as it knows it can optimise them all at the same time. This
is unfortunate for the RemoveDIs project to remove intrinsic-based
debug-info, because that means debug-info attached to those skipped
instructions doesn't get seen by optimizeInst and so updated. Add code
to handle debug-info on those skipped instructions manually.
This code will also have been slower when it had dbg.values stuffed in
between instructions, but with RemoveDIs it'll go faster because the
dbg.values won't break up the select sequence.
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 824371c..aa5cdd2 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -460,6 +460,7 @@ private: bool dupRetToEnableTailCallOpts(BasicBlock *BB, ModifyDT &ModifiedDT); bool fixupDbgValue(Instruction *I); bool fixupDPValue(DPValue &I); + bool fixupDPValuesOnInst(Instruction &I); bool placeDbgValues(Function &F); bool placePseudoProbes(Function &F); bool canFormExtLd(const SmallVectorImpl<Instruction *> &MovedExts, @@ -6986,6 +6987,11 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) { // Increment the current iterator to skip all the rest of select instructions // because they will be either "not lowered" or "all lowered" to branch. CurInstIterator = std::next(LastSI->getIterator()); + // Examine debug-info attached to the consecutive select instructions. They + // won't be individually optimised by optimizeInst, so we need to perform + // DPValue maintenence here instead. + for (SelectInst *SI : ArrayRef(ASI).drop_front()) + fixupDPValuesOnInst(*SI); bool VectorCond = !SI->getCondition()->getType()->isIntegerTy(1); @@ -8141,8 +8147,7 @@ static bool optimizeBranch(BranchInst *Branch, const TargetLowering &TLI, bool CodeGenPrepare::optimizeInst(Instruction *I, ModifyDT &ModifiedDT) { bool AnyChange = false; - for (DPValue &DPV : I->getDbgValueRange()) - AnyChange |= fixupDPValue(DPV); + AnyChange = fixupDPValuesOnInst(*I); // Bail out if we inserted the instruction to prevent optimizations from // stepping on each other's toes. @@ -8408,6 +8413,13 @@ bool CodeGenPrepare::fixupDbgValue(Instruction *I) { return AnyChange; } +bool CodeGenPrepare::fixupDPValuesOnInst(Instruction &I) { + bool AnyChange = false; + for (DPValue &DPV : I.getDbgValueRange()) + AnyChange |= fixupDPValue(DPV); + return AnyChange; +} + // FIXME: should updating debug-info really cause the "changed" flag to fire, // which can cause a function to be reprocessed? bool CodeGenPrepare::fixupDPValue(DPValue &DPV) { |