Skip to content

Commit 4bdf82c

Browse files
committedFeb 5, 2019
[SamplePGO] Minor efficiency improvement in samplePGO ICP
Summary: When attaching prof metadata to promoted direct calls in SamplePGO mode, no need to construct and use a SmallVector to pass a single count to the ArrayRef parameter, we can simply use a brace-enclosed init list. This made a small but consistent improvement for a ThinLTO backend compile I was measuring. Reviewers: wmi Subscribers: mehdi_amini, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57706 llvm-svn: 353123
1 parent 81511e5 commit 4bdf82c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ Instruction *llvm::pgo::promoteIndirectCall(Instruction *Inst,
310310
promoteCallWithIfThenElse(CallSite(Inst), DirectCallee, BranchWeights);
311311

312312
if (AttachProfToDirectCall) {
313-
SmallVector<uint32_t, 1> Weights;
314-
Weights.push_back(Count);
315313
MDBuilder MDB(NewInst->getContext());
316-
NewInst->setMetadata(LLVMContext::MD_prof, MDB.createBranchWeights(Weights));
314+
NewInst->setMetadata(
315+
LLVMContext::MD_prof,
316+
MDB.createBranchWeights({static_cast<uint32_t>(Count)}));
317317
}
318318

319319
using namespace ore;

0 commit comments

Comments
 (0)