summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/ADCE.cpp
diff options
context:
space:
mode:
authorBetul Buyukkurt <betulb@codeaurora.org>2016-04-13 18:52:19 +0000
committerBetul Buyukkurt <betulb@codeaurora.org>2016-04-13 18:52:19 +0000
commitbf8554c27976709a056005f10cb8ce4568ccd060 (patch)
treef4cadaae3f2b18acd90e499565d219e726b4db8b /llvm/lib/Transforms/Scalar/ADCE.cpp
parent87bcae366daf2cd690b2fc2711a7908be40b2bcf (diff)
downloadbcm5719-llvm-bf8554c27976709a056005f10cb8ce4568ccd060.tar.gz
bcm5719-llvm-bf8554c27976709a056005f10cb8ce4568ccd060.zip
[PGO] Remove redundant VP instrumentation
LLVM optimization passes may reduce a profiled target expression to a constant. Removing runtime calls at such instrumentation points would help speedup the runtime of the instrumented program. llvm-svn: 266229
Diffstat (limited to 'llvm/lib/Transforms/Scalar/ADCE.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/ADCE.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp
index d94f83d66c4..579e60f76da 100644
--- a/llvm/lib/Transforms/Scalar/ADCE.cpp
+++ b/llvm/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,6 +62,17 @@ static void collectLiveScopes(const DILocation &DL,
collectLiveScopes(*IA, AliveScopes);
}
+// Check if this instruction is a runtime call for value profiling and
+// if it's instrumenting a constant.
+static bool isInstrumentsConstant(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;
@@ -68,6 +80,10 @@ static bool aggressiveDCE(Function& F) {
// Collect the set of "root" instructions that are known live.
for (Instruction &I : instructions(F)) {
if (isa<TerminatorInst>(I) || I.isEHPad() || I.mayHaveSideEffects()) {
+ // Skip any value profile instrumentation calls if they are
+ // instrumenting constants.
+ if (isInstrumentsConstant(I))
+ continue;
Alive.insert(&I);
Worklist.push_back(&I);
}
OpenPOWER on IntegriCloud