From: Vitaly Buka Date: Wed, 15 Mar 2017 23:07:41 +0000 (+0000) Subject: Revert "Revert "[PGO] Minor cleanup for count instruction in SelectInstVisitor."" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6868195f9c576b55d065e5fbd50a130670fd7b0c;p=llvm Revert "Revert "[PGO] Minor cleanup for count instruction in SelectInstVisitor."" Previously reverted wrong revision. This reverts commit r297910. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297911 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 258b77c8add..d9c25f2e981 100644 --- a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -205,6 +205,7 @@ struct SelectInstVisitor : public InstVisitor { SelectInstVisitor(Function &Func) : F(Func) {} void countSelects(Function &Func) { + NSIs = 0; Mode = VM_counting; visit(Func); } @@ -234,6 +235,8 @@ struct SelectInstVisitor : public InstVisitor { 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; } }; @@ -1104,9 +1107,9 @@ void SelectInstVisitor::visitSelectInst(SelectInst &SI) { if (SI.getCondition()->getType()->isVectorTy()) return; - NSIs++; switch (Mode) { case VM_counting: + NSIs++; return; case VM_instrument: instrumentOneSelectInst(SI);