mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-18 21:24:32 -04:00
[MemDep] Use PhiValuesAnalysis to improve alias analysis results
This is being done in order to make GVN able to better optimize certain inputs. MemDep doesn't use PhiValues directly, but does need to notifiy it when things get invalidated. Differential Revision: https://reviews.llvm.org/D48489 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338384 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "llvm/Analysis/MemoryLocation.h"
|
||||
#include "llvm/Analysis/OrderedBasicBlock.h"
|
||||
#include "llvm/Analysis/PHITransAddr.h"
|
||||
#include "llvm/Analysis/PhiValues.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
#include "llvm/IR/Attributes.h"
|
||||
@@ -1513,6 +1514,8 @@ void MemoryDependenceResults::invalidateCachedPointerInfo(Value *Ptr) {
|
||||
RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, false));
|
||||
// Flush load info for the pointer.
|
||||
RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, true));
|
||||
// Invalidate phis that use the pointer.
|
||||
PV.invalidateValue(Ptr);
|
||||
}
|
||||
|
||||
void MemoryDependenceResults::invalidateCachedPredecessors() {
|
||||
@@ -1671,6 +1674,9 @@ void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
|
||||
}
|
||||
}
|
||||
|
||||
// Invalidate phis that use the removed instruction.
|
||||
PV.invalidateValue(RemInst);
|
||||
|
||||
assert(!NonLocalDeps.count(RemInst) && "RemInst got reinserted?");
|
||||
LLVM_DEBUG(verifyRemoved(RemInst));
|
||||
}
|
||||
@@ -1730,7 +1736,8 @@ MemoryDependenceAnalysis::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
auto &AC = AM.getResult<AssumptionAnalysis>(F);
|
||||
auto &TLI = AM.getResult<TargetLibraryAnalysis>(F);
|
||||
auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
|
||||
return MemoryDependenceResults(AA, AC, TLI, DT);
|
||||
auto &PV = AM.getResult<PhiValuesAnalysis>(F);
|
||||
return MemoryDependenceResults(AA, AC, TLI, DT, PV);
|
||||
}
|
||||
|
||||
char MemoryDependenceWrapperPass::ID = 0;
|
||||
@@ -1741,6 +1748,7 @@ INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
|
||||
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(PhiValuesWrapperPass)
|
||||
INITIALIZE_PASS_END(MemoryDependenceWrapperPass, "memdep",
|
||||
"Memory Dependence Analysis", false, true)
|
||||
|
||||
@@ -1758,6 +1766,7 @@ void MemoryDependenceWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.setPreservesAll();
|
||||
AU.addRequired<AssumptionCacheTracker>();
|
||||
AU.addRequired<DominatorTreeWrapperPass>();
|
||||
AU.addRequired<PhiValuesWrapperPass>();
|
||||
AU.addRequiredTransitive<AAResultsWrapperPass>();
|
||||
AU.addRequiredTransitive<TargetLibraryInfoWrapperPass>();
|
||||
}
|
||||
@@ -1773,7 +1782,8 @@ bool MemoryDependenceResults::invalidate(Function &F, const PreservedAnalyses &P
|
||||
// Check whether the analyses we depend on became invalid for any reason.
|
||||
if (Inv.invalidate<AAManager>(F, PA) ||
|
||||
Inv.invalidate<AssumptionAnalysis>(F, PA) ||
|
||||
Inv.invalidate<DominatorTreeAnalysis>(F, PA))
|
||||
Inv.invalidate<DominatorTreeAnalysis>(F, PA) ||
|
||||
Inv.invalidate<PhiValuesAnalysis>(F, PA))
|
||||
return true;
|
||||
|
||||
// Otherwise this analysis result remains valid.
|
||||
@@ -1789,6 +1799,7 @@ bool MemoryDependenceWrapperPass::runOnFunction(Function &F) {
|
||||
auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
|
||||
auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
|
||||
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
||||
MemDep.emplace(AA, AC, TLI, DT);
|
||||
auto &PV = getAnalysis<PhiValuesWrapperPass>().getResult();
|
||||
MemDep.emplace(AA, AC, TLI, DT, PV);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user