summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-09-21 19:52:03 +0000
committerReid Kleckner <rnk@google.com>2017-09-21 19:52:03 +0000
commit0fe506bc5eff0b3b77632ff8db00165ae07830ee (patch)
tree540b10e2fd6b6ca76708216c9cdf21255da665db /llvm/lib/Transforms/InstCombine
parent977996d25b1f7ca0d4f4d2c863537a95287f096e (diff)
downloadbcm5719-llvm-0fe506bc5eff0b3b77632ff8db00165ae07830ee.tar.gz
bcm5719-llvm-0fe506bc5eff0b3b77632ff8db00165ae07830ee.zip
Re-land r313825: "[IR] Add llvm.dbg.addr, a control-dependent version of llvm.dbg.declare"
The fix is to avoid invalidating our insertion point in replaceDbgDeclare: Builder.insertDeclare(NewAddress, DIVar, DIExpr, Loc, InsertBefore); + if (DII == InsertBefore) + InsertBefore = &*std::next(InsertBefore->getIterator()); DII->eraseFromParent(); I had to write a unit tests for this instead of a lit test because the use list order matters in order to trigger the bug. The reduced C test case for this was: void useit(int*); static inline void inlineme() { int x[2]; useit(x); } void f() { inlineme(); inlineme(); } llvm-svn: 313905
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index f51b8381445..60db2ddb63c 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2106,10 +2106,10 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) {
// If we are removing an alloca with a dbg.declare, insert dbg.value calls
// before each store.
- DbgDeclareInst *DDI = nullptr;
+ TinyPtrVector<DbgInfoIntrinsic *> DIIs;
std::unique_ptr<DIBuilder> DIB;
if (isa<AllocaInst>(MI)) {
- DDI = FindAllocaDbgDeclare(&MI);
+ DIIs = FindDbgAddrUses(&MI);
DIB.reset(new DIBuilder(*MI.getModule(), /*AllowUnresolved=*/false));
}
@@ -2145,8 +2145,9 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) {
} else if (isa<BitCastInst>(I) || isa<GetElementPtrInst>(I) ||
isa<AddrSpaceCastInst>(I)) {
replaceInstUsesWith(*I, UndefValue::get(I->getType()));
- } else if (DDI && isa<StoreInst>(I)) {
- ConvertDebugDeclareToDebugValue(DDI, cast<StoreInst>(I), *DIB);
+ } else if (auto *SI = dyn_cast<StoreInst>(I)) {
+ for (auto *DII : DIIs)
+ ConvertDebugDeclareToDebugValue(DII, SI, *DIB);
}
eraseInstFromFunction(*I);
}
@@ -2159,8 +2160,8 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) {
None, "", II->getParent());
}
- if (DDI)
- eraseInstFromFunction(*DDI);
+ for (auto *DII : DIIs)
+ eraseInstFromFunction(*DII);
return eraseInstFromFunction(MI);
}
OpenPOWER on IntegriCloud