diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2015-07-22 23:15:57 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2015-07-22 23:15:57 +0000 |
commit | 194f59ca5d2f48f1e0b7fa95971ae9f88e95ba95 (patch) | |
tree | 67fa8610cb1dccceeb055c823d16d438fed256d5 /llvm/lib | |
parent | 16fe4d178e9d81b07e8deb59a4b4292850364898 (diff) | |
download | bcm5719-llvm-194f59ca5d2f48f1e0b7fa95971ae9f88e95ba95.tar.gz bcm5719-llvm-194f59ca5d2f48f1e0b7fa95971ae9f88e95ba95.zip |
[PM/AA] Extract the ModRef enums from the AliasAnalysis class in
preparation for de-coupling the AA implementations.
In order to do this, they had to become fake-scoped using the
traditional LLVM pattern of a leading initialism. These can't be actual
scoped enumerations because they're bitfields and thus inherently we use
them as integers.
I've also renamed the behavior enums that are specific to reasoning
about the mod/ref behavior of functions when called. This makes it more
clear that they have a very narrow domain of applicability.
I think there is a significantly cleaner API for all of this, but
I don't want to try to do really substantive changes for now, I just
want to refactor the things away from analysis groups so I'm preserving
the exact original design and just cleaning up the names, style, and
lifting out of the class.
Differential Revision: http://reviews.llvm.org/D10564
llvm-svn: 242963
Diffstat (limited to 'llvm/lib')
27 files changed, 365 insertions, 370 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index f10468d2ebb..22ef7739a2d 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -60,14 +60,14 @@ bool AliasAnalysis::pointsToConstantMemory(const MemoryLocation &Loc, return AA->pointsToConstantMemory(Loc, OrLocal); } -AliasAnalysis::ModRefResult -AliasAnalysis::getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx) { +ModRefInfo AliasAnalysis::getArgModRefInfo(ImmutableCallSite CS, + unsigned ArgIdx) { assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); return AA->getArgModRefInfo(CS, ArgIdx); } -AliasAnalysis::ModRefResult -AliasAnalysis::getModRefInfo(Instruction *I, ImmutableCallSite Call) { +ModRefInfo AliasAnalysis::getModRefInfo(Instruction *I, + ImmutableCallSite Call) { // We may have two calls if (auto CS = ImmutableCallSite(I)) { // Check if the two calls modify the same memory @@ -78,27 +78,27 @@ AliasAnalysis::getModRefInfo(Instruction *I, ImmutableCallSite Call) { // 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) != AliasAnalysis::NoModRef) - return AliasAnalysis::ModRef; + if (getModRefInfo(Call, DefLoc) != MRI_NoModRef) + return MRI_ModRef; } - return AliasAnalysis::NoModRef; + return MRI_NoModRef; } -AliasAnalysis::ModRefResult -AliasAnalysis::getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc) { +ModRefInfo AliasAnalysis::getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) { assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); - ModRefBehavior MRB = getModRefBehavior(CS); - if (MRB == DoesNotAccessMemory) - return NoModRef; + auto MRB = getModRefBehavior(CS); + if (MRB == FMRB_DoesNotAccessMemory) + return MRI_NoModRef; - ModRefResult Mask = ModRef; + ModRefInfo Mask = MRI_ModRef; if (onlyReadsMemory(MRB)) - Mask = Ref; + Mask = MRI_Ref; if (onlyAccessesArgPointees(MRB)) { bool doesAlias = false; - ModRefResult AllArgsMask = NoModRef; + ModRefInfo AllArgsMask = MRI_NoModRef; if (doesAccessArgPointees(MRB)) { for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end(); AI != AE; ++AI) { @@ -109,57 +109,59 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc) { MemoryLocation ArgLoc = MemoryLocation::getForArgument(CS, ArgIdx, *TLI); if (!isNoAlias(ArgLoc, Loc)) { - ModRefResult ArgMask = getArgModRefInfo(CS, ArgIdx); + ModRefInfo ArgMask = getArgModRefInfo(CS, ArgIdx); doesAlias = true; - AllArgsMask = ModRefResult(AllArgsMask | ArgMask); + AllArgsMask = ModRefInfo(AllArgsMask | ArgMask); } } } if (!doesAlias) - return NoModRef; - Mask = ModRefResult(Mask & AllArgsMask); + return MRI_NoModRef; + Mask = ModRefInfo(Mask & AllArgsMask); } // If Loc is a constant memory location, the call definitely could not // modify the memory location. - if ((Mask & Mod) && pointsToConstantMemory(Loc)) - Mask = ModRefResult(Mask & ~Mod); + if ((Mask & MRI_Mod) && pointsToConstantMemory(Loc)) + Mask = ModRefInfo(Mask & ~MRI_Mod); // If this is the end of the chain, don't forward. if (!AA) return Mask; // Otherwise, fall back to the next AA in the chain. But we can merge // in any mask we've managed to compute. - return ModRefResult(AA->getModRefInfo(CS, Loc) & Mask); + return ModRefInfo(AA->getModRefInfo(CS, Loc) & Mask); } -AliasAnalysis::ModRefResult -AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) { +ModRefInfo AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) { assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); // If CS1 or CS2 are readnone, they don't interact. - ModRefBehavior CS1B = getModRefBehavior(CS1); - if (CS1B == DoesNotAccessMemory) return NoModRef; + auto CS1B = getModRefBehavior(CS1); + if (CS1B == FMRB_DoesNotAccessMemory) + return MRI_NoModRef; - ModRefBehavior CS2B = getModRefBehavior(CS2); - if (CS2B == DoesNotAccessMemory) return NoModRef; + auto CS2B = getModRefBehavior(CS2); + if (CS2B == FMRB_DoesNotAccessMemory) + return MRI_NoModRef; // If they both only read from memory, there is no dependence. if (onlyReadsMemory(CS1B) && onlyReadsMemory(CS2B)) - return NoModRef; + return MRI_NoModRef; - AliasAnalysis::ModRefResult Mask = ModRef; + ModRefInfo Mask = MRI_ModRef; // If CS1 only reads memory, the only dependence on CS2 can be // from CS1 reading memory written by CS2. if (onlyReadsMemory(CS1B)) - Mask = ModRefResult(Mask & Ref); + Mask = ModRefInfo(Mask & MRI_Ref); // If CS2 only access memory through arguments, accumulate the mod/ref // information from CS1's references to the memory referenced by // CS2's arguments. if (onlyAccessesArgPointees(CS2B)) { - AliasAnalysis::ModRefResult R = NoModRef; + ModRefInfo R = MRI_NoModRef; if (doesAccessArgPointees(CS2B)) { for (ImmutableCallSite::arg_iterator I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) { @@ -171,13 +173,13 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) { // ArgMask indicates what CS2 might do to CS2ArgLoc, and the dependence of // CS1 on that location is the inverse. - ModRefResult ArgMask = getArgModRefInfo(CS2, CS2ArgIdx); - if (ArgMask == Mod) - ArgMask = ModRef; - else if (ArgMask == Ref) - ArgMask = Mod; + ModRefInfo ArgMask = getArgModRefInfo(CS2, CS2ArgIdx); + if (ArgMask == MRI_Mod) + ArgMask = MRI_ModRef; + else if (ArgMask == MRI_Ref) + ArgMask = MRI_Mod; - R = ModRefResult((R | (getModRefInfo(CS1, CS2ArgLoc) & ArgMask)) & Mask); + R = ModRefInfo((R | (getModRefInfo(CS1, CS2ArgLoc) & ArgMask)) & Mask); if (R == Mask) break; } @@ -188,7 +190,7 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) { // If CS1 only accesses memory through arguments, check if CS2 references // any of the memory referenced by CS1's arguments. If not, return NoModRef. if (onlyAccessesArgPointees(CS1B)) { - AliasAnalysis::ModRefResult R = NoModRef; + ModRefInfo R = MRI_NoModRef; if (doesAccessArgPointees(CS1B)) { for (ImmutableCallSite::arg_iterator I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I) { @@ -201,11 +203,13 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) { // ArgMask indicates what CS1 might do to CS1ArgLoc; if CS1 might Mod // CS1ArgLoc, then we care about either a Mod or a Ref by CS2. If CS1 // might Ref, then we care only about a Mod by CS2. - ModRefResult ArgMask = getArgModRefInfo(CS1, CS1ArgIdx); - ModRefResult ArgR = getModRefInfo(CS2, CS1ArgLoc); - if (((ArgMask & Mod) != NoModRef && (ArgR & ModRef) != NoModRef) || - ((ArgMask & Ref) != NoModRef && (ArgR & Mod) != NoModRef)) - R = ModRefResult((R | ArgMask) & Mask); + ModRefInfo ArgMask = getArgModRefInfo(CS1, CS1ArgIdx); + ModRefInfo ArgR = getModRefInfo(CS2, CS1ArgLoc); + if (((ArgMask & MRI_Mod) != MRI_NoModRef && + (ArgR & MRI_ModRef) != MRI_NoModRef) || + ((ArgMask & MRI_Ref) != MRI_NoModRef && + (ArgR & MRI_Mod) != MRI_NoModRef)) + R = ModRefInfo((R | ArgMask) & Mask); if (R == Mask) break; @@ -219,14 +223,13 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) { // Otherwise, fall back to the next AA in the chain. But we can merge // in any mask we've managed to compute. - return ModRefResult(AA->getModRefInfo(CS1, CS2) & Mask); + return ModRefInfo(AA->getModRefInfo(CS1, CS2) & Mask); } -AliasAnalysis::ModRefBehavior -AliasAnalysis::getModRefBehavior(ImmutableCallSite CS) { +FunctionModRefBehavior AliasAnalysis::getModRefBehavior(ImmutableCallSite CS) { assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); - ModRefBehavior Min = UnknownModRefBehavior; + auto Min = FMRB_UnknownModRefBehavior; // Call back into the alias analysis with the other form of getModRefBehavior // to see if it can give a better response. @@ -238,11 +241,10 @@ AliasAnalysis::getModRefBehavior(ImmutableCallSite CS) { // Otherwise, fall back to the next AA in the chain. But we can merge // in any result we've managed to compute. - return ModRefBehavior(AA->getModRefBehavior(CS) & Min); + return FunctionModRefBehavior(AA->getModRefBehavior(CS) & Min); } -AliasAnalysis::ModRefBehavior -AliasAnalysis::getModRefBehavior(const Function *F) { +FunctionModRefBehavior AliasAnalysis::getModRefBehavior(const Function *F) { assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); return AA->getModRefBehavior(F); } @@ -251,116 +253,114 @@ AliasAnalysis::getModRefBehavior(const Function *F) { // AliasAnalysis non-virtual helper method implementation //===----------------------------------------------------------------------===// -AliasAnalysis::ModRefResult -AliasAnalysis::getModRefInfo(const LoadInst *L, const MemoryLocation &Loc) { +ModRefInfo AliasAnalysis::getModRefInfo(const LoadInst *L, + const MemoryLocation &Loc) { // Be conservative in the face of volatile/atomic. if (!L->isUnordered()) - return ModRef; + return MRI_ModRef; // 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 NoModRef; + return MRI_NoModRef; // Otherwise, a load just reads. - return Ref; + return MRI_Ref; } -AliasAnalysis::ModRefResult -AliasAnalysis::getModRefInfo(const StoreInst *S, const MemoryLocation &Loc) { +ModRefInfo AliasAnalysis::getModRefInfo(const StoreInst *S, + const MemoryLocation &Loc) { // Be conservative in the face of volatile/atomic. if (!S->isUnordered()) - return ModRef; + return MRI_ModRef; if (Loc.Ptr) { // 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)) - return NoModRef; + 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 NoModRef; - + return MRI_NoModRef; } // Otherwise, a store just writes. - return Mod; + return MRI_Mod; } -AliasAnalysis::ModRefResult -AliasAnalysis::getModRefInfo(const VAArgInst *V, const MemoryLocation &Loc) { +ModRefInfo AliasAnalysis::getModRefInfo(const VAArgInst *V, + const MemoryLocation &Loc) { if (Loc.Ptr) { // 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)) - return NoModRef; + 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 NoModRef; + return MRI_NoModRef; } // Otherwise, a va_arg reads and writes. - return ModRef; + return MRI_ModRef; } -AliasAnalysis::ModRefResult -AliasAnalysis::getModRefInfo(const AtomicCmpXchgInst *CX, - const MemoryLocation &Loc) { +ModRefInfo AliasAnalysis::getModRefInfo(const AtomicCmpXchgInst *CX, + const MemoryLocation &Loc) { // Acquire/Release cmpxchg has properties that matter for arbitrary addresses. if (CX->getSuccessOrdering() > Monotonic) - return ModRef; + 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 NoModRef; + return MRI_NoModRef; - return ModRef; + return MRI_ModRef; } -AliasAnalysis::ModRefResult -AliasAnalysis::getModRefInfo(const AtomicRMWInst *RMW, - const MemoryLocation &Loc) { +ModRefInfo AliasAnalysis::getModRefInfo(const AtomicRMWInst *RMW, + const MemoryLocation &Loc) { // Acquire/Release atomicrmw has properties that matter for arbitrary addresses. if (RMW->getOrdering() > Monotonic) - return ModRef; + 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 NoModRef; + return MRI_NoModRef; - return ModRef; + return MRI_ModRef; } // FIXME: this is really just shoring-up a deficiency in alias analysis. // BasicAA isn't willing to spend linear time determining whether an alloca // was captured before or after this particular call, while we are. However, // with a smarter AA in place, this test is just wasting compile time. -AliasAnalysis::ModRefResult AliasAnalysis::callCapturesBefore( - const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT) { +ModRefInfo AliasAnalysis::callCapturesBefore(const Instruction *I, + const MemoryLocation &MemLoc, + DominatorTree *DT) { if (!DT) - return AliasAnalysis::ModRef; + return MRI_ModRef; const Value *Object = GetUnderlyingObject(MemLoc.Ptr, *DL); if (!isIdentifiedObject(Object) || isa<GlobalValue>(Object) || isa<Constant>(Object)) - return AliasAnalysis::ModRef; + return MRI_ModRef; ImmutableCallSite CS(I); if (!CS.getInstruction() || CS.getInstruction() == Object) - return AliasAnalysis::ModRef; + return MRI_ModRef; if (llvm::PointerMayBeCapturedBefore(Object, /* ReturnCaptures */ true, /* StoreCaptures */ true, I, DT, /* include Object */ true)) - return AliasAnalysis::ModRef; + return MRI_ModRef; unsigned ArgNo = 0; - AliasAnalysis::ModRefResult R = AliasAnalysis::NoModRef; + ModRefInfo R = MRI_NoModRef; for (ImmutableCallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); CI != CE; ++CI, ++ArgNo) { // Only look at the no-capture or byval pointer arguments. If this @@ -379,10 +379,10 @@ AliasAnalysis::ModRefResult AliasAnalysis::callCapturesBefore( if (CS.doesNotAccessMemory(ArgNo)) continue; if (CS.onlyReadsMemory(ArgNo)) { - R = AliasAnalysis::Ref; + R = MRI_Ref; continue; } - return AliasAnalysis::ModRef; + return MRI_ModRef; } return R; } @@ -422,7 +422,7 @@ uint64_t AliasAnalysis::getTypeStoreSize(Type *Ty) { /// bool AliasAnalysis::canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc) { - return canInstructionRangeModRef(BB.front(), BB.back(), Loc, Mod); + return canInstructionRangeModRef(BB.front(), BB.back(), Loc, MRI_Mod); } /// canInstructionRangeModRef - Return true if it is possible for the @@ -433,7 +433,7 @@ bool AliasAnalysis::canBasicBlockModify(const BasicBlock &BB, bool AliasAnalysis::canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const MemoryLocation &Loc, - const ModRefResult Mode) { + const ModRefInfo Mode) { assert(I1.getParent() == I2.getParent() && "Instructions not in same basic block!"); BasicBlock::const_iterator I = &I1; diff --git a/llvm/lib/Analysis/AliasAnalysisCounter.cpp b/llvm/lib/Analysis/AliasAnalysisCounter.cpp index 9b6a5a44d80..6c53b41d3a1 100644 --- a/llvm/lib/Analysis/AliasAnalysisCounter.cpp +++ b/llvm/lib/Analysis/AliasAnalysisCounter.cpp @@ -62,15 +62,16 @@ namespace { << Must*100/AASum<<"%\n\n"; } - errs() << " " << MRSum << " Total Mod/Ref Queries Performed\n"; + errs() << " " << MRSum << " Total MRI_Mod/MRI_Ref Queries Performed\n"; if (MRSum) { printLine("no mod/ref", NoMR, MRSum); printLine("ref", JustRef, MRSum); printLine("mod", JustMod, MRSum); printLine("mod/ref", MR, MRSum); - errs() << " Mod/Ref Analysis Counter Summary: " <<NoMR*100/MRSum - << "%/" << JustRef*100/MRSum << "%/" << JustMod*100/MRSum - << "%/" << MR*100/MRSum <<"%\n\n"; + errs() << " MRI_Mod/MRI_Ref Analysis Counter Summary: " + << NoMR * 100 / MRSum << "%/" << JustRef * 100 / MRSum << "%/" + << JustMod * 100 / MRSum << "%/" << MR * 100 / MRSum + << "%\n\n"; } } } @@ -108,10 +109,10 @@ namespace { AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) override; - ModRefResult getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) override; - ModRefResult getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) override { + ModRefInfo getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) override { return AliasAnalysis::getModRefInfo(CS1,CS2); } }; @@ -150,20 +151,31 @@ AliasResult AliasAnalysisCounter::alias(const MemoryLocation &LocA, return R; } -AliasAnalysis::ModRefResult -AliasAnalysisCounter::getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) { - ModRefResult R = getAnalysis<AliasAnalysis>().getModRefInfo(CS, Loc); +ModRefInfo AliasAnalysisCounter::getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) { + ModRefInfo R = getAnalysis<AliasAnalysis>().getModRefInfo(CS, Loc); const char *MRString = nullptr; switch (R) { - case NoModRef: NoMR++; MRString = "NoModRef"; break; - case Ref: JustRef++; MRString = "JustRef"; break; - case Mod: JustMod++; MRString = "JustMod"; break; - case ModRef: MR++; MRString = "ModRef"; break; + case MRI_NoModRef: + NoMR++; + MRString = "MRI_NoModRef"; + break; + case MRI_Ref: + JustRef++; + MRString = "JustRef"; + break; + case MRI_Mod: + JustMod++; + MRString = "JustMod"; + break; + case MRI_ModRef: + MR++; + MRString = "MRI_ModRef"; + break; } - if (PrintAll || (PrintAllFailures && R == ModRef)) { + if (PrintAll || (PrintAllFailures && R == MRI_ModRef)) { errs() << MRString << ": Ptr: "; errs() << "[" << Loc.Size << "B] "; Loc.Ptr->printAsOperand(errs(), true, M); diff --git a/llvm/lib/Analysis/AliasAnalysisEvaluator.cpp b/llvm/lib/Analysis/AliasAnalysisEvaluator.cpp index 5d1b001fe16..7114a96c4ec 100644 --- a/llvm/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/llvm/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -292,19 +292,19 @@ bool AAEval::runOnFunction(Function &F) { if (ElTy->isSized()) Size = AA.getTypeStoreSize(ElTy); switch (AA.getModRefInfo(*C, *V, Size)) { - case AliasAnalysis::NoModRef: + case MRI_NoModRef: PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent()); ++NoModRefCount; break; - case AliasAnalysis::Mod: + case MRI_Mod: PrintModRefResults("Just Mod", PrintMod, I, *V, F.getParent()); ++ModCount; break; - case AliasAnalysis::Ref: + case MRI_Ref: PrintModRefResults("Just Ref", PrintRef, I, *V, F.getParent()); ++RefCount; break; - case AliasAnalysis::ModRef: + case MRI_ModRef: PrintModRefResults("Both ModRef", PrintModRef, I, *V, F.getParent()); ++ModRefCount; break; @@ -319,19 +319,19 @@ bool AAEval::runOnFunction(Function &F) { if (D == C) continue; switch (AA.getModRefInfo(*C, *D)) { - case AliasAnalysis::NoModRef: + case MRI_NoModRef: PrintModRefResults("NoModRef", PrintNoModRef, *C, *D, F.getParent()); ++NoModRefCount; break; - case AliasAnalysis::Mod: + case MRI_Mod: PrintModRefResults("Just Mod", PrintMod, *C, *D, F.getParent()); ++ModCount; break; - case AliasAnalysis::Ref: + case MRI_Ref: PrintModRefResults("Just Ref", PrintRef, *C, *D, F.getParent()); ++RefCount; break; - case AliasAnalysis::ModRef: + case MRI_ModRef: PrintModRefResults("Both ModRef", PrintModRef, *C, *D, F.getParent()); ++ModRefCount; break; diff --git a/llvm/lib/Analysis/AliasDebugger.cpp b/llvm/lib/Analysis/AliasDebugger.cpp index 1f331857dd1..146036b0060 100644 --- a/llvm/lib/Analysis/AliasDebugger.cpp +++ b/llvm/lib/Analysis/AliasDebugger.cpp @@ -103,14 +103,14 @@ namespace { return AliasAnalysis::alias(LocA, LocB); } - ModRefResult getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) override { + ModRefInfo getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) override { assert(Vals.find(Loc.Ptr) != Vals.end() && "Never seen value in AA before"); return AliasAnalysis::getModRefInfo(CS, Loc); } - ModRefResult getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) override { + ModRefInfo getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) override { return AliasAnalysis::getModRefInfo(CS1,CS2); } diff --git a/llvm/lib/Analysis/AliasSetTracker.cpp b/llvm/lib/Analysis/AliasSetTracker.cpp index 3369cc5bf42..05bbe9b227d 100644 --- a/llvm/lib/Analysis/AliasSetTracker.cpp +++ b/llvm/lib/Analysis/AliasSetTracker.cpp @@ -167,8 +167,7 @@ bool AliasSet::aliasesPointer(const Value *Ptr, uint64_t Size, if (!UnknownInsts.empty()) { for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) if (AA.getModRefInfo(UnknownInsts[i], - MemoryLocation(Ptr, Size, AAInfo)) != - AliasAnalysis::NoModRef) + MemoryLocation(Ptr, Size, AAInfo)) != MRI_NoModRef) return true; } @@ -182,16 +181,14 @@ bool AliasSet::aliasesUnknownInst(const Instruction *Inst, for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) { ImmutableCallSite C1(getUnknownInst(i)), C2(Inst); - if (!C1 || !C2 || - AA.getModRefInfo(C1, C2) != AliasAnalysis::NoModRef || - AA.getModRefInfo(C2, C1) != AliasAnalysis::NoModRef) + if (!C1 || !C2 || AA.getModRefInfo(C1, C2) != MRI_NoModRef || + AA.getModRefInfo(C2, C1) != MRI_NoModRef) return true; } for (iterator I = begin(), E = end(); I != E; ++I) - if (AA.getModRefInfo( - Inst, MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo())) != - AliasAnalysis::NoModRef) + if (AA.getModRefInfo(Inst, MemoryLocation(I.getPointer(), I.getSize(), + I.getAAInfo())) != MRI_NoModRef) return true; return false; diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 06e600e8835..511ea4bbfab 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -479,11 +479,11 @@ namespace { return Alias; } - ModRefResult getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) override; - ModRefResult getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) override; /// pointsToConstantMemory - Chase pointers until we find a (constant /// global) or not. @@ -491,16 +491,15 @@ namespace { bool OrLocal) override; /// Get the location associated with a pointer argument of a callsite. - ModRefResult getArgModRefInfo(ImmutableCallSite CS, - unsigned ArgIdx) override; + ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx) override; /// getModRefBehavior - Return the behavior when calling the given /// call site. - ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override; + FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override; /// getModRefBehavior - Return the behavior when calling the given function. /// For use when the call site is not known. - ModRefBehavior getModRefBehavior(const Function *F) override; + FunctionModRefBehavior getModRefBehavior(const Function *F) override; /// getAdjustedAnalysisPointer - This method is used when a pass implements /// an analysis interface through multiple inheritance. If needed, it @@ -676,33 +675,33 @@ static bool isMemsetPattern16(const Function *MS, } /// getModRefBehavior - Return the behavior when calling the given call site. -AliasAnalysis::ModRefBehavior +FunctionModRefBehavior BasicAliasAnalysis::getModRefBehavior(ImmutableCallSite CS) { if (CS.doesNotAccessMemory()) // Can't do better than this. - return DoesNotAccessMemory; + return FMRB_DoesNotAccessMemory; - ModRefBehavior Min = UnknownModRefBehavior; + FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior; // If the callsite knows it only reads memory, don't return worse // than that. if (CS.onlyReadsMemory()) - Min = OnlyReadsMemory; + Min = FMRB_OnlyReadsMemory; if (CS.onlyAccessesArgMemory()) - Min = ModRefBehavior(Min & OnlyAccessesArgumentPointees); + Min = FunctionModRefBehavior(Min & FMRB_OnlyAccessesArgumentPointees); // The AliasAnalysis base class has some smarts, lets use them. - return ModRefBehavior(AliasAnalysis::getModRefBehavior(CS) & Min); + return FunctionModRefBehavior(AliasAnalysis::getModRefBehavior(CS) & Min); } /// getModRefBehavior - Return the behavior when calling the given function. /// For use when the call site is not known. -AliasAnalysis::ModRefBehavior +FunctionModRefBehavior BasicAliasAnalysis::getModRefBehavior(const Function *F) { // If the function declares it doesn't access memory, we can't do better. if (F->doesNotAccessMemory()) - return DoesNotAccessMemory; + return FMRB_DoesNotAccessMemory; // For intrinsics, we can check the table. if (Intrinsic::ID iid = F->getIntrinsicID()) { @@ -711,26 +710,26 @@ BasicAliasAnalysis::getModRefBehavior(const Function *F) { #undef GET_INTRINSIC_MODREF_BEHAVIOR } - ModRefBehavior Min = UnknownModRefBehavior; + FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior; // If the function declares it only reads memory, go with that. if (F->onlyReadsMemory()) - Min = OnlyReadsMemory; + Min = FMRB_OnlyReadsMemory; if (F->onlyAccessesArgMemory()) - Min = ModRefBehavior(Min & OnlyAccessesArgumentPointees); + Min = FunctionModRefBehavior(Min & FMRB_OnlyAccessesArgumentPointees); const TargetLibraryInfo &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(); if (isMemsetPattern16(F, TLI)) - Min = OnlyAccessesArgumentPointees; + Min = FMRB_OnlyAccessesArgumentPointees; // Otherwise be conservative. - return ModRefBehavior(AliasAnalysis::getModRefBehavior(F) & Min); + return FunctionModRefBehavior(AliasAnalysis::getModRefBehavior(F) & Min); } -AliasAnalysis::ModRefResult -BasicAliasAnalysis::getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx) { +ModRefInfo BasicAliasAnalysis::getArgModRefInfo(ImmutableCallSite CS, + unsigned ArgIdx) { if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(CS.getInstruction())) switch (II->getIntrinsicID()) { default: @@ -740,7 +739,7 @@ BasicAliasAnalysis::getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx) { case Intrinsic::memmove: assert((ArgIdx == 0 || ArgIdx == 1) && "Invalid argument index for memory intrinsic"); - return ArgIdx ? Ref : Mod; + return ArgIdx ? MRI_Ref : MRI_Mod; } // We can bound the aliasing properties of memset_pattern16 just as we can @@ -751,7 +750,7 @@ BasicAliasAnalysis::getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx) { isMemsetPattern16(CS.getCalledFunction(), *TLI)) { assert((ArgIdx == 0 || ArgIdx == 1) && "Invalid argument index for memset_pattern16"); - return ArgIdx ? Ref : Mod; + return ArgIdx ? MRI_Ref : MRI_Mod; } // FIXME: Handle memset_pattern4 and memset_pattern8 also. @@ -775,9 +774,8 @@ bool BasicAliasAnalysis::doInitialization(Module &M) { /// specified memory object. Since we only look at local properties of this /// function, we really can't say much about this query. We do, however, use /// simple "address taken" analysis on local objects. -AliasAnalysis::ModRefResult -BasicAliasAnalysis::getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) { +ModRefInfo BasicAliasAnalysis::getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) { assert(notDifferentParent(CS.getInstruction(), Loc.Ptr) && "AliasAnalysis query involving multiple functions!"); @@ -791,7 +789,7 @@ BasicAliasAnalysis::getModRefInfo(ImmutableCallSite CS, if (isa<AllocaInst>(Object)) if (const CallInst *CI = dyn_cast<CallInst>(CS.getInstruction())) if (CI->isTailCall()) - return NoModRef; + return MRI_NoModRef; // If the pointer is to a locally allocated object that does not escape, // then the call can not mod/ref the pointer unless the call takes the pointer @@ -820,27 +818,26 @@ BasicAliasAnalysis::getModRefInfo(ImmutableCallSite CS, } if (!PassedAsArg) - return NoModRef; + return MRI_NoModRef; } // While the assume intrinsic is marked as arbitrarily writing so that // proper control dependencies will be maintained, it never aliases any // particular memory location. if (isAssumeIntrinsic(CS)) - return NoModRef; + return MRI_NoModRef; // The AliasAnalysis base class has some smarts, lets use them. return AliasAnalysis::getModRefInfo(CS, Loc); } -AliasAnalysis::ModRefResult -BasicAliasAnalysis::getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) { +ModRefInfo BasicAliasAnalysis::getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) { // While the assume intrinsic is marked as arbitrarily writing so that // proper control dependencies will be maintained, it never aliases any // particular memory location. if (isAssumeIntrinsic(CS1) || isAssumeIntrinsic(CS2)) - return NoModRef; + return MRI_NoModRef; // The AliasAnalysis base class has some smarts, lets use them. return AliasAnalysis::getModRefInfo(CS1, CS2); diff --git a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp b/llvm/lib/Analysis/IPA/GlobalsModRef.cpp index 3e4b00e6e50..1accb4647e7 100644 --- a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/llvm/lib/Analysis/IPA/GlobalsModRef.cpp @@ -71,7 +71,7 @@ struct FunctionRecord { bool MayReadAnyGlobal; unsigned getInfoForGlobal(const GlobalValue *GV) const { - unsigned Effect = MayReadAnyGlobal ? AliasAnalysis::Ref : 0; + unsigned Effect = MayReadAnyGlobal ? MRI_Ref : 0; std::map<const GlobalValue *, unsigned>::const_iterator I = GlobalInfo.find(GV); if (I != GlobalInfo.end()) @@ -168,59 +168,59 @@ public: AU.setPreservesAll(); // Does not transform code } + /// getAdjustedAnalysisPointer - This method is used when a pass implements + /// an analysis interface through multiple inheritance. If needed, it + /// should override this to adjust the this pointer as needed for the + /// specified pass info. + void *getAdjustedAnalysisPointer(AnalysisID PI) override { + if (PI == &AliasAnalysis::ID) + return (AliasAnalysis *)this; + return this; + } + //------------------------------------------------ // Implement the AliasAnalysis API // AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) override; - ModRefResult getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) override; - ModRefResult getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) override { + ModRefInfo getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) override { return AliasAnalysis::getModRefInfo(CS1, CS2); } /// getModRefBehavior - Return the behavior of the specified function if /// called from the specified call site. The call site may be null in which /// case the most generic behavior of this function should be returned. - ModRefBehavior getModRefBehavior(const Function *F) override { - ModRefBehavior Min = UnknownModRefBehavior; + FunctionModRefBehavior getModRefBehavior(const Function *F) override { + FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior; if (FunctionRecord *FR = getFunctionInfo(F)) { if (FR->FunctionEffect == 0) - Min = DoesNotAccessMemory; - else if ((FR->FunctionEffect & Mod) == 0) - Min = OnlyReadsMemory; + Min = FMRB_DoesNotAccessMemory; + else if ((FR->FunctionEffect & MRI_Mod) == 0) + Min = FMRB_OnlyReadsMemory; } - return ModRefBehavior(AliasAnalysis::getModRefBehavior(F) & Min); + return FunctionModRefBehavior(AliasAnalysis::getModRefBehavior(F) & Min); } /// getModRefBehavior - Return the behavior of the specified function if /// called from the specified call site. The call site may be null in which /// case the most generic behavior of this function should be returned. - ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override { - ModRefBehavior Min = UnknownModRefBehavior; + FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override { + FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior; if (const Function *F = CS.getCalledFunction()) if (FunctionRecord *FR = getFunctionInfo(F)) { if (FR->FunctionEffect == 0) - Min = DoesNotAccessMemory; - else if ((FR->FunctionEffect & Mod) == 0) - Min = OnlyReadsMemory; + Min = FMRB_DoesNotAccessMemory; + else if ((FR->FunctionEffect & MRI_Mod) == 0) + Min = FMRB_OnlyReadsMemory; } - return ModRefBehavior(AliasAnalysis::getModRefBehavior(CS) & Min); - } - - /// getAdjustedAnalysisPointer - This method is used when a pass implements - /// an analysis interface through multiple inheritance. If needed, it - /// should override this to adjust the this pointer as needed for the - /// specified pass info. - void *getAdjustedAnalysisPointer(AnalysisID PI) override { - if (PI == &AliasAnalysis::ID) - return (AliasAnalysis *)this; - return this; + return FunctionModRefBehavior(AliasAnalysis::getModRefBehavior(CS) & Min); } private: @@ -280,11 +280,11 @@ void GlobalsModRef::AnalyzeGlobals(Module &M) { Handles.front().I = Handles.begin(); for (Function *Reader : Readers) - FunctionInfo[Reader].GlobalInfo[&GV] |= Ref; + FunctionInfo[Reader].GlobalInfo[&GV] |= MRI_Ref; if (!GV.isConstant()) // No need to keep track of writers to constants for (Function *Writer : Writers) - FunctionInfo[Writer].GlobalInfo[&GV] |= Mod; + FunctionInfo[Writer].GlobalInfo[&GV] |= MRI_Mod; ++NumNonAddrTakenGlobalVars; // If this global holds a pointer type, see if it is an indirect global. @@ -455,13 +455,13 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { if (F->doesNotAccessMemory()) { // Can't do better than that! } else if (F->onlyReadsMemory()) { - FunctionEffect |= Ref; + FunctionEffect |= MRI_Ref; if (!F->isIntrinsic()) // This function might call back into the module and read a global - // consider every global as possibly being read by this function. FR.MayReadAnyGlobal = true; } else { - FunctionEffect |= ModRef; + FunctionEffect |= MRI_ModRef; // Can't say anything useful unless it's an intrinsic - they don't // read or write global variables of the kind considered here. KnowNothing = !F->isIntrinsic(); @@ -502,10 +502,10 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { // Scan the function bodies for explicit loads or stores. for (auto *Node : SCC) { - if (FunctionEffect == ModRef) + if (FunctionEffect == MRI_ModRef) break; // The mod/ref lattice saturates here. for (Instruction &I : inst_range(Node->getFunction())) { - if (FunctionEffect == ModRef) + if (FunctionEffect == MRI_ModRef) break; // The mod/ref lattice saturates here. // We handle calls specially because the graph-relevant aspects are @@ -514,13 +514,13 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { if (isAllocationFn(&I, TLI) || isFreeCall(&I, TLI)) { // FIXME: It is completely unclear why this is necessary and not // handled by the above graph code. - FunctionEffect |= ModRef; + FunctionEffect |= MRI_ModRef; } else if (Function *Callee = CS.getCalledFunction()) { // The callgraph doesn't include intrinsic calls. if (Callee->isIntrinsic()) { - ModRefBehavior Behaviour = + FunctionModRefBehavior Behaviour = AliasAnalysis::getModRefBehavior(Callee); - FunctionEffect |= (Behaviour & ModRef); + FunctionEffect |= (Behaviour & MRI_ModRef); } } continue; @@ -529,13 +529,13 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { // All non-call instructions we use the primary predicates for whether // thay read or write memory. if (I.mayReadFromMemory()) - FunctionEffect |= Ref; + FunctionEffect |= MRI_Ref; if (I.mayWriteToMemory()) - FunctionEffect |= Mod; + FunctionEffect |= MRI_Mod; } } - if ((FunctionEffect & Mod) == 0) + if ((FunctionEffect & MRI_Mod) == 0) ++NumReadMemFunctions; if (FunctionEffect == 0) ++NumNoMemFunctions; @@ -621,9 +621,9 @@ AliasResult GlobalsModRef::alias(const MemoryLocation &LocA, return AliasAnalysis::alias(LocA, LocB); } -AliasAnalysis::ModRefResult -GlobalsModRef::getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc) { - unsigned Known = ModRef; +ModRefInfo GlobalsModRef::getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) { + unsigned Known = MRI_ModRef; // If we are asking for mod/ref info of a direct call with a pointer to a // global we are tracking, return information if we have it. @@ -636,7 +636,7 @@ GlobalsModRef::getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc) { if (const FunctionRecord *FR = getFunctionInfo(F)) Known = FR->getInfoForGlobal(GV); - if (Known == NoModRef) - return NoModRef; // No need to query other mod/ref analyses - return ModRefResult(Known & AliasAnalysis::getModRefInfo(CS, Loc)); + if (Known == MRI_NoModRef) + return MRI_NoModRef; // No need to query other mod/ref analyses + return ModRefInfo(Known & AliasAnalysis::getModRefInfo(CS, Loc)); } diff --git a/llvm/lib/Analysis/LibCallAliasAnalysis.cpp b/llvm/lib/Analysis/LibCallAliasAnalysis.cpp index 991a0e3e275..c9e2585bd66 100644 --- a/llvm/lib/Analysis/LibCallAliasAnalysis.cpp +++ b/llvm/lib/Analysis/LibCallAliasAnalysis.cpp @@ -45,15 +45,16 @@ bool LibCallAliasAnalysis::runOnFunction(Function &F) { /// AnalyzeLibCallDetails - Given a call to a function with the specified /// LibCallFunctionInfo, see if we can improve the mod/ref footprint of the call /// vs the specified pointer/size. -AliasAnalysis::ModRefResult +ModRefInfo LibCallAliasAnalysis::AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, ImmutableCallSite CS, const MemoryLocation &Loc) { // If we have a function, check to see what kind of mod/ref effects it // has. Start by including any info globally known about the function. - AliasAnalysis::ModRefResult MRInfo = FI->UniversalBehavior; - if (MRInfo == NoModRef) return MRInfo; - + ModRefInfo MRInfo = FI->UniversalBehavior; + if (MRInfo == MRI_NoModRef) + return MRInfo; + // If that didn't tell us that the function is 'readnone', check to see // if we have detailed info and if 'P' is any of the locations we know // about. @@ -75,7 +76,7 @@ LibCallAliasAnalysis::AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, // If we find a match against a location that we 'do not' interact with, // learn this info into MRInfo. - return ModRefResult(MRInfo & ~Details[i].MRInfo); + return ModRefInfo(MRInfo & ~Details[i].MRInfo); } return MRInfo; } @@ -83,7 +84,7 @@ LibCallAliasAnalysis::AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, // If the details are of the 'DoesOnly' sort, we know something if the pointer // is a match for one of the locations in 'Details'. Also, if we can prove // that the pointers is *not* one of the locations in 'Details', we know that - // the call is NoModRef. + // the call is MRI_NoModRef. assert(FI->DetailsType == LibCallFunctionInfo::DoesOnly); // Find out if the pointer refers to a known location. @@ -103,16 +104,16 @@ LibCallAliasAnalysis::AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, // If we know that this pointer definitely is pointing into the location, // merge in this information. - return ModRefResult(MRInfo & Details[i].MRInfo); + return ModRefInfo(MRInfo & Details[i].MRInfo); } // If we found that the pointer is guaranteed to not match any of the // locations in our 'DoesOnly' rule, then we know that the pointer must point // to some other location. Since the libcall doesn't mod/ref any other - // locations, return NoModRef. + // locations, return MRI_NoModRef. if (NoneMatch) - return NoModRef; - + return MRI_NoModRef; + // Otherwise, return any other info gained so far. return MRInfo; } @@ -120,22 +121,22 @@ LibCallAliasAnalysis::AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, // getModRefInfo - Check to see if the specified callsite can clobber the // specified memory object. // -AliasAnalysis::ModRefResult -LibCallAliasAnalysis::getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) { - ModRefResult MRInfo = ModRef; - +ModRefInfo LibCallAliasAnalysis::getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) { + ModRefInfo MRInfo = MRI_ModRef; + // If this is a direct call to a function that LCI knows about, get the // information about the runtime function. if (LCI) { if (const Function *F = CS.getCalledFunction()) { if (const LibCallFunctionInfo *FI = LCI->getFunctionInfo(F)) { - MRInfo = ModRefResult(MRInfo & AnalyzeLibCallDetails(FI, CS, Loc)); - if (MRInfo == NoModRef) return NoModRef; + MRInfo = ModRefInfo(MRInfo & AnalyzeLibCallDetails(FI, CS, Loc)); + if (MRInfo == MRI_NoModRef) + return MRI_NoModRef; } } } // The AliasAnalysis base class has some smarts, lets use them. - return (ModRefResult)(MRInfo | AliasAnalysis::getModRefInfo(CS, Loc)); + return (ModRefInfo)(MRInfo | AliasAnalysis::getModRefInfo(CS, Loc)); } diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp index 624c5a18d67..4d6d960f159 100644 --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -246,9 +246,7 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB, // If we have alias analysis and it says the store won't modify the loaded // value, ignore the store. - if (AA && - (AA->getModRefInfo(SI, StrippedPtr, AccessSize) & - AliasAnalysis::Mod) == 0) + if (AA && (AA->getModRefInfo(SI, StrippedPtr, AccessSize) & MRI_Mod) == 0) continue; // Otherwise the store that may or may not alias the pointer, bail out. @@ -261,8 +259,7 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB, // If alias analysis claims that it really won't modify the load, // ignore it. if (AA && - (AA->getModRefInfo(Inst, StrippedPtr, AccessSize) & - AliasAnalysis::Mod) == 0) + (AA->getModRefInfo(Inst, StrippedPtr, AccessSize) & MRI_Mod) == 0) continue; // May modify the pointer, bail out. diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index fc96b7d8eb3..5ac6fdf239a 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -122,43 +122,43 @@ static void RemoveFromReverseMap(DenseMap<Instruction*, /// location, fill in Loc with the details, otherwise set Loc.Ptr to null. /// Return a ModRefInfo value describing the general behavior of the /// instruction. -static AliasAnalysis::ModRefResult -GetLocation(const Instruction *Inst, MemoryLocation &Loc, AliasAnalysis *AA) { +static ModRefInfo GetLocation(const Instruction *Inst, MemoryLocation &Loc, + AliasAnalysis *AA) { if (const LoadInst *LI = dyn_cast<LoadInst>(Inst)) { if (LI->isUnordered()) { Loc = MemoryLocation::get(LI); - return AliasAnalysis::Ref; + return MRI_Ref; } if (LI->getOrdering() == Monotonic) { Loc = MemoryLocation::get(LI); - return AliasAnalysis::ModRef; + return MRI_ModRef; } Loc = MemoryLocation(); - return AliasAnalysis::ModRef; + return MRI_ModRef; } if (const StoreInst *SI = dyn_cast<StoreInst>(Inst)) { if (SI->isUnordered()) { Loc = MemoryLocation::get(SI); - return AliasAnalysis::Mod; + return MRI_Mod; } if (SI->getOrdering() == Monotonic) { Loc = MemoryLocation::get(SI); - return AliasAnalysis::ModRef; + return MRI_ModRef; } Loc = MemoryLocation(); - return AliasAnalysis::ModRef; + return MRI_ModRef; } if (const VAArgInst *V = dyn_cast<VAArgInst>(Inst)) { Loc = MemoryLocation::get(V); - return AliasAnalysis::ModRef; + return MRI_ModRef; } if (const CallInst *CI = isFreeCall(Inst, AA->getTargetLibraryInfo())) { // calls to free() deallocate the entire structure Loc = MemoryLocation(CI->getArgOperand(0)); - return AliasAnalysis::Mod; + return MRI_Mod; } if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(Inst)) { @@ -174,7 +174,7 @@ GetLocation(const Instruction *Inst, MemoryLocation &Loc, AliasAnalysis *AA) { cast<ConstantInt>(II->getArgOperand(0))->getZExtValue(), AAInfo); // These intrinsics don't really modify the memory, but returning Mod // will allow them to be handled conservatively. - return AliasAnalysis::Mod; + return MRI_Mod; case Intrinsic::invariant_end: II->getAAMetadata(AAInfo); Loc = MemoryLocation( @@ -182,7 +182,7 @@ GetLocation(const Instruction *Inst, MemoryLocation &Loc, AliasAnalysis *AA) { cast<ConstantInt>(II->getArgOperand(1))->getZExtValue(), AAInfo); // These intrinsics don't really modify the memory, but returning Mod // will allow them to be handled conservatively. - return AliasAnalysis::Mod; + return MRI_Mod; default: break; } @@ -190,10 +190,10 @@ GetLocation(const Instruction *Inst, MemoryLocation &Loc, AliasAnalysis *AA) { // Otherwise, just do the coarse-grained thing that always works. if (Inst->mayWriteToMemory()) - return AliasAnalysis::ModRef; + return MRI_ModRef; if (Inst->mayReadFromMemory()) - return AliasAnalysis::Ref; - return AliasAnalysis::NoModRef; + return MRI_Ref; + return MRI_NoModRef; } /// getCallSiteDependencyFrom - Private helper for finding the local @@ -215,10 +215,10 @@ getCallSiteDependencyFrom(CallSite CS, bool isReadOnlyCall, // If this inst is a memory op, get the pointer it accessed MemoryLocation Loc; - AliasAnalysis::ModRefResult MR = GetLocation(Inst, Loc, AA); + ModRefInfo MR = GetLocation(Inst, Loc, AA); if (Loc.Ptr) { // A simple instruction. - if (AA->getModRefInfo(CS, Loc) != AliasAnalysis::NoModRef) + if (AA->getModRefInfo(CS, Loc) != MRI_NoModRef) return MemDepResult::getClobber(Inst); continue; } @@ -228,10 +228,10 @@ getCallSiteDependencyFrom(CallSite CS, bool isReadOnlyCall, if (isa<DbgInfoIntrinsic>(Inst)) continue; // If these two calls do not interfere, look past it. switch (AA->getModRefInfo(CS, InstCS)) { - case AliasAnalysis::NoModRef: + case MRI_NoModRef: // If the two calls are the same, return InstCS as a Def, so that // CS can be found redundant and eliminated. - if (isReadOnlyCall && !(MR & AliasAnalysis::Mod) && + if (isReadOnlyCall && !(MR & MRI_Mod) && CS.getInstruction()->isIdenticalToWhenDefined(Inst)) return MemDepResult::getDef(Inst); @@ -245,7 +245,7 @@ getCallSiteDependencyFrom(CallSite CS, bool isReadOnlyCall, // If we could not obtain a pointer for the instruction and the instruction // touches memory then assume that this is a dependency. - if (MR != AliasAnalysis::NoModRef) + if (MR != MRI_NoModRef) return MemDepResult::getClobber(Inst); } @@ -571,7 +571,7 @@ MemDepResult MemoryDependenceAnalysis::getPointerDependencyFrom( // 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) == AliasAnalysis::NoModRef) + if (AA->getModRefInfo(SI, MemLoc) == MRI_NoModRef) continue; // Ok, this store might clobber the query pointer. Check to see if it is @@ -620,17 +620,17 @@ MemDepResult MemoryDependenceAnalysis::getPointerDependencyFrom( continue; // See if this instruction (e.g. a call or vaarg) mod/ref's the pointer. - AliasAnalysis::ModRefResult MR = AA->getModRefInfo(Inst, MemLoc); + ModRefInfo MR = AA->getModRefInfo(Inst, MemLoc); // If necessary, perform additional analysis. - if (MR == AliasAnalysis::ModRef) + if (MR == MRI_ModRef) MR = AA->callCapturesBefore(Inst, MemLoc, DT); switch (MR) { - case AliasAnalysis::NoModRef: + case MRI_NoModRef: // If the call has no effect on the queried pointer, just ignore it. continue; - case AliasAnalysis::Mod: + case MRI_Mod: return MemDepResult::getClobber(Inst); - case AliasAnalysis::Ref: + case MRI_Ref: // 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) @@ -681,10 +681,10 @@ MemDepResult MemoryDependenceAnalysis::getDependency(Instruction *QueryInst) { LocalCache = MemDepResult::getNonFuncLocal(); } else { MemoryLocation MemLoc; - AliasAnalysis::ModRefResult MR = GetLocation(QueryInst, MemLoc, AA); + ModRefInfo MR = GetLocation(QueryInst, MemLoc, AA); if (MemLoc.Ptr) { // If we can do a pointer scan, make it happen. - bool isLoad = !(MR & AliasAnalysis::Mod); + bool isLoad = !(MR & MRI_Mod); if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(QueryInst)) isLoad |= II->getIntrinsicID() == Intrinsic::lifetime_start; diff --git a/llvm/lib/Analysis/NoAliasAnalysis.cpp b/llvm/lib/Analysis/NoAliasAnalysis.cpp index 1d21ed75954..aa78ceab89c 100644 --- a/llvm/lib/Analysis/NoAliasAnalysis.cpp +++ b/llvm/lib/Analysis/NoAliasAnalysis.cpp @@ -46,29 +46,29 @@ namespace { return MayAlias; } - ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override { - return UnknownModRefBehavior; + FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override { + return FMRB_UnknownModRefBehavior; } - ModRefBehavior getModRefBehavior(const Function *F) override { - return UnknownModRefBehavior; + FunctionModRefBehavior getModRefBehavior(const Function *F) override { + return FMRB_UnknownModRefBehavior; } bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) override { return false; } - ModRefResult getArgModRefInfo(ImmutableCallSite CS, - unsigned ArgIdx) override { - return ModRef; + ModRefInfo getArgModRefInfo(ImmutableCallSite CS, + unsigned ArgIdx) override { + return MRI_ModRef; } - ModRefResult getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) override { - return ModRef; + ModRefInfo getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) override { + return MRI_ModRef; } - ModRefResult getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) override { - return ModRef; + ModRefInfo getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) override { + return MRI_ModRef; } /// getAdjustedAnalysisPointer - This method is used when a pass implements diff --git a/llvm/lib/Analysis/ScopedNoAliasAA.cpp b/llvm/lib/Analysis/ScopedNoAliasAA.cpp index a5fca3e79b3..e89fbfbf865 100644 --- a/llvm/lib/Analysis/ScopedNoAliasAA.cpp +++ b/llvm/lib/Analysis/ScopedNoAliasAA.cpp @@ -102,12 +102,12 @@ private: AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) override; bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) override; - ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override; - ModRefBehavior getModRefBehavior(const Function *F) override; - ModRefResult getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) override; - ModRefResult getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) override; + FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override; + FunctionModRefBehavior getModRefBehavior(const Function *F) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) override; }; } // End of anonymous namespace @@ -204,48 +204,46 @@ bool ScopedNoAliasAA::pointsToConstantMemory(const MemoryLocation &Loc, return AliasAnalysis::pointsToConstantMemory(Loc, OrLocal); } -AliasAnalysis::ModRefBehavior +FunctionModRefBehavior ScopedNoAliasAA::getModRefBehavior(ImmutableCallSite CS) { return AliasAnalysis::getModRefBehavior(CS); } -AliasAnalysis::ModRefBehavior -ScopedNoAliasAA::getModRefBehavior(const Function *F) { +FunctionModRefBehavior ScopedNoAliasAA::getModRefBehavior(const Function *F) { return AliasAnalysis::getModRefBehavior(F); } -AliasAnalysis::ModRefResult -ScopedNoAliasAA::getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) { +ModRefInfo ScopedNoAliasAA::getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) { if (!EnableScopedNoAlias) return AliasAnalysis::getModRefInfo(CS, Loc); if (!mayAliasInScopes(Loc.AATags.Scope, CS.getInstruction()->getMetadata( LLVMContext::MD_noalias))) - return NoModRef; + return MRI_NoModRef; if (!mayAliasInScopes( CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope), Loc.AATags.NoAlias)) - return NoModRef; + return MRI_NoModRef; return AliasAnalysis::getModRefInfo(CS, Loc); } -AliasAnalysis::ModRefResult -ScopedNoAliasAA::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) { +ModRefInfo ScopedNoAliasAA::getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) { if (!EnableScopedNoAlias) return AliasAnalysis::getModRefInfo(CS1, CS2); if (!mayAliasInScopes( CS1.getInstruction()->getMetadata(LLVMContext::MD_alias_scope), CS2.getInstruction()->getMetadata(LLVMContext::MD_noalias))) - return NoModRef; + return MRI_NoModRef; if (!mayAliasInScopes( CS2.getInstruction()->getMetadata(LLVMContext::MD_alias_scope), CS1.getInstruction()->getMetadata(LLVMContext::MD_noalias))) - return NoModRef; + return MRI_NoModRef; return AliasAnalysis::getModRefInfo(CS1, CS2); } diff --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp index 4e9c6f678eb..c86856d330c 100644 --- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -304,12 +304,12 @@ namespace { const MemoryLocation &LocB) override; bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) override; - ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override; - ModRefBehavior getModRefBehavior(const Function *F) override; - ModRefResult getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) override; - ModRefResult getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) override; + FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override; + FunctionModRefBehavior getModRefBehavior(const Function *F) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) override; }; } // End of anonymous namespace @@ -491,32 +491,31 @@ bool TypeBasedAliasAnalysis::pointsToConstantMemory(const MemoryLocation &Loc, return AliasAnalysis::pointsToConstantMemory(Loc, OrLocal); } -AliasAnalysis::ModRefBehavior +FunctionModRefBehavior TypeBasedAliasAnalysis::getModRefBehavior(ImmutableCallSite CS) { if (!EnableTBAA) return AliasAnalysis::getModRefBehavior(CS); - ModRefBehavior Min = UnknownModRefBehavior; + FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior; // If this is an "immutable" type, we can assume the call doesn't write // to memory. if (const MDNode *M = CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa)) if ((!isStructPathTBAA(M) && TBAANode(M).TypeIsImmutable()) || (isStructPathTBAA(M) && TBAAStructTagNode(M).TypeIsImmutable())) - Min = OnlyReadsMemory; + Min = FMRB_OnlyReadsMemory; - return ModRefBehavior(AliasAnalysis::getModRefBehavior(CS) & Min); + return FunctionModRefBehavior(AliasAnalysis::getModRefBehavior(CS) & Min); } -AliasAnalysis::ModRefBehavior +FunctionModRefBehavior TypeBasedAliasAnalysis::getModRefBehavior(const Function *F) { // Functions don't have metadata. Just chain to the next implementation. return AliasAnalysis::getModRefBehavior(F); } -AliasAnalysis::ModRefResult -TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) { +ModRefInfo TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) { if (!EnableTBAA) return AliasAnalysis::getModRefInfo(CS, Loc); @@ -524,14 +523,13 @@ TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS, if (const MDNode *M = CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa)) if (!Aliases(L, M)) - return NoModRef; + return MRI_NoModRef; return AliasAnalysis::getModRefInfo(CS, Loc); } -AliasAnalysis::ModRefResult -TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) { +ModRefInfo TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) { if (!EnableTBAA) return AliasAnalysis::getModRefInfo(CS1, CS2); @@ -540,7 +538,7 @@ TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS1, if (const MDNode *M2 = CS2.getInstruction()->getMetadata(LLVMContext::MD_tbaa)) if (!Aliases(M1, M2)) - return NoModRef; + return MRI_NoModRef; return AliasAnalysis::getModRefInfo(CS1, CS2); } diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index af2504682aa..ce4468bd926 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -571,8 +571,7 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg, BasicBlock *BB = Load->getParent(); MemoryLocation Loc = MemoryLocation::get(Load); - if (AA.canInstructionRangeModRef(BB->front(), *Load, Loc, - AliasAnalysis::Mod)) + if (AA.canInstructionRangeModRef(BB->front(), *Load, Loc, MRI_Mod)) return false; // Pointer is invalidated! // Now check every path from the entry block to the load for transparency. diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index bb5e64aef33..93a549a2e90 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -166,8 +166,8 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) { // memory and give up. return false; - AliasAnalysis::ModRefBehavior MRB = AA->getModRefBehavior(F); - if (MRB == AliasAnalysis::DoesNotAccessMemory) + FunctionModRefBehavior MRB = AA->getModRefBehavior(F); + if (MRB == FMRB_DoesNotAccessMemory) // Already perfect! continue; @@ -193,7 +193,7 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) { // Ignore calls to functions in the same SCC. if (CS.getCalledFunction() && SCCNodes.count(CS.getCalledFunction())) continue; - AliasAnalysis::ModRefBehavior MRB = AA->getModRefBehavior(CS); + FunctionModRefBehavior MRB = AA->getModRefBehavior(CS); // If the call doesn't access arbitrary memory, we may be able to // figure out something. if (AliasAnalysis::onlyAccessesArgPointees(MRB)) { @@ -210,10 +210,10 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) { MemoryLocation Loc(Arg, MemoryLocation::UnknownSize, AAInfo); if (!AA->pointsToConstantMemory(Loc, /*OrLocal=*/true)) { - if (MRB & AliasAnalysis::Mod) + if (MRB & MRI_Mod) // Writes non-local memory. Give up. return false; - if (MRB & AliasAnalysis::Ref) + if (MRB & MRI_Ref) // Ok, it reads non-local memory. ReadsMemory = true; } @@ -222,10 +222,10 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) { continue; } // The call could access any memory. If that includes writes, give up. - if (MRB & AliasAnalysis::Mod) + if (MRB & MRI_Mod) return false; // If it reads, note it. - if (MRB & AliasAnalysis::Ref) + if (MRB & MRI_Ref) ReadsMemory = true; continue; } else if (LoadInst *LI = dyn_cast<LoadInst>(I)) { diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 286a5633024..42c20339d5a 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -1867,15 +1867,15 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { }; static IntrinsicKind getIntrinsicKind(Intrinsic::ID iid) { - const int DoesNotAccessMemory = IK_DoesNotAccessMemory; - const int OnlyReadsArgumentPointees = IK_OnlyReadsMemory; - const int OnlyReadsMemory = IK_OnlyReadsMemory; - const int OnlyAccessesArgumentPointees = IK_WritesMemory; - const int UnknownModRefBehavior = IK_WritesMemory; + const int FMRB_DoesNotAccessMemory = IK_DoesNotAccessMemory; + const int FMRB_OnlyReadsArgumentPointees = IK_OnlyReadsMemory; + const int FMRB_OnlyReadsMemory = IK_OnlyReadsMemory; + const int FMRB_OnlyAccessesArgumentPointees = IK_WritesMemory; + const int FMRB_UnknownModRefBehavior = IK_WritesMemory; #define GET_INTRINSIC_MODREF_BEHAVIOR -#define ModRefBehavior IntrinsicKind +#define FunctionModRefBehavior IntrinsicKind #include "llvm/IR/Intrinsics.gen" -#undef ModRefBehavior +#undef FunctionModRefBehavior #undef GET_INTRINSIC_MODREF_BEHAVIOR } diff --git a/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp b/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp index 4edd02904b2..0c6b16d5d01 100644 --- a/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp +++ b/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp @@ -49,7 +49,7 @@ bool llvm::objcarc::CanAlterRefCount(const Instruction *Inst, const Value *Ptr, assert(CS && "Only calls can alter reference counts!"); // See if AliasAnalysis can help us with the call. - AliasAnalysis::ModRefBehavior MRB = PA.getAA()->getModRefBehavior(CS); + FunctionModRefBehavior MRB = PA.getAA()->getModRefBehavior(CS); if (AliasAnalysis::onlyReadsMemory(MRB)) return false; if (AliasAnalysis::onlyAccessesArgPointees(MRB)) { diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.cpp index 3893aab76b2..e7d05404e9c 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.cpp @@ -112,20 +112,20 @@ bool ObjCARCAliasAnalysis::pointsToConstantMemory(const MemoryLocation &Loc, return false; } -AliasAnalysis::ModRefBehavior +FunctionModRefBehavior ObjCARCAliasAnalysis::getModRefBehavior(ImmutableCallSite CS) { // We have nothing to do. Just chain to the next AliasAnalysis. return AliasAnalysis::getModRefBehavior(CS); } -AliasAnalysis::ModRefBehavior +FunctionModRefBehavior ObjCARCAliasAnalysis::getModRefBehavior(const Function *F) { if (!EnableARCOpts) return AliasAnalysis::getModRefBehavior(F); switch (GetFunctionClass(F)) { case ARCInstKind::NoopCast: - return DoesNotAccessMemory; + return FMRB_DoesNotAccessMemory; default: break; } @@ -133,9 +133,8 @@ ObjCARCAliasAnalysis::getModRefBehavior(const Function *F) { return AliasAnalysis::getModRefBehavior(F); } -AliasAnalysis::ModRefResult -ObjCARCAliasAnalysis::getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) { +ModRefInfo ObjCARCAliasAnalysis::getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) { if (!EnableARCOpts) return AliasAnalysis::getModRefInfo(CS, Loc); @@ -151,7 +150,7 @@ ObjCARCAliasAnalysis::getModRefInfo(ImmutableCallSite CS, // These functions don't access any memory visible to the compiler. // Note that this doesn't include objc_retainBlock, because it updates // pointers when it copies block data. - return NoModRef; + return MRI_NoModRef; default: break; } @@ -159,10 +158,9 @@ ObjCARCAliasAnalysis::getModRefInfo(ImmutableCallSite CS, return AliasAnalysis::getModRefInfo(CS, Loc); } -AliasAnalysis::ModRefResult -ObjCARCAliasAnalysis::getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) { +ModRefInfo ObjCARCAliasAnalysis::getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) { // TODO: Theoretically we could check for dependencies between objc_* calls - // and OnlyAccessesArgumentPointees calls or other well-behaved calls. + // and FMRB_OnlyAccessesArgumentPointees calls or other well-behaved calls. return AliasAnalysis::getModRefInfo(CS1, CS2); } diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.h b/llvm/lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.h index eecc82fe572..a002e2862f9 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.h +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.h @@ -60,12 +60,12 @@ namespace objcarc { const MemoryLocation &LocB) override; bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) override; - ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override; - ModRefBehavior getModRefBehavior(const Function *F) override; - ModRefResult getModRefInfo(ImmutableCallSite CS, - const MemoryLocation &Loc) override; - ModRefResult getModRefInfo(ImmutableCallSite CS1, - ImmutableCallSite CS2) override; + FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override; + FunctionModRefBehavior getModRefBehavior(const Function *F) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS, + const MemoryLocation &Loc) override; + ModRefInfo getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) override; }; } // namespace objcarc diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp index baca76ba3f2..ded930658ab 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp @@ -247,7 +247,7 @@ static StoreInst *findSafeStoreForStoreStrongContraction(LoadInst *Load, // Ok, now we know we have not seen a store yet. See if Inst can write to // our load location, if it can not, just ignore the instruction. - if (!(AA->getModRefInfo(Inst, Loc) & AliasAnalysis::Mod)) + if (!(AA->getModRefInfo(Inst, Loc) & MRI_Mod)) continue; Store = dyn_cast<StoreInst>(Inst); diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index c50558434da..66f23b9a429 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -609,7 +609,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) { if (DepWrite == &BB.front()) break; // Can't look past this instruction if it might read 'Loc'. - if (AA->getModRefInfo(DepWrite, Loc) & AliasAnalysis::Ref) + if (AA->getModRefInfo(DepWrite, Loc) & MRI_Ref) break; InstDep = MD->getPointerDependencyFrom(Loc, false, DepWrite, &BB); @@ -795,10 +795,10 @@ bool DSE::handleEndBlock(BasicBlock &BB) { // the call is live. DeadStackObjects.remove_if([&](Value *I) { // See if the call site touches the value. - AliasAnalysis::ModRefResult A = AA->getModRefInfo( + ModRefInfo A = AA->getModRefInfo( CS, I, getPointerSize(I, DL, AA->getTargetLibraryInfo())); - return A == AliasAnalysis::ModRef || A == AliasAnalysis::Ref; + return A == MRI_ModRef || A == MRI_Ref; }); // If all of the allocas were clobbered by the call then we're not going diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 43fc50e588f..8f3839f40bc 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -457,8 +457,8 @@ bool canSinkOrHoistInst(Instruction &I, AliasAnalysis *AA, DominatorTree *DT, return false; // Handle simple cases by querying alias analysis. - AliasAnalysis::ModRefBehavior Behavior = AA->getModRefBehavior(CI); - if (Behavior == AliasAnalysis::DoesNotAccessMemory) + FunctionModRefBehavior Behavior = AA->getModRefBehavior(CI); + if (Behavior == FMRB_DoesNotAccessMemory) return true; if (AliasAnalysis::onlyReadsMemory(Behavior)) { // If this call only reads from memory and there are no writes to memory diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index a21ca2417ca..d1ee2268421 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -826,9 +826,9 @@ processLoopMemSet(MemSetInst *MSI, const SCEV *BECount) { /// mayLoopAccessLocation - Return true if the specified loop might access the /// specified pointer location, which is a loop-strided access. The 'Access' /// argument specifies what the verboten forms of access are (read or write). -static bool mayLoopAccessLocation(Value *Ptr,AliasAnalysis::ModRefResult Access, - Loop *L, const SCEV *BECount, - unsigned StoreSize, AliasAnalysis &AA, +static bool mayLoopAccessLocation(Value *Ptr, ModRefInfo Access, Loop *L, + const SCEV *BECount, unsigned StoreSize, + AliasAnalysis &AA, Instruction *IgnoredStore) { // Get the location that may be stored across the loop. Since the access is // strided positively through memory, we say that the modified location starts @@ -949,9 +949,8 @@ processLoopStridedStore(Value *DestPtr, unsigned StoreSize, Expander.expandCodeFor(Ev->getStart(), DestInt8PtrTy, Preheader->getTerminator()); - if (mayLoopAccessLocation(BasePtr, AliasAnalysis::ModRef, - CurLoop, BECount, - StoreSize, getAnalysis<AliasAnalysis>(), TheStore)) { + if (mayLoopAccessLocation(BasePtr, MRI_ModRef, CurLoop, BECount, StoreSize, + getAnalysis<AliasAnalysis>(), TheStore)) { Expander.clear(); // If we generated new code for the base pointer, clean up. RecursivelyDeleteTriviallyDeadInstructions(BasePtr, TLI); @@ -1047,9 +1046,8 @@ processLoopStoreOfLoopLoad(StoreInst *SI, unsigned StoreSize, Builder.getInt8PtrTy(SI->getPointerAddressSpace()), Preheader->getTerminator()); - if (mayLoopAccessLocation(StoreBasePtr, AliasAnalysis::ModRef, - CurLoop, BECount, StoreSize, - getAnalysis<AliasAnalysis>(), SI)) { + if (mayLoopAccessLocation(StoreBasePtr, MRI_ModRef, CurLoop, BECount, + StoreSize, getAnalysis<AliasAnalysis>(), SI)) { Expander.clear(); // If we generated new code for the base pointer, clean up. RecursivelyDeleteTriviallyDeadInstructions(StoreBasePtr, TLI); @@ -1063,8 +1061,8 @@ processLoopStoreOfLoopLoad(StoreInst *SI, unsigned StoreSize, Builder.getInt8PtrTy(LI->getPointerAddressSpace()), Preheader->getTerminator()); - if (mayLoopAccessLocation(LoadBasePtr, AliasAnalysis::Mod, CurLoop, BECount, - StoreSize, getAnalysis<AliasAnalysis>(), SI)) { + if (mayLoopAccessLocation(LoadBasePtr, MRI_Mod, CurLoop, BECount, StoreSize, + getAnalysis<AliasAnalysis>(), SI)) { Expander.clear(); // If we generated new code for the base pointer, clean up. RecursivelyDeleteTriviallyDeadInstructions(LoadBasePtr, TLI); diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 32921716f23..46105dab1d8 100644 --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -506,7 +506,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator &BBI) { MemoryLocation StoreLoc = MemoryLocation::get(SI); for (BasicBlock::iterator I = --BasicBlock::iterator(SI), E = C; I != E; --I) { - if (AA.getModRefInfo(&*I, StoreLoc) != AliasAnalysis::NoModRef) { + if (AA.getModRefInfo(&*I, StoreLoc) != MRI_NoModRef) { C = nullptr; break; } @@ -704,11 +704,11 @@ bool MemCpyOpt::performCallSlotOptzn(Instruction *cpy, // the use analysis, we also need to know that it does not sneakily // access dest. We rely on AA to figure this out for us. AliasAnalysis &AA = getAnalysis<AliasAnalysis>(); - AliasAnalysis::ModRefResult MR = AA.getModRefInfo(C, cpyDest, srcSize); + ModRefInfo MR = AA.getModRefInfo(C, cpyDest, srcSize); // If necessary, perform additional analysis. - if (MR != AliasAnalysis::NoModRef) + if (MR != MRI_NoModRef) MR = AA.callCapturesBefore(C, cpyDest, srcSize, &DT); - if (MR != AliasAnalysis::NoModRef) + if (MR != MRI_NoModRef) return false; // All the checks have passed, so do the transformation. diff --git a/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp b/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp index 1a729bae6a9..6a094b2a7a1 100644 --- a/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp +++ b/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp @@ -241,7 +241,7 @@ bool MergedLoadStoreMotion::isLoadHoistBarrierInRange(const Instruction& Start, const Instruction& End, LoadInst* LI) { MemoryLocation Loc = MemoryLocation::get(LI); - return AA->canInstructionRangeModRef(Start, End, Loc, AliasAnalysis::Mod); + return AA->canInstructionRangeModRef(Start, End, Loc, MRI_Mod); } /// @@ -398,7 +398,7 @@ bool MergedLoadStoreMotion::mergeLoads(BasicBlock *BB) { bool MergedLoadStoreMotion::isStoreSinkBarrierInRange(const Instruction &Start, const Instruction &End, MemoryLocation Loc) { - return AA->canInstructionRangeModRef(Start, End, Loc, AliasAnalysis::ModRef); + return AA->canInstructionRangeModRef(Start, End, Loc, MRI_ModRef); } /// diff --git a/llvm/lib/Transforms/Scalar/Sink.cpp b/llvm/lib/Transforms/Scalar/Sink.cpp index f49f4eaaedc..17684c04dc4 100644 --- a/llvm/lib/Transforms/Scalar/Sink.cpp +++ b/llvm/lib/Transforms/Scalar/Sink.cpp @@ -165,7 +165,7 @@ static bool isSafeToMove(Instruction *Inst, AliasAnalysis *AA, if (LoadInst *L = dyn_cast<LoadInst>(Inst)) { MemoryLocation Loc = MemoryLocation::get(L); for (Instruction *S : Stores) - if (AA->getModRefInfo(S, Loc) & AliasAnalysis::Mod) + if (AA->getModRefInfo(S, Loc) & MRI_Mod) return false; } diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index d2d60d7cd9f..bc6e9bfcb46 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -481,9 +481,9 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap, IsFuncCall = true; if (AA) { - AliasAnalysis::ModRefBehavior MRB = AA->getModRefBehavior(ICS); - if (MRB == AliasAnalysis::OnlyAccessesArgumentPointees || - MRB == AliasAnalysis::OnlyReadsArgumentPointees) + FunctionModRefBehavior MRB = AA->getModRefBehavior(ICS); + if (MRB == FMRB_OnlyAccessesArgumentPointees || + MRB == FMRB_OnlyReadsArgumentPointees) IsArgMemOnlyCall = true; } |