[llvm] r284099 - Memory-SSA: strengthen defClobbersUseOrDef interface
Sebastian Pop via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 20:23:33 PDT 2016
Author: spop
Date: Wed Oct 12 22:23:33 2016
New Revision: 284099
URL: http://llvm.org/viewvc/llvm-project?rev=284099&view=rev
Log:
Memory-SSA: strengthen defClobbersUseOrDef interface
As Danny pointed out, defClobbersUseOrDef should use MemoryLocOrCall to make
sure fences are properly handled.
Modified:
llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp
Modified: llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp?rev=284099&r1=284098&r2=284099&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp Wed Oct 12 22:23:33 2016
@@ -105,6 +105,8 @@ public:
MemoryLocOrCall() : IsCall(false) {}
MemoryLocOrCall(MemoryUseOrDef *MUD)
: MemoryLocOrCall(MUD->getMemoryInst()) {}
+ MemoryLocOrCall(const MemoryUseOrDef *MUD)
+ : MemoryLocOrCall(MUD->getMemoryInst()) {}
MemoryLocOrCall(Instruction *Inst) {
if (ImmutableCallSite(Inst)) {
@@ -254,16 +256,22 @@ static bool instructionClobbersQuery(Mem
return AA.getModRefInfo(DefInst, UseLoc) & MRI_Mod;
}
+static bool instructionClobbersQuery(MemoryDef *MD, const MemoryUseOrDef *MU,
+ const MemoryLocOrCall &UseMLOC,
+ AliasAnalysis &AA) {
+ // FIXME: This is a temporary hack to allow a single instructionClobbersQuery
+ // to exist while MemoryLocOrCall is pushed through places.
+ if (UseMLOC.IsCall)
+ return instructionClobbersQuery(MD, MemoryLocation(), MU->getMemoryInst(),
+ AA);
+ return instructionClobbersQuery(MD, UseMLOC.getLoc(), MU->getMemoryInst(),
+ AA);
+}
+
// Return true when MD may alias MU, return false otherwise.
bool defClobbersUseOrDef(MemoryDef *MD, const MemoryUseOrDef *MU,
AliasAnalysis &AA) {
- Instruction *UseInst = MU->getMemoryInst();
- MemoryLocation UseLoc;
- if (ImmutableCallSite(UseInst))
- UseLoc = MemoryLocation();
- else
- UseLoc = MemoryLocation::get(UseInst);
- return instructionClobbersQuery(MD, UseLoc, UseInst, AA);
+ return instructionClobbersQuery(MD, MU, MemoryLocOrCall(MU), AA);
}
}
@@ -315,18 +323,6 @@ static bool isUseTriviallyOptimizableToL
AA.pointsToConstantMemory(I));
}
-static bool instructionClobbersQuery(MemoryDef *MD, MemoryUse *MU,
- const MemoryLocOrCall &UseMLOC,
- AliasAnalysis &AA) {
- // FIXME: This is a temporary hack to allow a single instructionClobbersQuery
- // to exist while MemoryLocOrCall is pushed through places.
- if (UseMLOC.IsCall)
- return instructionClobbersQuery(MD, MemoryLocation(), MU->getMemoryInst(),
- AA);
- return instructionClobbersQuery(MD, UseMLOC.getLoc(), MU->getMemoryInst(),
- AA);
-}
-
/// Cache for our caching MemorySSA walker.
class WalkerCache {
DenseMap<ConstMemoryAccessPair, MemoryAccess *> Accesses;
More information about the llvm-commits
mailing list