diff options
| author | Florian Hahn <florian.hahn@arm.com> | 2018-08-21 19:11:27 +0000 |
|---|---|---|
| committer | Florian Hahn <florian.hahn@arm.com> | 2018-08-21 19:11:27 +0000 |
| commit | 9583d4fa03e8010ba6f80302940b548084d8c477 (patch) | |
| tree | 857c6c2697e025a7311b4e57cd82ab4f8b68a517 /llvm/lib/Transforms/Scalar | |
| parent | b211434a78d43823307e1c9a44af480f246c3f0c (diff) | |
| download | bcm5719-llvm-9583d4fa03e8010ba6f80302940b548084d8c477.tar.gz bcm5719-llvm-9583d4fa03e8010ba6f80302940b548084d8c477.zip | |
[GVN] Assign new value number to calls reading memory, if there is no MemDep info.
Currently we assign the same value number to two calls reading the same
memory location if we do not have MemoryDependence info. Without MemDep
Info we cannot guarantee that there is no store between the two calls, so we
have to assign a new number to the second call.
It also adds a new option EnableMemDep to enable/disable running
MemoryDependenceAnalysis and also renamed NoLoads to NoMemDepAnalysis to
be more explicit what it does. As it also impacts calls that read memory,
NoLoads is a bit confusing.
Reviewers: efriedma, sebpop, john.brawn, wmi
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D50893
llvm-svn: 340319
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 1a127119422..3e36943ada0 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -98,6 +98,7 @@ STATISTIC(NumPRELoad, "Number of loads PRE'd"); static cl::opt<bool> EnablePRE("enable-pre", cl::init(true), cl::Hidden); static cl::opt<bool> EnableLoadPRE("enable-load-pre", cl::init(true)); +static cl::opt<bool> EnableMemDep("enable-gvn-memdep", cl::init(true)); // Maximum allowed recursion depth. static cl::opt<uint32_t> @@ -393,18 +394,13 @@ uint32_t GVN::ValueTable::lookupOrAddCall(CallInst *C) { uint32_t e = assignExpNewValueNum(exp).first; valueNumbering[C] = e; return e; - } else if (AA->onlyReadsMemory(C)) { + } else if (MD && AA->onlyReadsMemory(C)) { Expression exp = createExpr(C); auto ValNum = assignExpNewValueNum(exp); if (ValNum.second) { valueNumbering[C] = ValNum.first; return ValNum.first; } - if (!MD) { - uint32_t e = assignExpNewValueNum(exp).first; - valueNumbering[C] = e; - return e; - } MemDepResult local_dep = MD->getDependency(C); @@ -2520,8 +2516,8 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass { public: static char ID; // Pass identification, replacement for typeid - explicit GVNLegacyPass(bool NoLoads = false) - : FunctionPass(ID), NoLoads(NoLoads) { + explicit GVNLegacyPass(bool NoMemDepAnalysis = !EnableMemDep) + : FunctionPass(ID), NoMemDepAnalysis(NoMemDepAnalysis) { initializeGVNLegacyPassPass(*PassRegistry::getPassRegistry()); } @@ -2536,7 +2532,7 @@ public: getAnalysis<DominatorTreeWrapperPass>().getDomTree(), getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(), getAnalysis<AAResultsWrapperPass>().getAAResults(), - NoLoads ? nullptr + NoMemDepAnalysis ? nullptr : &getAnalysis<MemoryDependenceWrapperPass>().getMemDep(), LIWP ? &LIWP->getLoopInfo() : nullptr, &getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE()); @@ -2546,7 +2542,7 @@ public: AU.addRequired<AssumptionCacheTracker>(); AU.addRequired<DominatorTreeWrapperPass>(); AU.addRequired<TargetLibraryInfoWrapperPass>(); - if (!NoLoads) + if (!NoMemDepAnalysis) AU.addRequired<MemoryDependenceWrapperPass>(); AU.addRequired<AAResultsWrapperPass>(); @@ -2557,7 +2553,7 @@ public: } private: - bool NoLoads; + bool NoMemDepAnalysis; GVN Impl; }; @@ -2574,6 +2570,6 @@ INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass) INITIALIZE_PASS_END(GVNLegacyPass, "gvn", "Global Value Numbering", false, false) // The public interface to this file... -FunctionPass *llvm::createGVNPass(bool NoLoads) { - return new GVNLegacyPass(NoLoads); +FunctionPass *llvm::createGVNPass(bool NoMemDepAnalysis) { + return new GVNLegacyPass(NoMemDepAnalysis); } |

