aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2025-04-24 19:59:29 +0200
committerGitHub <noreply@github.com>2025-04-24 18:59:29 +0100
commitd6bb786705d0fe76d62010457eac0f8f05af7009 (patch)
tree235f6ed93c0440a39c4343f6e513d337242df47f /llvm/lib/Transforms/Utils/Local.cpp
parent2bc6f9d4b6ff1d838f1c2d50cacbab6ba2f20bc9 (diff)
downloadllvm-d6bb786705d0fe76d62010457eac0f8f05af7009.zip
llvm-d6bb786705d0fe76d62010457eac0f8f05af7009.tar.gz
llvm-d6bb786705d0fe76d62010457eac0f8f05af7009.tar.bz2
[DebugInfo] Propagate source loc from invoke to replacement branch (#137206)
An existing transformation replaces invoke instructions with a call to the invoked function and a branch to the destination; when this happens, we propagate the invoke's source location to the call but not to the branch. This patch updates this behaviour to propagate to the branch as well. Found using https://github.com/llvm/llvm-project/pull/107279.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index b3204da..f914d596 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2964,7 +2964,11 @@ CallInst *llvm::changeToCall(InvokeInst *II, DomTreeUpdater *DTU) {
// Follow the call by a branch to the normal destination.
BasicBlock *NormalDestBB = II->getNormalDest();
- BranchInst::Create(NormalDestBB, II->getIterator());
+ auto *BI = BranchInst::Create(NormalDestBB, II->getIterator());
+ // Although it takes place after the call itself, the new branch is still
+ // performing part of the control-flow functionality of the invoke, so we use
+ // II's DebugLoc.
+ BI->setDebugLoc(II->getDebugLoc());
// Update PHI nodes in the unwind destination
BasicBlock *BB = II->getParent();