[llvm] 244ec95 - [Transforms][Scalar] Remove ProfcheckDisableMetadataFixes checks

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 10:57:54 PDT 2026


Author: Aiden Grossman
Date: 2026-09-09T10:57:49-07:00
New Revision: 244ec9557be24db8ca9d212f2f7bd29e91ea06ec

URL: https://github.com/llvm/llvm-project/commit/244ec9557be24db8ca9d212f2f7bd29e91ea06ec
DIFF: https://github.com/llvm/llvm-project/commit/244ec9557be24db8ca9d212f2f7bd29e91ea06ec.diff

LOG: [Transforms][Scalar] Remove ProfcheckDisableMetadataFixes checks

Our internal ablation study on the set of checks up to 2-11-2026 has
finished, so we can remove any fixes that are older than that.

Reviewers: mtrofin

Pull Request: https://github.com/llvm/llvm-project/pull/222388

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
    llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
    llvm/lib/Transforms/Scalar/LICM.cpp
    llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
    llvm/lib/Transforms/Scalar/MergeICmps.cpp
    llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
    llvm/lib/Transforms/Scalar/SROA.cpp
    llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index 585c6e237be84..1949d52302e1e 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -136,8 +136,6 @@ static cl::opt<unsigned>
                                "accepted for the transformation"),
                       cl::Hidden, cl::init(40));
 
