[llvm] [SimplifyCFG] Refine metadata handling during instruction hoisting (PR #158448)

William Moses via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 14 09:39:22 PDT 2025


================
@@ -3387,11 +3387,14 @@ 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());
----------------
wsmoses wrote:

done

https://github.com/llvm/llvm-project/pull/158448


More information about the llvm-commits mailing list