Index: include/llvm/Analysis/AliasAnalysis.h =================================================================== --- include/llvm/Analysis/AliasAnalysis.h +++ include/llvm/Analysis/AliasAnalysis.h @@ -95,17 +95,25 @@ /// /// This is no access at all, a modification, a reference, or both /// a modification and a reference. These are specifically structured such that -/// they form a two bit matrix and bit-tests for 'mod' or 'ref' work with any -/// of the possible values. +/// they form a three bit matrix and bit-tests for 'mod' or 'ref' or 'must' +/// work with any of the possible values. enum ModRefInfo { /// The access neither references nor modifies the value stored in memory. MRI_NoModRef = 0, - /// The access references the value stored in memory. + /// The access may reference the value stored in memory. MRI_Ref = 1, - /// The access modifies the value stored in memory. + /// The access may modify the value stored in memory. MRI_Mod = 2, - /// The access both references and modifies the value stored in memory. - MRI_ModRef = MRI_Ref | MRI_Mod + /// The access may reference and may modify the value stored in memory. + MRI_ModRef = MRI_Ref | MRI_Mod, + /// The access must alias the value stored in memory. + MRI_Must = 4, + /// The access must reference the value stored in memory. + MRI_MustRef = MRI_Ref | MRI_Must, + /// The access must modify the value stored in memory. + MRI_MustMod = MRI_Mod | MRI_Must, + /// The access must reference and must modify the value stored in memory. + MRI_MustModRef = MRI_ModRef | MRI_Must }; /// The locations at which a function might access memory. @@ -117,11 +125,11 @@ /// Base case is no access to memory. FMRL_Nowhere = 0, /// Access to memory via argument pointers. - FMRL_ArgumentPointees = 4, + FMRL_ArgumentPointees = 8, /// Memory that is inaccessible via LLVM IR. - FMRL_InaccessibleMem = 8, + FMRL_InaccessibleMem = 16, /// Access to any memory. - FMRL_Anywhere = 16 | FMRL_InaccessibleMem | FMRL_ArgumentPointees + FMRL_Anywhere = 32 | FMRL_InaccessibleMem | FMRL_ArgumentPointees }; /// Summary of how a function affects memory in the program. Index: lib/Analysis/AliasAnalysis.cpp =================================================================== --- lib/Analysis/AliasAnalysis.cpp +++ lib/Analysis/AliasAnalysis.cpp @@ -125,7 +125,7 @@ Result = ModRefInfo(Result & AA->getArgModRefInfo(CS, ArgIdx)); // Early-exit the moment we reach the bottom of the lattice. - if (Result == MRI_NoModRef) + if ((Result & MRI_ModRef) == MRI_NoModRef) return Result; } @@ -146,8 +146,9 @@ // is that if the call references what this instruction // defines, it must be clobbered by this location. const MemoryLocation DefLoc = MemoryLocation::get(I); - if (getModRefInfo(Call, DefLoc) != MRI_NoModRef) - return MRI_ModRef; + ModRefInfo MR = getModRefInfo(Call, DefLoc); + if (MR & MRI_ModRef) + return ModRefInfo(MRI_ModRef | (MR & MRI_Must)); } return MRI_NoModRef; } @@ -160,7 +161,7 @@ Result = ModRefInfo(Result & AA->getModRefInfo(CS, Loc)); // Early-exit the moment we reach the bottom of the lattice. - if (Result == MRI_NoModRef) + if ((Result & MRI_ModRef) == MRI_NoModRef) return Result; } @@ -172,16 +173,18 @@ return MRI_NoModRef; if (onlyReadsMemory(MRB)) - Result = ModRefInfo(Result & MRI_Ref); + Result = ModRefInfo(Result & MRI_MustRef); else if (doesNotReadMemory(MRB)) - Result = ModRefInfo(Result & MRI_Mod); + Result = ModRefInfo(Result & MRI_MustMod); if (onlyAccessesArgPointees(MRB) || onlyAccessesInaccessibleOrArgMem(MRB)) { bool DoesAlias = false; + bool MayAlias = false; ModRefInfo AllArgsMask = MRI_NoModRef; if (doesAccessArgPointees(MRB)) { for (auto AI = CS.arg_begin(), AE = CS.arg_end(); AI != AE; ++AI) { const Value *Arg = *AI; + // FIXME: Set MRI_Must for non-pointer types? if (!Arg->getType()->isPointerTy()) continue; unsigned ArgIdx = std::distance(CS.arg_begin(), AI); @@ -191,11 +194,15 @@ ModRefInfo ArgMask = getArgModRefInfo(CS, ArgIdx); DoesAlias = true; AllArgsMask = ModRefInfo(AllArgsMask | ArgMask); + if (ArgAlias != MustAlias) + MayAlias = true; } } } if (!DoesAlias) return MRI_NoModRef; + else if (!MayAlias) + AllArgsMask = ModRefInfo(AllArgsMask | MRI_Must); Result = ModRefInfo(Result & AllArgsMask); } @@ -216,7 +223,7 @@ Result = ModRefInfo(Result & AA->getModRefInfo(CS1, CS2)); // Early-exit the moment we reach the bottom of the lattice. - if (Result == MRI_NoModRef) + if ((Result & MRI_ModRef) == MRI_NoModRef) return Result; } @@ -239,9 +246,9 @@ // If CS1 only reads memory, the only dependence on CS2 can be // from CS1 reading memory written by CS2. if (onlyReadsMemory(CS1B)) - Result = ModRefInfo(Result & MRI_Ref); + Result = ModRefInfo(Result & MRI_MustRef); else if (doesNotReadMemory(CS1B)) - Result = ModRefInfo(Result & MRI_Mod); + Result = ModRefInfo(Result & MRI_MustMod); // If CS2 only access memory through arguments, accumulate the mod/ref // information from CS1's references to the memory referenced by @@ -251,6 +258,7 @@ if (doesAccessArgPointees(CS2B)) { for (auto I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) { const Value *Arg = *I; + // FIXME: Set MRI_Must for non-pointer types? if (!Arg->getType()->isPointerTy()) continue; unsigned CS2ArgIdx = std::distance(CS2.arg_begin(), I); @@ -259,10 +267,10 @@ // ArgMask indicates what CS2 might do to CS2ArgLoc, and the dependence // of CS1 on that location is the inverse. ModRefInfo ArgMask = getArgModRefInfo(CS2, CS2ArgIdx); - if (ArgMask == MRI_Mod) - ArgMask = MRI_ModRef; - else if (ArgMask == MRI_Ref) - ArgMask = MRI_Mod; + if (ArgMask & MRI_Mod) + ArgMask = ModRefInfo(MRI_ModRef | (ArgMask & MRI_Must)); + else if (ArgMask & MRI_Ref) + ArgMask = ModRefInfo(MRI_Mod | (ArgMask & MRI_Must)); ArgMask = ModRefInfo(ArgMask & getModRefInfo(CS1, CS2ArgLoc)); @@ -347,9 +355,13 @@ // If the load address doesn't alias the given address, it doesn't read // or write the specified memory. - if (Loc.Ptr && !alias(MemoryLocation::get(L), Loc)) - return MRI_NoModRef; - + if (Loc.Ptr) { + AliasResult AR = alias(MemoryLocation::get(L), Loc); + if (AR == NoAlias) + return MRI_NoModRef; + if (AR == MustAlias) + return MRI_MustRef; + } // Otherwise, a load just reads. return MRI_Ref; } @@ -361,15 +373,20 @@ return MRI_ModRef; if (Loc.Ptr) { + AliasResult AR = alias(MemoryLocation::get(S), Loc); // If the store address cannot alias the pointer in question, then the // specified memory cannot be modified by the store. - if (!alias(MemoryLocation::get(S), Loc)) + if (AR == NoAlias) return MRI_NoModRef; // If the pointer is a pointer to constant memory, then it could not have // been modified by this store. if (pointsToConstantMemory(Loc)) return MRI_NoModRef; + + // If the store address aliases the pointer as must alias, set MRI_Must + if (AR == MustAlias) + return MRI_MustMod; } // Otherwise, a store just writes. @@ -387,15 +404,20 @@ ModRefInfo AAResults::getModRefInfo(const VAArgInst *V, const MemoryLocation &Loc) { if (Loc.Ptr) { + AliasResult AR = alias(MemoryLocation::get(V), Loc); // If the va_arg address cannot alias the pointer in question, then the // specified memory cannot be accessed by the va_arg. - if (!alias(MemoryLocation::get(V), Loc)) + if (AR == NoAlias) return MRI_NoModRef; // If the pointer is a pointer to constant memory, then it could not have // been modified by this va_arg. if (pointsToConstantMemory(Loc)) return MRI_NoModRef; + + // If the va_arg aliases the pointer as must alias, set MRI_Must + if (AR == MustAlias) + return MRI_MustModRef; } // Otherwise, a va_arg reads and writes. @@ -434,9 +456,17 @@ if (isStrongerThanMonotonic(CX->getSuccessOrdering())) return MRI_ModRef; - // If the cmpxchg address does not alias the location, it does not access it. - if (Loc.Ptr && !alias(MemoryLocation::get(CX), Loc)) - return MRI_NoModRef; + if (Loc.Ptr) { + AliasResult AR = alias(MemoryLocation::get(CX), Loc); + // If the cmpxchg address does not alias the location, it does not access + // it. + if (AR == NoAlias) + return MRI_NoModRef; + + // If the cmpxchg address aliases the pointer as must alias, set MRI_Must + if (AR == MustAlias) + return MRI_MustModRef; + } return MRI_ModRef; } @@ -447,9 +477,17 @@ if (isStrongerThanMonotonic(RMW->getOrdering())) return MRI_ModRef; - // If the atomicrmw address does not alias the location, it does not access it. - if (Loc.Ptr && !alias(MemoryLocation::get(RMW), Loc)) - return MRI_NoModRef; + if (Loc.Ptr) { + AliasResult AR = alias(MemoryLocation::get(RMW), Loc); + // If the atomicrmw address does not alias the location, it does not access + // it. + if (AR == NoAlias) + return MRI_NoModRef; + + // If the atomicrmw address aliases the pointer as must alias, set MRI_Must + if (AR == MustAlias) + return MRI_MustModRef; + } return MRI_ModRef; } @@ -487,6 +525,9 @@ unsigned ArgNo = 0; ModRefInfo R = MRI_NoModRef; + ModRefInfo M = MRI_Must; + // FIXME: MRI_Must info is incomplete due to early return. + // Set flag only if no May found and all operands processed. for (auto CI = CS.data_operands_begin(), CE = CS.data_operands_end(); CI != CE; ++CI, ++ArgNo) { // Only look at the no-capture or byval pointer arguments. If this @@ -497,12 +538,15 @@ ArgNo < CS.getNumArgOperands() && !CS.isByValArgument(ArgNo))) continue; + AliasResult AR = alias(MemoryLocation(*CI), MemoryLocation(Object)); // If this is a no-capture pointer argument, see if we can tell that it // is impossible to alias the pointer we're checking. If not, we have to // assume that the call could touch the pointer, even though it doesn't // escape. - if (isNoAlias(MemoryLocation(*CI), MemoryLocation(Object))) + if (AR == NoAlias) continue; + if (AR == MayAlias) + M = MRI_NoModRef; if (CS.doesNotAccessMemory(ArgNo)) continue; if (CS.onlyReadsMemory(ArgNo)) { @@ -511,7 +555,7 @@ } return MRI_ModRef; } - return R; + return ModRefInfo(R | M); } /// canBasicBlockModify - Return true if it is possible for execution of the Index: lib/Analysis/AliasAnalysisEvaluator.cpp =================================================================== --- lib/Analysis/AliasAnalysisEvaluator.cpp +++ lib/Analysis/AliasAnalysisEvaluator.cpp @@ -245,19 +245,23 @@ switch (AA.getModRefInfo(C, Pointer, Size)) { case MRI_NoModRef: + case MRI_Must: PrintModRefResults("NoModRef", PrintNoModRef, I, Pointer, F.getParent()); ++NoModRefCount; break; case MRI_Mod: + case MRI_MustMod: PrintModRefResults("Just Mod", PrintMod, I, Pointer, F.getParent()); ++ModCount; break; case MRI_Ref: + case MRI_MustRef: PrintModRefResults("Just Ref", PrintRef, I, Pointer, F.getParent()); ++RefCount; break; case MRI_ModRef: + case MRI_MustModRef: PrintModRefResults("Both ModRef", PrintModRef, I, Pointer, F.getParent()); ++ModRefCount; @@ -273,18 +277,22 @@ continue; switch (AA.getModRefInfo(*C, *D)) { case MRI_NoModRef: + case MRI_Must: PrintModRefResults("NoModRef", PrintNoModRef, *C, *D, F.getParent()); ++NoModRefCount; break; case MRI_Mod: + case MRI_MustMod: PrintModRefResults("Just Mod", PrintMod, *C, *D, F.getParent()); ++ModCount; break; case MRI_Ref: + case MRI_MustRef: PrintModRefResults("Just Ref", PrintRef, *C, *D, F.getParent()); ++RefCount; break; case MRI_ModRef: + case MRI_MustModRef: PrintModRefResults("Both ModRef", PrintModRef, *C, *D, F.getParent()); ++ModRefCount; break; Index: lib/Analysis/AliasSetTracker.cpp =================================================================== --- lib/Analysis/AliasSetTracker.cpp +++ lib/Analysis/AliasSetTracker.cpp @@ -211,8 +211,8 @@ if (!UnknownInsts.empty()) { for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) if (auto *Inst = getUnknownInst(i)) - if (AA.getModRefInfo(Inst, MemoryLocation(Ptr, Size, AAInfo)) != - MRI_NoModRef) + if (AA.getModRefInfo(Inst, MemoryLocation(Ptr, Size, AAInfo)) & + MRI_ModRef) return true; } @@ -231,15 +231,16 @@ for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) { if (auto *UnknownInst = getUnknownInst(i)) { ImmutableCallSite C1(UnknownInst), C2(Inst); - if (!C1 || !C2 || AA.getModRefInfo(C1, C2) != MRI_NoModRef || - AA.getModRefInfo(C2, C1) != MRI_NoModRef) + if (!C1 || !C2 || AA.getModRefInfo(C1, C2) & MRI_ModRef || + AA.getModRefInfo(C2, C1) & MRI_ModRef) return true; } } for (iterator I = begin(), E = end(); I != E; ++I) - if (AA.getModRefInfo(Inst, MemoryLocation(I.getPointer(), I.getSize(), - I.getAAInfo())) != MRI_NoModRef) + if (AA.getModRefInfo( + Inst, MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo())) & + MRI_ModRef) return true; return false; Index: lib/Analysis/BasicAliasAnalysis.cpp =================================================================== --- lib/Analysis/BasicAliasAnalysis.cpp +++ lib/Analysis/BasicAliasAnalysis.cpp @@ -777,6 +777,7 @@ // Optimistically assume that call doesn't touch Object and check this // assumption in the following loop. ModRefInfo Result = MRI_NoModRef; + ModRefInfo MustResult = MRI_Must; unsigned OperandNo = 0; for (auto CI = CS.data_operands_begin(), CE = CS.data_operands_end(); @@ -802,6 +803,8 @@ // Operand doesnt alias 'Object', continue looking for other aliases if (AR == NoAlias) continue; + if (AR == MayAlias) + MustResult = MRI_NoModRef; // Operand aliases 'Object', but call doesn't modify it. Strengthen // initial assumption and keep looking in case if there are more aliases. if (CS.onlyReadsMemory(OperandNo)) { @@ -818,9 +821,14 @@ break; } + // No operand aliases, reset Must bit. Add below if at least one aliases + // and all aliases found are MustAlias. + if (Result == MRI_NoModRef) + MustResult = MRI_NoModRef; + // Early return if we improved mod ref information if (Result != MRI_ModRef) - return Result; + return ModRefInfo(Result | MustResult); } // If the CallSite is to malloc or calloc, we can assume that it doesn't @@ -847,11 +855,11 @@ if ((SrcAA = getBestAAResults().alias(MemoryLocation::getForSource(Inst), Loc)) == MustAlias) // Loc is exactly the memcpy source thus disjoint from memcpy dest. - return MRI_Ref; + return MRI_MustRef; if ((DestAA = getBestAAResults().alias(MemoryLocation::getForDest(Inst), Loc)) == MustAlias) // The converse case. - return MRI_Mod; + return MRI_MustMod; // It's also possible for Loc to alias both src and dest, or neither. ModRefInfo rv = MRI_NoModRef; Index: lib/Analysis/GlobalsModRef.cpp =================================================================== --- lib/Analysis/GlobalsModRef.cpp +++ lib/Analysis/GlobalsModRef.cpp @@ -84,6 +84,9 @@ /// The bit that flags that this function may read any global. This is /// chosen to mix together with ModRefInfo bits. + /// FIXME: Overlaps with MRI_Must bit! + /// FunctionInfo.getModRefInfo() masks out everything except MRI_ModRef so + /// this remains correct, but the MRI_Must info is lost. enum { MayReadAnyGlobal = 4 }; /// Checks to document the invariants of the bit packing here. @@ -230,7 +233,7 @@ FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior; if (FunctionInfo *FI = getFunctionInfo(F)) { - if (FI->getModRefInfo() == MRI_NoModRef) + if ((FI->getModRefInfo() & MRI_ModRef) == MRI_NoModRef) Min = FMRB_DoesNotAccessMemory; else if ((FI->getModRefInfo() & MRI_Mod) == 0) Min = FMRB_OnlyReadsMemory; @@ -246,7 +249,7 @@ if (!CS.hasOperandBundles()) if (const Function *F = CS.getCalledFunction()) if (FunctionInfo *FI = getFunctionInfo(F)) { - if (FI->getModRefInfo() == MRI_NoModRef) + if ((FI->getModRefInfo() & MRI_ModRef) == MRI_NoModRef) Min = FMRB_DoesNotAccessMemory; else if ((FI->getModRefInfo() & MRI_Mod) == 0) Min = FMRB_OnlyReadsMemory; @@ -586,7 +589,7 @@ if ((FI.getModRefInfo() & MRI_Mod) == 0) ++NumReadMemFunctions; - if (FI.getModRefInfo() == MRI_NoModRef) + if ((FI.getModRefInfo() & MRI_ModRef) == MRI_NoModRef) ++NumNoMemFunctions; // Finally, now that we know the full effect on this SCC, clone the @@ -907,7 +910,7 @@ Known = FI->getModRefInfoForGlobal(*GV) | getModRefInfoForArgument(CS, GV); - if (Known == MRI_NoModRef) + if ((Known & MRI_ModRef) == MRI_NoModRef) return MRI_NoModRef; // No need to query other mod/ref analyses return ModRefInfo(Known & AAResultBase::getModRefInfo(CS, Loc)); } Index: lib/Analysis/MemoryDependenceAnalysis.cpp =================================================================== --- lib/Analysis/MemoryDependenceAnalysis.cpp +++ lib/Analysis/MemoryDependenceAnalysis.cpp @@ -209,7 +209,7 @@ ModRefInfo MR = GetLocation(Inst, Loc, TLI); if (Loc.Ptr) { // A simple instruction. - if (AA.getModRefInfo(CS, Loc) != MRI_NoModRef) + if (AA.getModRefInfo(CS, Loc) & MRI_ModRef) return MemDepResult::getClobber(Inst); continue; } @@ -221,6 +221,7 @@ // If these two calls do not interfere, look past it. switch (AA.getModRefInfo(CS, InstCS)) { case MRI_NoModRef: + case MRI_Must: // If the two calls are the same, return InstCS as a Def, so that // CS can be found redundant and eliminated. if (isReadOnlyCall && !(MR & MRI_Mod) && @@ -237,7 +238,7 @@ // If we could not obtain a pointer for the instruction and the instruction // touches memory then assume that this is a dependency. - if (MR != MRI_NoModRef) + if (MR & MRI_ModRef) return MemDepResult::getClobber(Inst); } @@ -642,11 +643,12 @@ // If alias analysis can tell that this store is guaranteed to not modify // the query pointer, ignore it. Use getModRefInfo to handle cases where // the query pointer points to constant memory etc. - if (AA.getModRefInfo(SI, MemLoc) == MRI_NoModRef) + if ((AA.getModRefInfo(SI, MemLoc) & MRI_ModRef) == MRI_NoModRef) continue; // Ok, this store might clobber the query pointer. Check to see if it is // a must alias: in this case, we want to return this as a def. + // FIXME: Use MRI_Must bit from getModRefInfo call above. MemoryLocation StoreLoc = MemoryLocation::get(SI); // If we found a pointer, check if it could be the same as our pointer. @@ -688,15 +690,19 @@ // See if this instruction (e.g. a call or vaarg) mod/ref's the pointer. ModRefInfo MR = AA.getModRefInfo(Inst, MemLoc); // If necessary, perform additional analysis. - if (MR == MRI_ModRef) - MR = AA.callCapturesBefore(Inst, MemLoc, &DT, &OBB); + if ((MR & MRI_ModRef) == MRI_ModRef) + MR = ModRefInfo(AA.callCapturesBefore(Inst, MemLoc, &DT, &OBB) | + (MR & MRI_Must)); switch (MR) { case MRI_NoModRef: + case MRI_Must: // If the call has no effect on the queried pointer, just ignore it. continue; case MRI_Mod: + case MRI_MustMod: return MemDepResult::getClobber(Inst); case MRI_Ref: + case MRI_MustRef: // If the call is known to never store to the pointer, and if this is a // load query, we can safely ignore it (scan past it). if (isLoad) Index: lib/Analysis/MemorySSA.cpp =================================================================== --- lib/Analysis/MemorySSA.cpp +++ lib/Analysis/MemorySSA.cpp @@ -262,7 +262,7 @@ if (UseCS) { ModRefInfo I = AA.getModRefInfo(DefInst, UseCS); - return I != MRI_NoModRef; + return I & MRI_ModRef; } if (auto *DefLoad = dyn_cast(DefInst)) { Index: lib/Transforms/Scalar/DeadStoreElimination.cpp =================================================================== --- lib/Transforms/Scalar/DeadStoreElimination.cpp +++ lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -802,7 +802,7 @@ // See if the call site touches the value. ModRefInfo A = AA->getModRefInfo(CS, I, getPointerSize(I, DL, *TLI)); - return A == MRI_ModRef || A == MRI_Ref; + return A & MRI_Ref; }); // If all of the allocas were clobbered by the call then we're not going Index: lib/Transforms/Scalar/MemCpyOptimizer.cpp =================================================================== --- lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -511,7 +511,7 @@ const LoadInst *LI) { // If the store alias this position, early bail out. MemoryLocation StoreLoc = MemoryLocation::get(SI); - if (AA.getModRefInfo(P, StoreLoc) != MRI_NoModRef) + if (AA.getModRefInfo(P, StoreLoc) & MRI_ModRef) return false; // Keep track of the arguments of all instruction we plan to lift @@ -535,20 +535,20 @@ for (auto I = --SI->getIterator(), E = P->getIterator(); I != E; --I) { auto *C = &*I; - bool MayAlias = AA.getModRefInfo(C, None) != MRI_NoModRef; + bool MayAlias = AA.getModRefInfo(C, None) & MRI_ModRef; bool NeedLift = false; if (Args.erase(C)) NeedLift = true; else if (MayAlias) { NeedLift = llvm::any_of(MemLocs, [C, &AA](const MemoryLocation &ML) { - return AA.getModRefInfo(C, ML); + return AA.getModRefInfo(C, ML) & MRI_ModRef; }); if (!NeedLift) NeedLift = llvm::any_of(CallSites, [C, &AA](const ImmutableCallSite &CS) { - return AA.getModRefInfo(C, CS); + return AA.getModRefInfo(C, CS) & MRI_ModRef; }); } @@ -562,14 +562,14 @@ return false; else if (auto CS = ImmutableCallSite(C)) { // If we can't lift this before P, it's game over. - if (AA.getModRefInfo(P, CS) != MRI_NoModRef) + if (AA.getModRefInfo(P, CS) & MRI_ModRef) return false; CallSites.push_back(CS); } else if (isa(C) || isa(C) || isa(C)) { // If we can't lift this before P, it's game over. auto ML = MemoryLocation::get(C); - if (AA.getModRefInfo(P, ML) != MRI_NoModRef) + if (AA.getModRefInfo(P, ML) & MRI_ModRef) return false; MemLocs.push_back(ML); @@ -695,7 +695,7 @@ MemoryLocation StoreLoc = MemoryLocation::get(SI); for (BasicBlock::iterator I = --SI->getIterator(), E = C->getIterator(); I != E; --I) { - if (AA.getModRefInfo(&*I, StoreLoc) != MRI_NoModRef) { + if (AA.getModRefInfo(&*I, StoreLoc) & MRI_ModRef) { C = nullptr; break; } @@ -927,9 +927,9 @@ AliasAnalysis &AA = LookupAliasAnalysis(); ModRefInfo MR = AA.getModRefInfo(C, cpyDest, srcSize); // If necessary, perform additional analysis. - if (MR != MRI_NoModRef) + if (MR & MRI_ModRef) MR = AA.callCapturesBefore(C, cpyDest, srcSize, &DT); - if (MR != MRI_NoModRef) + if (MR & MRI_ModRef) return false; // We can't create address space casts here because we don't know if they're