[PATCH] D18784: [PGO] Remove redundant VP runtime calls

Betul Buyukkurt via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 8 11:00:56 PDT 2016


betulb updated the summary for this revision.
betulb removed rL LLVM as the repository for this revision.
betulb updated this revision to Diff 53041.
betulb added a comment.

Integrated the removal of the VP calls into ADCE pass.


http://reviews.llvm.org/D18784

Files:
  lib/Transforms/Scalar/ADCE.cpp

Index: lib/Transforms/Scalar/ADCE.cpp
===================================================================
--- lib/Transforms/Scalar/ADCE.cpp
+++ lib/Transforms/Scalar/ADCE.cpp
@@ -27,6 +27,7 @@
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/Pass.h"
+#include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Transforms/Scalar.h"
 using namespace llvm;
 
@@ -61,13 +62,24 @@
     collectLiveScopes(*IA, AliveScopes);
 }
 
+static bool instrumentsConstants(Instruction &I) {
+  if (CallInst *CI = dyn_cast<CallInst>(&I))
+    if (Function *Callee = CI->getCalledFunction())
+      if (Callee->getName().equals(getInstrProfValueProfFuncName()))
+        if (isa<Constant>(CI->getArgOperand(0)))
+          return true;
+  return false;
+}
+
 static bool aggressiveDCE(Function& F) {
   SmallPtrSet<Instruction*, 32> Alive;
   SmallVector<Instruction*, 128> Worklist;
 
   // Collect the set of "root" instructions that are known live.
   for (Instruction &I : instructions(F)) {
     if (isa<TerminatorInst>(I) || I.isEHPad() || I.mayHaveSideEffects()) {
+      if (instrumentsConstants(I))
+        continue;
       Alive.insert(&I);
       Worklist.push_back(&I);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18784.53041.patch
Type: text/x-patch
Size: 1208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160408/b5db82e7/attachment.bin>


More information about the llvm-commits mailing list