diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2023-11-20 20:53:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-20 20:53:24 +0000 |
commit | f42482def236999b0f7896c09cd714b708861c8b (patch) | |
tree | 5af8ca0c198f5fd71b50511d61cbd9ea558834d5 /llvm/lib/Transforms/Utils/Local.cpp | |
parent | 6352a07ba65301b60ace8e5e67e54f4967e375ae (diff) | |
download | llvm-f42482def236999b0f7896c09cd714b708861c8b.zip llvm-f42482def236999b0f7896c09cd714b708861c8b.tar.gz llvm-f42482def236999b0f7896c09cd714b708861c8b.tar.bz2 |
[DebugInfo][RemoveDIs] Don't convert debug-intrinsics to Unreachable (#72380)
It might seem obvious, but it's not a good idea to convert a
debug-intrinsic instruction into an UnreachableInst, as this means
things operate differently with and without the -g option. However this
can happen due to the "mutate the next instruction" API calls we make.
With RemoveDIs eliminating debug intrinsics, this behaviour is at risk
of changing, hence this patch ensures we only ever mutate the next _non_
debuginfo instruction into an Unreachable.
The tests instrumented with the --try... flag all exercise this, I've
added some metadata to a SCCP test to ensure it's exercised.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 0be782f..0b392e7 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -2750,6 +2750,7 @@ unsigned llvm::changeToUnreachable(Instruction *I, bool PreserveLCSSA, Updates.push_back({DominatorTree::Delete, BB, UniqueSuccessor}); DTU->applyUpdates(Updates); } + BB->flushTerminatorDbgValues(); return NumInstrsRemoved; } @@ -2903,9 +2904,9 @@ static bool markAliveBlocks(Function &F, // If we found a call to a no-return function, insert an unreachable // instruction after it. Make sure there isn't *already* one there // though. - if (!isa<UnreachableInst>(CI->getNextNode())) { + if (!isa<UnreachableInst>(CI->getNextNonDebugInstruction())) { // Don't insert a call to llvm.trap right before the unreachable. - changeToUnreachable(CI->getNextNode(), false, DTU); + changeToUnreachable(CI->getNextNonDebugInstruction(), false, DTU); Changed = true; } break; |