]> granicus.if.org Git - llvm/commitdiff
[SamplePGO] Minor efficiency improvement in samplePGO ICP
authorTeresa Johnson <tejohnson@google.com>
Tue, 5 Feb 2019 00:18:38 +0000 (00:18 +0000)
committerTeresa Johnson <tejohnson@google.com>
Tue, 5 Feb 2019 00:18:38 +0000 (00:18 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353123 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/IndirectCallPromotion.cpp

index ac60aadfbd6cd8902f106335fe088bd82d2e6e3d..79c219aeed5cf79d84b6af12e11ed7264b4fc52f 100644 (file)
@@ -310,10 +310,10 @@ Instruction *llvm::pgo::promoteIndirectCall(Instruction *Inst,
       promoteCallWithIfThenElse(CallSite(Inst), DirectCallee, BranchWeights);
 
   if (AttachProfToDirectCall) {
-    SmallVector<uint32_t, 1> Weights;
-    Weights.push_back(Count);
     MDBuilder MDB(NewInst->getContext());
-    NewInst->setMetadata(LLVMContext::MD_prof, MDB.createBranchWeights(Weights));
+    NewInst->setMetadata(
+        LLVMContext::MD_prof,
+        MDB.createBranchWeights({static_cast<uint32_t>(Count)}));
   }
 
   using namespace ore;