[llvm] Refine metadata handling during instruction hoisting (PR #158448)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 13 16:13:54 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: William Moses (wsmoses)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/158448.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Utils/SimplifyCFG.cpp (+4-2)
``````````diff
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 5a842f9b49c1b..6d6e32d51b62e 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3387,11 +3387,13 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
// Metadata can be dependent on the condition we are hoisting above.
// Strip all UB-implying metadata on the instruction. Drop the debug loc
// to avoid making it appear as if the condition is a constant, which would
- // be misleading while debugging.
+ // be misleading while debugging. However, make sure to keep debug info
+ // for calls as inlinable function calls in a function with debug info must
+ // have a !dbg location.
// Similarly strip attributes that maybe dependent on condition we are
// hoisting above.
for (auto &I : make_early_inc_range(*ThenBB)) {
- if (!SpeculatedStoreValue || &I != SpeculatedStore) {
+ if (!SpeculatedStoreValue || &I != SpeculatedStore && !isa<CallBase>(&I)) {
I.setDebugLoc(DebugLoc::getDropped());
}
I.dropUBImplyingAttrsAndMetadata();
``````````
</details>
https://github.com/llvm/llvm-project/pull/158448
More information about the llvm-commits
mailing list