[PATCH] D16015: [PGO] Create the profile data variable before the lowering
Rong Xu via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 15 13:48:30 PST 2016
xur updated this revision to Diff 45033.
xur added a comment.
revised patch based on David's comments.
http://reviews.llvm.org/D16015
Files:
lib/Transforms/Instrumentation/InstrProfiling.cpp
Index: lib/Transforms/Instrumentation/InstrProfiling.cpp
===================================================================
--- lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -137,11 +137,20 @@
// We did not know how many value sites there would be inside
// the instrumented function. This is counting the number of instrumented
// target value sites to enter it as field in the profile data variable.
- for (Function &F : M)
+ for (Function &F : M) {
+ InstrProfIncrementInst *FirstProfIncInst = nullptr;
for (BasicBlock &BB : F)
- for (auto I = BB.begin(), E = BB.end(); I != E;)
- if (auto *Ind = dyn_cast<InstrProfValueProfileInst>(I++))
+ for (auto I = BB.begin(), E = BB.end(); I != E; I++)
+ if (auto *Ind = dyn_cast<InstrProfValueProfileInst>(I))
computeNumValueSiteCounts(Ind);
+ else if (FirstProfIncInst == nullptr)
+ FirstProfIncInst = dyn_cast<InstrProfIncrementInst>(I);
+
+ // Value profiling intrinsic lowering requires per-function profile data
+ // variable to be created first.
+ if (FirstProfIncInst != nullptr)
+ getOrCreateRegionCounters(FirstProfIncInst);
+ }
for (Function &F : M)
for (BasicBlock &BB : F)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16015.45033.patch
Type: text/x-patch
Size: 1287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160115/f217bc76/attachment.bin>
More information about the llvm-commits
mailing list