Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3565,9 +3565,8 @@ void CodeGenFunction::EmitCheck(
llvm::BasicBlock *Handlers = createBasicBlock("handler." + CheckName);
llvm::Instruction *Branch = Builder.CreateCondBr(JointCond, Cont, Handlers);
// Give hint that we very much don't expect to execute the handler
// Value chosen to match UR_NONTAKEN_WEIGHT, see BranchProbabilityInfo.cpp
llvm::MDBuilder MDHelper(getLLVMContext());
llvm::MDNode *Node = MDHelper.createBranchWeights((1U << 20) - 1, 1);
llvm::MDNode *Node = MDHelper.createLikelyBranchWeights();
Branch->setMetadata(llvm::LLVMContext::MD_prof, Node);
EmitBlock(Handlers);

Expand Down Expand Up @@ -3635,7 +3634,7 @@ void CodeGenFunction::EmitCfiSlowPathCheck(
llvm::BranchInst *BI = Builder.CreateCondBr(Cond, Cont, CheckBB);

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

EmitBlock(CheckBB);
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/CodeGen/CGExprComplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,7 @@ ComplexPairTy ComplexExprEmitter::EmitBinMul(const BinOpInfo &Op) {
llvm::BasicBlock *OrigBB = Branch->getParent();

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

// Now test the imaginary part and create its branch.
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGObjCGNU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {

Builder.CreateCondBr(Builder.CreateICmpEQ(selfValue, Zero),
SelfIsNilBlock, ContBlock,
MDHelper.createBranchWeights(1, 1 << 20));
MDHelper.createUnlikelyBranchWeights());

CGF.EmitBlock(SelfIsNilBlock);

Expand Down Expand Up @@ -2107,7 +2107,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
CGF.createBasicBlock("objc_direct_method.class_initialized");
Builder.CreateCondBr(Builder.CreateICmpEQ(isInitialized, Zeros[0]),
notInitializedBlock, initializedBlock,
MDHelper.createBranchWeights(1, 1 << 20));
MDHelper.createUnlikelyBranchWeights());
CGF.EmitBlock(notInitializedBlock);
Builder.SetInsertPoint(notInitializedBlock);
CGF.EmitRuntimeCall(SentInitializeFn, selfValue);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGObjCMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4072,7 +4072,7 @@ void CGObjCCommonMac::GenerateDirectMethodPrologue(

llvm::MDBuilder MDHelper(CGM.getLLVMContext());
Builder.CreateCondBr(Builder.CreateICmpEQ(selfValue, Zero), SelfIsNilBlock,
ContBlock, MDHelper.createBranchWeights(1, 1 << 20));
ContBlock, MDHelper.createUnlikelyBranchWeights());

CGF.EmitBlock(SelfIsNilBlock);

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ Value *LibCallsShrinkWrap::generateCondForPow(CallInst *CI,
void LibCallsShrinkWrap::shrinkWrapCI(CallInst *CI, Value *Cond) {
assert(Cond != nullptr && "ShrinkWrapCI is not expecting an empty call inst");
MDNode *BranchWeights =
MDBuilder(CI->getContext()).createBranchWeights(1, 2000);
MDBuilder(CI->getContext()).createUnlikelyBranchWeights();

Instruction *NewInst =
SplitBlockAndInsertIfThen(Cond, CI, false, BranchWeights, &DTU);
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Util/libcalls-shrinkwrap-double.ll
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,4 @@ define void @test_pow_strictfp(i32 %int_val, double %exp) strictfp {

declare double @pow(double, double)

; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 2000}
; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 1048575}
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Util/libcalls-shrinkwrap-float.ll
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,4 @@ declare float @log2f(float)
declare float @logbf(float)
declare float @log1pf(float)

; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 2000}
; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 1048575}
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,4 @@ declare x86_fp80 @log2l(x86_fp80)
declare x86_fp80 @logbl(x86_fp80)
declare x86_fp80 @log1pl(x86_fp80)

; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 2000}
; CHECK: ![[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 1048575}