[llvm-branch-commits] [IR] Remove ProfcheckDisableMetadataFixes checks (PR #222425)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Sep 9 12:01:04 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Aiden Grossman (boomanaiden154)

<details>
<summary>Changes</summary>

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.

Also remove some calls to applyProfMetadataIfEnabled that were added
before the cutoff date. Leave the rest that were added afterwards.


---
Full diff: https://github.com/llvm/llvm-project/pull/222425.diff


3 Files Affected:

- (modified) llvm/lib/IR/Instruction.cpp (+1-2) 
- (modified) llvm/lib/IR/Metadata.cpp (+1-5) 
- (modified) llvm/lib/Transforms/Utils/IntegerDivision.cpp (+6-12) 


``````````diff
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 2cfd9fb902886..60e4f353585db 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -587,8 +587,7 @@ void Instruction::dropUBImplyingAttrsAndMetadata(ArrayRef<unsigned> Keep) {
       LLVMContext::MD_mem_cache_hint, LLVMContext::MD_nofpclass};
   SmallVector<unsigned> KeepIDs;
   KeepIDs.reserve(Keep.size() + std::size(KnownIDs));
-  append_range(KeepIDs, (!ProfcheckDisableMetadataFixes ? KnownIDs
-                                                        : drop_end(KnownIDs)));
+  append_range(KeepIDs, KnownIDs);
   append_range(KeepIDs, Keep);
   dropUBImplyingAttrsAndUnknownMetadata(KeepIDs);
 }
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 2b1a7bb117308..fe79bd08ffa52 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -61,10 +61,6 @@
 
 using namespace llvm;
 
-namespace llvm {
-extern cl::opt<bool> ProfcheckDisableMetadataFixes;
-}
-
 MetadataAsValue::MetadataAsValue(Type *Ty, Metadata *MD)
     : Value(Ty, MetadataAsValueVal), MD(MD) {
   track();
@@ -1287,7 +1283,7 @@ MDNode *MDNode::getMergedProfMetadata(MDNode *A, MDNode *B,
       BCall->getCalledFunction())
     return mergeDirectCallProfMetadata(A, B, AInstr, BInstr);
 
-  if (A == B && !ProfcheckDisableMetadataFixes)
+  if (A == B)
     return A;
 
   // The rest of the cases are not implemented but could be added
diff --git a/llvm/lib/Transforms/Utils/IntegerDivision.cpp b/llvm/lib/Transforms/Utils/IntegerDivision.cpp
index 875ebecd493a5..549c8e32c6079 100644
--- a/llvm/lib/Transforms/Utils/IntegerDivision.cpp
+++ b/llvm/lib/Transforms/Utils/IntegerDivision.cpp
@@ -245,33 +245,29 @@ static Value *generateUnsignedDivisionCode(Value *Dividend, Value *Divisor,
   // Add 'unlikely' branch weights. We mark the case where either the divisor
   // or the dividend is equal to zero as unlikely.
   Value *Ret0        = Builder.CreateLogicalOr(Ret0_3, Ret0_4);
-  applyProfMetadataIfEnabled(Ret0, [&](Instruction *Inst) {
+  if (auto *Inst = dyn_cast<Instruction>(Ret0))
     Inst->setMetadata(
         LLVMContext::MD_prof,
         MDBuilder(Inst->getContext()).createUnlikelyBranchWeights());
-  });
   Value *RetDividend = Builder.CreateICmpEQ(SR, MSB);
 
   // Conservatively, we treat the case |divisor| > |dividend| as unknown
   Value *RetVal      = Builder.CreateSelect(Ret0, Zero, Dividend);
-  applyProfMetadataIfEnabled(RetVal, [&](Instruction *Inst) {
+  if (auto *Inst = dyn_cast<Instruction>(RetVal))
     setExplicitlyUnknownBranchWeightsIfProfiled(*Inst, DEBUG_TYPE, F);
-  });
   Value *EarlyRet    = Builder.CreateLogicalOr(Ret0, RetDividend);
-  applyProfMetadataIfEnabled(EarlyRet, [&](Instruction *Inst) {
+  if (auto *Inst = dyn_cast<Instruction>(EarlyRet))
     setExplicitlyUnknownBranchWeightsIfProfiled(*Inst, DEBUG_TYPE, F);
-  });
 
   // The condition of this branch is based on `EarlyRet`. `EarlyRet` is true
   // only for special cases like dividend or divisor being zero, or the divisor
   // being greater than the dividend. Thus, the branch to `End` is unlikely,
   // and we expect to more frequently enter `BB1`.
   Value *ConBrSpecialCases = Builder.CreateCondBr(EarlyRet, End, BB1);
-  applyProfMetadataIfEnabled(ConBrSpecialCases, [&](Instruction *Inst) {
+  if (auto *Inst = dyn_cast<Instruction>(ConBrSpecialCases))
     Inst->setMetadata(
         LLVMContext::MD_prof,
         MDBuilder(Inst->getContext()).createUnlikelyBranchWeights());
-  });
 
   // ; bb1:                                             ; preds = %special-cases
   // ;   %sr_1     = add i32 %sr, 1
@@ -289,11 +285,10 @@ static Value *generateUnsignedDivisionCode(Value *Dividend, Value *Divisor,
   // >= 2. The case where SR_1 == 0 is thus considered unlikely.
   Value *SkipLoop = Builder.CreateICmpEQ(SR_1, Zero);
   Value *ConBrBB1 = Builder.CreateCondBr(SkipLoop, LoopExit, Preheader);
-  applyProfMetadataIfEnabled(ConBrBB1, [&](Instruction *Inst) {
+  if (auto *Inst = dyn_cast<Instruction>(ConBrBB1))
     Inst->setMetadata(
         LLVMContext::MD_prof,
         MDBuilder(Inst->getContext()).createUnlikelyBranchWeights());
-  });
 
   // ; preheader:                                           ; preds = %bb1
   // ;   %tmp3 = lshr i32 %dividend, %sr_1
@@ -343,11 +338,10 @@ static Value *generateUnsignedDivisionCode(Value *Dividend, Value *Divisor,
   // The branch is unlikely to exit the loop early until it has processed all
   // significant bits.
   Value *ConBrDoWhile = Builder.CreateCondBr(Tmp12, LoopExit, DoWhile);
-  applyProfMetadataIfEnabled(ConBrDoWhile, [&](Instruction *Inst) {
+  if (auto *Inst = dyn_cast<Instruction>(ConBrDoWhile))
     Inst->setMetadata(
         LLVMContext::MD_prof,
         MDBuilder(Inst->getContext()).createUnlikelyBranchWeights());
-  });
 
   // ; loop-exit:                                      ; preds = %do-while, %bb1
   // ;   %carry_2 = phi i32 [ 0, %bb1 ], [ %carry, %do-while ]

``````````

</details>


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


More information about the llvm-branch-commits mailing list