From c2457e1fa1360adb372da3e50e695c009385c775 Mon Sep 17 00:00:00 2001 From: William Moses Date: Sat, 13 Sep 2025 18:33:17 -0500 Subject: [PATCH 1/2] Backport "Refine metadata handling during instruction hoisting #158448" 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 74eaf228c9417..73f9298b730d0 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2876,7 +2876,8 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB, // Similarly strip attributes that maybe dependent on condition we are // hoisting above. for (auto &I : *ThenBB) { - if (!SpeculatedStoreValue || &I != SpeculatedStore) + if ((!SpeculatedStoreValue || &I != SpeculatedStore) && + !isa(&I)) I.setDebugLoc(DebugLoc()); I.dropUndefImplyingAttrsAndUnknownMetadata(); } From b961243374d78823681cd0a51815bbf1a04846f5 Mon Sep 17 00:00:00 2001 From: "William S. Moses" Date: Mon, 15 Sep 2025 09:34:23 -0500 Subject: [PATCH 2/2] fix --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 73f9298b730d0..c6e11b849f5bf 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2876,9 +2876,8 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB, // Similarly strip attributes that maybe dependent on condition we are // hoisting above. for (auto &I : *ThenBB) { - if ((!SpeculatedStoreValue || &I != SpeculatedStore) && - !isa(&I)) - I.setDebugLoc(DebugLoc()); + if (!SpeculatedStoreValue || &I != SpeculatedStore) + I.dropLocation(); I.dropUndefImplyingAttrsAndUnknownMetadata(); }