[PATCH] D57706: [SamplePGO] Minor efficiency improvement in samplePGO ICP

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 4 12:26:13 PST 2019


tejohnson created this revision.
tejohnson added a reviewer: wmi.
Herald added subscribers: dexonsmith, mehdi_amini.
Herald added a project: LLVM.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D57706

Files:
  lib/Transforms/Instrumentation/IndirectCallPromotion.cpp


Index: lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
===================================================================
--- lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -310,10 +310,10 @@
       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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57706.185123.patch
Type: text/x-patch
Size: 742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190204/c84fd09c/attachment.bin>


More information about the llvm-commits mailing list