Skip to content

Commit fe68afb

Browse files
committed
[ProfInfo] Remove Function argument from branch weight setter (NFC).
There is no need to pass the function explicitly, we can simply retrieve if from the passed instruction.
1 parent 04f87c6 commit fe68afb

File tree

7 files changed

+7
-12
lines changed

7 files changed

+7
-12
lines changed

llvm/include/llvm/IR/ProfDataUtils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ LLVM_ABI void setExplicitlyUnknownBranchWeights(Instruction &I,
196196
/// instruction has an entry count. This is to not confuse users by injecting
197197
/// profile data into non-profiled functions.
198198
LLVM_ABI void setExplicitlyUnknownBranchWeightsIfProfiled(Instruction &I,
199-
Function &F,
200199
StringRef PassName);
201200

202201
/// Analogous to setExplicitlyUnknownBranchWeights, but for functions and their

llvm/lib/IR/IRBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,7 @@ Value *IRBuilderBase::CreateSelectWithUnknownProfile(Value *C, Value *True,
10191019
const Twine &Name) {
10201020
Value *Ret = CreateSelectFMF(C, True, False, {}, Name);
10211021
if (auto *SI = dyn_cast<SelectInst>(Ret)) {
1022-
setExplicitlyUnknownBranchWeightsIfProfiled(
1023-
*SI, *SI->getParent()->getParent(), PassName);
1022+
setExplicitlyUnknownBranchWeightsIfProfiled(*SI, PassName);
10241023
}
10251024
return Ret;
10261025
}

llvm/lib/IR/ProfDataUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ void llvm::setExplicitlyUnknownBranchWeights(Instruction &I,
274274
}
275275

276276
void llvm::setExplicitlyUnknownBranchWeightsIfProfiled(Instruction &I,
277-
Function &F,
278277
StringRef PassName) {
279-
if (std::optional<Function::ProfileCount> EC = F.getEntryCount();
278+
Function *F = I.getFunction();
279+
if (std::optional<Function::ProfileCount> EC = F->getEntryCount();
280280
EC && EC->getCount() > 0)
281281
setExplicitlyUnknownBranchWeights(I, PassName);
282282
}

llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,8 +1378,7 @@ static bool foldMemChr(CallInst *Call, DomTreeUpdater *DTU,
13781378
IRB.CreateTrunc(Call->getArgOperand(1), ByteTy), BBNext, N);
13791379
// We can't know the precise weights here, as they would depend on the value
13801380
// distribution of Call->getArgOperand(1). So we just mark it as "unknown".
1381-
setExplicitlyUnknownBranchWeightsIfProfiled(*SI, *Call->getFunction(),
1382-
DEBUG_TYPE);
1381+
setExplicitlyUnknownBranchWeightsIfProfiled(*SI, DEBUG_TYPE);
13831382
Type *IndexTy = DL.getIndexType(Call->getType());
13841383
SmallVector<DominatorTree::UpdateType, 8> Updates;
13851384

llvm/lib/Transforms/InstCombine/InstCombineInternal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
479479
const Twine &NameStr = "",
480480
InsertPosition InsertBefore = nullptr) {
481481
auto *Sel = SelectInst::Create(C, S1, S2, NameStr, InsertBefore, nullptr);
482-
setExplicitlyUnknownBranchWeightsIfProfiled(*Sel, F, DEBUG_TYPE);
482+
setExplicitlyUnknownBranchWeightsIfProfiled(*Sel, DEBUG_TYPE);
483483
return Sel;
484484
}
485485

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ static void buildPartialUnswitchConditionalBranch(
329329
HasBranchWeights ? ComputeProfFrom.getMetadata(LLVMContext::MD_prof)
330330
: nullptr);
331331
if (!HasBranchWeights)
332-
setExplicitlyUnknownBranchWeightsIfProfiled(
333-
*BR, *BR->getParent()->getParent(), DEBUG_TYPE);
332+
setExplicitlyUnknownBranchWeightsIfProfiled(*BR, DEBUG_TYPE);
334333
}
335334

336335
/// Copy a set of loop invariant values, and conditionally branch on them.

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5212,8 +5212,7 @@ bool SimplifyCFGOpt::simplifyBranchOnICmpChain(BranchInst *BI,
52125212
// We don't have any info about this condition.
52135213
auto *Br = TrueWhenEqual ? Builder.CreateCondBr(ExtraCase, EdgeBB, NewBB)
52145214
: Builder.CreateCondBr(ExtraCase, NewBB, EdgeBB);
5215-
setExplicitlyUnknownBranchWeightsIfProfiled(*Br, *NewBB->getParent(),
5216-
DEBUG_TYPE);
5215+
setExplicitlyUnknownBranchWeightsIfProfiled(*Br, DEBUG_TYPE);
52175216

52185217
OldTI->eraseFromParent();
52195218

0 commit comments

Comments
 (0)