Skip to content

Commit bb2bf3a

Browse files
authored
[NFCI][metadata][clang] Use create{Unlikely,Likely}BranchWeights (#89467)
It does not look like particular value is inportant. Howere, there is a comment., but the current implementation of `create{Unlikely,Likely}BranchWeights` use the same value. Follow up to #89464
1 parent f3b212c commit bb2bf3a

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

clang/lib/CodeGen/CGExpr.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -3571,9 +3571,8 @@ void CodeGenFunction::EmitCheck(
35713571
llvm::BasicBlock *Handlers = createBasicBlock("handler." + CheckName);
35723572
llvm::Instruction *Branch = Builder.CreateCondBr(JointCond, Cont, Handlers);
35733573
// Give hint that we very much don't expect to execute the handler
3574-
// Value chosen to match UR_NONTAKEN_WEIGHT, see BranchProbabilityInfo.cpp
35753574
llvm::MDBuilder MDHelper(getLLVMContext());
3576-
llvm::MDNode *Node = MDHelper.createBranchWeights((1U << 20) - 1, 1);
3575+
llvm::MDNode *Node = MDHelper.createLikelyBranchWeights();
35773576
Branch->setMetadata(llvm::LLVMContext::MD_prof, Node);
35783577
EmitBlock(Handlers);
35793578

@@ -3641,7 +3640,7 @@ void CodeGenFunction::EmitCfiSlowPathCheck(
36413640
llvm::BranchInst *BI = Builder.CreateCondBr(Cond, Cont, CheckBB);
36423641

36433642
llvm::MDBuilder MDHelper(getLLVMContext());
3644-
llvm::MDNode *Node = MDHelper.createBranchWeights((1U << 20) - 1, 1);
3643+
llvm::MDNode *Node = MDHelper.createLikelyBranchWeights();
36453644
BI->setMetadata(llvm::LLVMContext::MD_prof, Node);
36463645

36473646
EmitBlock(CheckBB);

clang/lib/CodeGen/CGExprComplex.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,7 @@ ComplexPairTy ComplexExprEmitter::EmitBinMul(const BinOpInfo &Op) {
856856
llvm::BasicBlock *OrigBB = Branch->getParent();
857857

858858
// Give hint that we very much don't expect to see NaNs.
859-
// Value chosen to match UR_NONTAKEN_WEIGHT, see BranchProbabilityInfo.cpp
860-
llvm::MDNode *BrWeight = MDHelper.createBranchWeights(1, (1U << 20) - 1);
859+
llvm::MDNode *BrWeight = MDHelper.createUnlikelyBranchWeights();
861860
Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
862861

863862
// Now test the imaginary part and create its branch.

clang/lib/CodeGen/CGObjCGNU.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
20692069

20702070
Builder.CreateCondBr(Builder.CreateICmpEQ(selfValue, Zero),
20712071
SelfIsNilBlock, ContBlock,
2072-
MDHelper.createBranchWeights(1, 1 << 20));
2072+
MDHelper.createUnlikelyBranchWeights());
20732073

20742074
CGF.EmitBlock(SelfIsNilBlock);
20752075

@@ -2104,7 +2104,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
21042104
CGF.createBasicBlock("objc_direct_method.class_initialized");
21052105
Builder.CreateCondBr(Builder.CreateICmpEQ(isInitialized, Zeros[0]),
21062106
notInitializedBlock, initializedBlock,
2107-
MDHelper.createBranchWeights(1, 1 << 20));
2107+
MDHelper.createUnlikelyBranchWeights());
21082108
CGF.EmitBlock(notInitializedBlock);
21092109
Builder.SetInsertPoint(notInitializedBlock);
21102110
CGF.EmitRuntimeCall(SentInitializeFn, selfValue);

clang/lib/CodeGen/CGObjCMac.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4072,7 +4072,7 @@ void CGObjCCommonMac::GenerateDirectMethodPrologue(
40724072

40734073
llvm::MDBuilder MDHelper(CGM.getLLVMContext());
40744074
Builder.CreateCondBr(Builder.CreateICmpEQ(selfValue, Zero), SelfIsNilBlock,
4075-
ContBlock, MDHelper.createBranchWeights(1, 1 << 20));
4075+
ContBlock, MDHelper.createUnlikelyBranchWeights());
40764076

40774077
CGF.EmitBlock(SelfIsNilBlock);
40784078

0 commit comments

Comments
 (0)