diff options
author | OCHyams <orlando.hyams@sony.com> | 2019-11-25 09:02:05 +0000 |
---|---|---|
committer | OCHyams <orlando.hyams@sony.com> | 2019-11-25 10:55:14 +0000 |
commit | 2de23c8364babb49fe39d81048cd304a5ac2934e (patch) | |
tree | df5640e86e23a095372c95f72480b92b7dfb6327 /llvm/lib/Transforms/Utils/Local.cpp | |
parent | 29b4d8f19e30910c099c5453da258843d6b7869a (diff) | |
download | llvm-2de23c8364babb49fe39d81048cd304a5ac2934e.zip llvm-2de23c8364babb49fe39d81048cd304a5ac2934e.tar.gz llvm-2de23c8364babb49fe39d81048cd304a5ac2934e.tar.bz2 |
[DebugInfo@O2][Utils] Undef instead of delete dbg.values in helper func
Summary:
Related bug: https://bugs.llvm.org/show_bug.cgi?id=40648
Static helper function rewriteDebugUsers in Local.cpp deletes dbg.value
intrinsics when it cannot move or rewrite them, or salvage the deleted
instruction's value. It should instead undef them in this case.
This patch fixes that and I've added a test which covers the failing test
case in bz40648. I've updated the unit test Local.ReplaceAllDbgUsesWith
to check for this behaviour (and fixed a typo in the test which would
cause the old test to always pass).
Reviewers: aprantl, vsk, djtodoro, probinson
Reviewed By: vsk
Subscribers: hiraditya, llvm-commits
Tags: #debug-info, #llvm
Differential Revision: https://reviews.llvm.org/D70604
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index aa1341e..eaccaa1 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1732,7 +1732,7 @@ DIExpression *llvm::salvageDebugInfoImpl(Instruction &I, using DbgValReplacement = Optional<DIExpression *>; /// Point debug users of \p From to \p To using exprs given by \p RewriteExpr, -/// possibly moving/deleting users to prevent use-before-def. Returns true if +/// possibly moving/undefing users to prevent use-before-def. Returns true if /// changes are made. static bool rewriteDebugUsers( Instruction &From, Value &To, Instruction &DomPoint, DominatorTree &DT, @@ -1745,7 +1745,7 @@ static bool rewriteDebugUsers( // Prevent use-before-def of To. bool Changed = false; - SmallPtrSet<DbgVariableIntrinsic *, 1> DeleteOrSalvage; + SmallPtrSet<DbgVariableIntrinsic *, 1> UndefOrSalvage; if (isa<Instruction>(&To)) { bool DomPointAfterFrom = From.getNextNonDebugInstruction() == &DomPoint; @@ -1760,14 +1760,14 @@ static bool rewriteDebugUsers( // Users which otherwise aren't dominated by the replacement value must // be salvaged or deleted. } else if (!DT.dominates(&DomPoint, DII)) { - DeleteOrSalvage.insert(DII); + UndefOrSalvage.insert(DII); } } } // Update debug users without use-before-def risk. for (auto *DII : Users) { - if (DeleteOrSalvage.count(DII)) + if (UndefOrSalvage.count(DII)) continue; LLVMContext &Ctx = DII->getContext(); @@ -1781,18 +1781,10 @@ static bool rewriteDebugUsers( Changed = true; } - if (!DeleteOrSalvage.empty()) { + if (!UndefOrSalvage.empty()) { // Try to salvage the remaining debug users. - Changed |= salvageDebugInfo(From); - - // Delete the debug users which weren't salvaged. - for (auto *DII : DeleteOrSalvage) { - if (DII->getVariableLocation() == &From) { - LLVM_DEBUG(dbgs() << "Erased UseBeforeDef: " << *DII << '\n'); - DII->eraseFromParent(); - Changed = true; - } - } + salvageDebugInfoOrMarkUndef(From); + Changed = true; } return Changed; |