From 145a7d6f2fb6b19f13261e75b4da65934c4e0282 Mon Sep 17 00:00:00 2001 From: William Moses Date: Sat, 13 Sep 2025 18:34:43 -0500 Subject: [PATCH 1/3] Backport "Refine metadata handling during instruction hoisting" Backport of https://github.com/llvm/llvm-project/pull/158448 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index f662e126e3784..d82045e52378e 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3031,7 +3031,8 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB, // 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(&I)) { // Don't update the DILocation of dbg.assign intrinsics. if (!isa(&I)) I.setDebugLoc(DebugLoc()); From 4dadcc24082762a97083255465ae14cf056c62b2 Mon Sep 17 00:00:00 2001 From: "William S. Moses" Date: Mon, 15 Sep 2025 09:34:23 -0500 Subject: [PATCH 2/3] fix --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index d82045e52378e..de1ea6d25174d 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3035,7 +3035,7 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB, !isa(&I)) { // Don't update the DILocation of dbg.assign intrinsics. if (!isa(&I)) - I.setDebugLoc(DebugLoc()); + I.dropLocation(); } I.dropUndefImplyingAttrsAndUnknownMetadata(); From 881b1423aaf52d851ea4b38e1531a2b1504f8169 Mon Sep 17 00:00:00 2001 From: "William S. Moses" Date: Mon, 15 Sep 2025 09:36:13 -0500 Subject: [PATCH 3/3] fix --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index de1ea6d25174d..b0af40d2df1a4 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3031,8 +3031,7 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB, // Similarly strip attributes that maybe dependent on condition we are // hoisting above. for (auto &I : make_early_inc_range(*ThenBB)) { - if ((!SpeculatedStoreValue || &I != SpeculatedStore) && - !isa(&I)) { + if (!SpeculatedStoreValue || &I != SpeculatedStore) { // Don't update the DILocation of dbg.assign intrinsics. if (!isa(&I)) I.dropLocation();