[PATCH] D30999: [PGO] Minor cleanup for count instruction in SelectInstVisitor.
Rong Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 15 13:47:27 PDT 2017
xur created this revision.
NSIs can be double-counted by different operations in
SelectInstVisitor. Sink the the update to VM_counting mode only.
Also reset the value for each counting operation.
https://reviews.llvm.org/D30999
Files:
lib/Transforms/Instrumentation/PGOInstrumentation.cpp
Index: lib/Transforms/Instrumentation/PGOInstrumentation.cpp
===================================================================
--- lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -200,6 +200,7 @@
SelectInstVisitor(Function &Func) : F(Func) {}
void countSelects(Function &Func) {
+ NSIs = 0;
Mode = VM_counting;
visit(Func);
}
@@ -229,6 +230,8 @@
void annotateOneSelectInst(SelectInst &SI);
// Visit \p SI instruction and perform tasks according to visit mode.
void visitSelectInst(SelectInst &SI);
+ // Return the number of select instructions. This needs be called after
+ // countSelects().
unsigned getNumOfSelectInsts() const { return NSIs; }
};
@@ -1058,9 +1061,9 @@
if (SI.getCondition()->getType()->isVectorTy())
return;
- NSIs++;
switch (Mode) {
case VM_counting:
+ NSIs++;
return;
case VM_instrument:
instrumentOneSelectInst(SI);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30999.91924.patch
Type: text/x-patch
Size: 982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170315/bc8f4a73/attachment.bin>
More information about the llvm-commits
mailing list