From ab547de7751bf37cde744278f72087f2a75c6805 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Mon, 26 Dec 2016 18:26:19 +0000 Subject: [PATCH] [NewGVN] Add a flag to enable the pass via `-mllvm`. NewGVN can be tested passing `-mllvm -enable-newgvn` to clang. Differential Revision: https://reviews.llvm.org/D28059 llvm-svn: 290548 --- .../llvm/Transforms/IPO/PassManagerBuilder.h | 1 + lib/Transforms/IPO/PassManagerBuilder.cpp | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/llvm/Transforms/IPO/PassManagerBuilder.h b/include/llvm/Transforms/IPO/PassManagerBuilder.h index 7f8a40b4abd..9f9ce467337 100644 --- a/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -132,6 +132,7 @@ public: bool LoopVectorize; bool RerollLoops; bool LoadCombine; + bool NewGVN; bool DisableGVNLoadPRE; bool VerifyInput; bool VerifyOutput; diff --git a/lib/Transforms/IPO/PassManagerBuilder.cpp b/lib/Transforms/IPO/PassManagerBuilder.cpp index 724965e27ff..6a67a721dad 100644 --- a/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -75,6 +75,9 @@ static cl::opt RunLoadCombine("combine-loads", cl::init(false), cl::Hidden, cl::desc("Run the load combining pass")); +static cl::opt RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden, + cl::desc("Run the NewGVN pass")); + static cl::opt RunSLPAfterLoopVectorization("run-slp-after-loop-vectorization", cl::init(true), cl::Hidden, @@ -162,6 +165,7 @@ PassManagerBuilder::PassManagerBuilder() { LoopVectorize = RunLoopVectorization; RerollLoops = RunLoopRerolling; LoadCombine = RunLoadCombine; + NewGVN = RunNewGVN; DisableGVNLoadPRE = false; VerifyInput = false; VerifyOutput = false; @@ -328,7 +332,8 @@ void PassManagerBuilder::addFunctionSimplificationPasses( if (OptLevel > 1) { if (EnableMLSM) MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds - MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies + MPM.add(NewGVN ? createNewGVNPass() + : createGVNPass(DisableGVNLoadPRE)); // Remove redundancies } MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset MPM.add(createSCCPPass()); // Constant prop with SCCP @@ -360,7 +365,9 @@ void PassManagerBuilder::addFunctionSimplificationPasses( addInstructionCombiningPass(MPM); addExtensionsToPM(EP_Peephole, MPM); if (OptLevel > 1 && UseGVNAfterVectorization) - MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies + MPM.add(NewGVN + ? createNewGVNPass() + : createGVNPass(DisableGVNLoadPRE)); // Remove redundancies else MPM.add(createEarlyCSEPass()); // Catch trivial redundancies @@ -605,7 +612,9 @@ void PassManagerBuilder::populateModulePassManager( addInstructionCombiningPass(MPM); addExtensionsToPM(EP_Peephole, MPM); if (OptLevel > 1 && UseGVNAfterVectorization) - MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies + MPM.add(NewGVN + ? createNewGVNPass() + : createGVNPass(DisableGVNLoadPRE)); // Remove redundancies else MPM.add(createEarlyCSEPass()); // Catch trivial redundancies @@ -757,7 +766,8 @@ void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) { PM.add(createLICMPass()); // Hoist loop invariants. if (EnableMLSM) PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds. - PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies. + PM.add(NewGVN ? createNewGVNPass() + : createGVNPass(DisableGVNLoadPRE)); // Remove redundancies. PM.add(createMemCpyOptPass()); // Remove dead memcpys. // Nuke dead stores.