diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Utils/LCSSA.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Transforms/Utils/LCSSA.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Utils/LCSSA.cpp b/contrib/llvm-project/llvm/lib/Transforms/Utils/LCSSA.cpp index c36b0533580b..5e0c312fe149 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Utils/LCSSA.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Utils/LCSSA.cpp @@ -160,7 +160,8 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist, if (SSAUpdate.HasValueForBlock(ExitBB)) continue; PHINode *PN = PHINode::Create(I->getType(), PredCache.size(ExitBB), - I->getName() + ".lcssa", &ExitBB->front()); + I->getName() + ".lcssa"); + PN->insertBefore(ExitBB->begin()); if (InsertedPHIs) InsertedPHIs->push_back(PN); // Get the debug location from the original instruction. @@ -241,7 +242,8 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist, } SmallVector<DbgValueInst *, 4> DbgValues; - llvm::findDbgValues(DbgValues, I); + SmallVector<DPValue *, 4> DPValues; + llvm::findDbgValues(DbgValues, I, &DPValues); // Update pre-existing debug value uses that reside outside the loop. for (auto *DVI : DbgValues) { @@ -257,6 +259,21 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist, DVI->replaceVariableLocationOp(I, V); } + // RemoveDIs: copy-paste of block above, using non-instruction debug-info + // records. + for (DPValue *DPV : DPValues) { + BasicBlock *UserBB = DPV->getMarker()->getParent(); + if (InstBB == UserBB || L->contains(UserBB)) + continue; + // We currently only handle debug values residing in blocks that were + // traversed while rewriting the uses. If we inserted just a single PHI, + // we will handle all relevant debug values. + Value *V = AddedPHIs.size() == 1 ? AddedPHIs[0] + : SSAUpdate.FindValueForBlock(UserBB); + if (V) + DPV->replaceVariableLocationOp(I, V); + } + // SSAUpdater might have inserted phi-nodes inside other loops. We'll need // to post-process them to keep LCSSA form. for (PHINode *InsertedPN : LocalInsertedPHIs) { |