-extern cl::opt<bool> ProfcheckDisableMetadataFixes;
-
 } // namespace llvm
 
 namespace {
@@ -277,9 +275,8 @@ void DFAJumpThreading::unfold(DomTreeUpdater *DTU, LoopInfo *LI,
     auto *BI =
         CondBrInst::Create(SI->getCondition(), EndBlock, NewBlock, StartBlock);
     BI->setDebugLoc(SelectBranchLoc);
-    if (!ProfcheckDisableMetadataFixes)
-      BI->setMetadata(LLVMContext::MD_prof,
-                      SI->getMetadata(LLVMContext::MD_prof));
+    BI->setMetadata(LLVMContext::MD_prof,
+                    SI->getMetadata(LLVMContext::MD_prof));
     DTU->applyUpdates({{DominatorTree::Insert, StartBlock, NewBlock}});
   } else {
     BasicBlock *EndBlock = SIUse->getParent();
@@ -320,9 +317,8 @@ void DFAJumpThreading::unfold(DomTreeUpdater *DTU, LoopInfo *LI,
     DebugLoc SelectLoc = SI->getDebugLoc();
     NewFToEnd->setDebugLoc(SelectLoc);
     BI->setDebugLoc(SelectLoc);
-    if (!ProfcheckDisableMetadataFixes)
-      BI->setMetadata(LLVMContext::MD_prof,
-                      SI->getMetadata(LLVMContext::MD_prof));
+    BI->setMetadata(LLVMContext::MD_prof,
+                    SI->getMetadata(LLVMContext::MD_prof));
     DTU->applyUpdates({{DominatorTree::Insert, NewBlockT, NewBlockF},
                        {DominatorTree::Insert, NewBlockT, EndBlock},
                        {DominatorTree::Insert, NewBlockF, EndBlock}});

diff  --git a/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp b/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
index 5c8af03e8f2b0..a9247e5107b5b 100644
--- a/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
@@ -39,10 +39,6 @@ static cl::opt<unsigned> FunctionSizeThreshold(
              "or equal than this threshold."),
     cl::init(50));
 
-namespace llvm {
-extern cl::opt<bool> ProfcheckDisableMetadataFixes;
-} // end namespace llvm
-
 #define DEBUG_TYPE "jump-table-to-switch"
 
 STATISTIC(NumEligibleJumpTables, "The number of jump tables seen by the pass "
@@ -193,8 +189,7 @@ expandToSwitch(CallBase *CB, const JumpTableTy &JT, DomTreeUpdater &DTU,
   // Only set branch weights on the switch if we have non-zero branch weights.
   // We can have no non-zero branch weights while having VP metadata if for
   // example, all of the functions are external and not instrumented.
-  if (HadProfile && !ProfcheckDisableMetadataFixes &&
-      llvm::any_of(BranchWeights, not_equal_to(0))) {
+  if (HadProfile && llvm::any_of(BranchWeights, not_equal_to(0))) {
     setBranchWeights(*Switch, downscaleWeights(BranchWeights),
                      /*IsExpected=*/false);
   } else

diff  --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 37adb72d06828..8a5210e75d41a 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -169,10 +169,6 @@ cl::opt<unsigned> llvm::SetLicmMssaNoAccForPromotionCap(
              "number of accesses allowed to be present in a loop in order to "
              "enable memory promotion."));
 
-namespace llvm {
-extern cl::opt<bool> ProfcheckDisableMetadataFixes;
-} // end namespace llvm
-
 static bool inSubLoop(BasicBlock *BB, Loop *CurLoop, LoopInfo *LI);
 static bool isNotUsedOrFoldableInLoop(const Instruction &I, const Loop *CurLoop,
                                       const LoopSafetyInfo *SafetyInfo,
@@ -872,8 +868,7 @@ class ControlFlowHoister {
     HoistTarget->getTerminator()->eraseFromParent();
     // md_prof should also come from the original branch - since the
     // condition was hoisted, the branch probabilities shouldn't change.
-    if (!ProfcheckDisableMetadataFixes)
-      NewBI->copyMetadata(*BI, {LLVMContext::MD_prof});
+    NewBI->copyMetadata(*BI, {LLVMContext::MD_prof});
     // FIXME: Issue #152767: debug info should also be the same as the
     // original branch, **if** the user explicitly indicated that.
     NewBI->setDebugLoc(HoistTarget->getTerminator()->getDebugLoc());

diff  --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index dbe114f7c220a..acecc8f746839 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -186,8 +186,6 @@ static cl::opt<CRCStrategyKind> CRCStrategy(
                clEnumValN(CRCStrategyKind::Clmul, "clmul",
                           "Use carry-less multiplication when possible")));
 
-extern cl::opt<bool> ProfcheckDisableMetadataFixes;
-
 } // namespace llvm
 
 namespace {
@@ -3500,7 +3498,6 @@ bool LoopIdiomRecognize::recognizeShiftUntilBitTest() {
                                        CurLoop->getName() + ".ivcheck");
   SmallVector<uint32_t> BranchWeights;
   const bool HasBranchWeights =
-      !ProfcheckDisableMetadataFixes &&
       extractBranchWeights(*LoopHeaderBB->getTerminator(), BranchWeights);
 
   auto *BI = Builder.CreateCondBr(IVCheck, SuccessorBB, LoopHeaderBB);
@@ -3848,7 +3845,6 @@ bool LoopIdiomRecognize::recognizeShiftUntilZero() {
   Builder.SetInsertPoint(LoopHeaderBB->getTerminator());
   SmallVector<uint32_t> BranchWeights;
   const bool HasBranchWeights =
-      !ProfcheckDisableMetadataFixes &&
       extractBranchWeights(*LoopHeaderBB->getTerminator(), BranchWeights);
 
   auto *BI = Builder.CreateCondBr(CIVCheck, SuccessorBB, LoopHeaderBB);

diff  --git a/llvm/lib/Transforms/Scalar/MergeICmps.cpp b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
index 9b4285f03b33a..6ac3045c6e12f 100644
--- a/llvm/lib/Transforms/Scalar/MergeICmps.cpp
+++ b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
@@ -64,9 +64,6 @@ using namespace llvm;
 
 #define DEBUG_TYPE "mergeicmps"
 
-namespace llvm {
-extern cl::opt<bool> ProfcheckDisableMetadataFixes;
-} // namespace llvm
 namespace {
 
 // A BCE atom "Binary Compare Expression Atom" represents an integer load
@@ -625,8 +622,6 @@ class MergedBlockName {
 static std::optional<SmallVector<uint32_t, 2>>
 computeMergedBranchWeights(ArrayRef<BCECmpBlock> Comparisons) {
   assert(!Comparisons.empty());
-  if (ProfcheckDisableMetadataFixes)
-    return std::nullopt;
   if (Comparisons.size() == 1) {
     SmallVector<uint32_t, 2> Weights;
     if (!extractBranchWeights(*Comparisons[0].BB->getTerminator(), Weights))

diff  --git a/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp b/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
index ec4051a7c43e4..6a1b992c42d73 100644
--- a/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
+++ b/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
@@ -28,10 +28,6 @@
 
 using namespace llvm;
 
-namespace llvm {
-extern cl::opt<bool> ProfcheckDisableMetadataFixes;
-} // namespace llvm
-
 #define DEBUG_TYPE "partially-inline-libcalls"
 
 DEBUG_COUNTER(PILCounter, "partially-inline-libcalls-transform",
@@ -99,8 +95,7 @@ static bool optimizeSQRT(CallInst *Call, Function *CalledFunc,
                     : Builder.CreateFCmpOGE(Call->getOperand(0),
                                             ConstantFP::get(Ty, 0.0));
   CurrBBTerm->setCondition(FCmp);
-  if (!ProfcheckDisableMetadataFixes &&
-      CurrBBTerm->getFunction()->getEntryCount()) {
+  if (CurrBBTerm->getFunction()->getEntryCount()) {
     // Presume the quick path - where we don't call the library call - is the
     // frequent one
     MDBuilder MDB(CurrBBTerm->getContext());

diff  --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index a0d7a0c921796..c933225c2ad21 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -121,7 +121,6 @@ namespace llvm {
 /// Disable running mem2reg during SROA in order to test or debug SROA.
 static cl::opt<bool> SROASkipMem2Reg("sroa-skip-mem2reg", cl::init(false),
                                      cl::Hidden);
-extern cl::opt<bool> ProfcheckDisableMetadataFixes;
 } // namespace llvm
 
 namespace {
@@ -1820,8 +1819,7 @@ static void speculateSelectInstLoads(SelectInst &SI, LoadInst &LI,
   }
 
   Value *V = IRB.CreateSelect(SI.getCondition(), TL, FL,
-                              LI.getName() + ".sroa.speculated",
-                              ProfcheckDisableMetadataFixes ? nullptr : &SI);
+                              LI.getName() + ".sroa.speculated", &SI);
 
   LLVM_DEBUG(dbgs() << "          speculated to: " << *V << "\n");
   LI.replaceAllUsesWith(V);
@@ -4522,8 +4520,7 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
       Cond = SI->getCondition();
       True = SI->getTrueValue();
       False = SI->getFalseValue();
-      if (!ProfcheckDisableMetadataFixes)
-        MDFrom = SI;
+      MDFrom = SI;
     } else {
       Cond = Sel->getOperand(0);
       True = ConstantInt::get(Sel->getType(), 1);

diff  --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 7f6a08454b749..abe8d19b1a583 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -141,7 +141,6 @@ static cl::opt<unsigned> InjectInvariantConditionHotnesThreshold(
 
 static cl::opt<bool> EstimateProfile("simple-loop-unswitch-estimate-profile",
                                      cl::Hidden, cl::init(true));
-extern cl::opt<bool> ProfcheckDisableMetadataFixes;
 } // namespace llvm
 
 AnalysisKey ShouldRunExtraSimpleLoopUnswitch::Key;
@@ -293,8 +292,8 @@ static void buildPartialUnswitchConditionalBranch(
     const CondBrInst &ComputeProfFrom) {
 
   SmallVector<uint32_t> BranchWeights;
-  bool HasBranchWeights = EstimateProfile && !ProfcheckDisableMetadataFixes &&
-                          extractBranchWeights(ComputeProfFrom, BranchWeights);
+  bool HasBranchWeights =
+      EstimateProfile && extractBranchWeights(ComputeProfFrom, BranchWeights);
   // If Direction is true, that means we had a disjunction and that the "true"
   // case exits. The probability of the disjunction of the subset of terms is at
   // most as high as the original one. So, if the probability is higher than the
@@ -380,8 +379,7 @@ static void buildPartialInvariantUnswitchConditionalBranch(
   // The expectation is that ToDuplicate[0] is the condition used by the
   // OriginalBranch, case in which we can clone the profile metadata from there.
   auto *ProfData =
-      !ProfcheckDisableMetadataFixes &&
-              ToDuplicate[0] == skipTrivialSelect(OriginalBranch.getCondition())
+      ToDuplicate[0] == skipTrivialSelect(OriginalBranch.getCondition())
           ? OriginalBranch.getMetadata(LLVMContext::MD_prof)
           : nullptr;
   auto *BR =
@@ -2580,7 +2578,7 @@ static CondBrInst *turnGuardIntoBranch(IntrinsicInst *GI, Loop &L,
   // however, that the deopt path is unlikely.
   Instruction *DeoptBlockTerm = SplitBlockAndInsertIfThen(
       GI->getArgOperand(0), GI, true,
-      !ProfcheckDisableMetadataFixes && EstimateProfile
+      EstimateProfile
           ? MDBuilder(GI->getContext()).createUnlikelyBranchWeights()
           : nullptr,
       &DTU, &LI);
@@ -2950,10 +2948,9 @@ injectPendingInvariantConditions(NonTrivialUnswitchCandidate Candidate, Loop &L,
   setExplicitlyUnknownBranchWeightsIfProfiled(*InvariantBr, DEBUG_TYPE);
 
   Builder.SetInsertPoint(CheckBlock);
-  Builder.CreateCondBr(
-      TI->getCondition(), TI->getSuccessor(0), TI->getSuccessor(1),
-      !ProfcheckDisableMetadataFixes ? TI->getMetadata(LLVMContext::MD_prof)
-                                     : nullptr);
+  Builder.CreateCondBr(TI->getCondition(), TI->getSuccessor(0),
+                       TI->getSuccessor(1),
+                       TI->getMetadata(LLVMContext::MD_prof));
   TI->eraseFromParent();
 
   // Fixup phis.


        


More information about the llvm-commits mailing list