diff options
Diffstat (limited to 'llvm/lib/Analysis/GlobalsModRef.cpp')
-rw-r--r-- | llvm/lib/Analysis/GlobalsModRef.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp index efdf9706ba3..758e8277c5d 100644 --- a/llvm/lib/Analysis/GlobalsModRef.cpp +++ b/llvm/lib/Analysis/GlobalsModRef.cpp @@ -286,7 +286,7 @@ GlobalsAAResult::getFunctionInfo(const Function *F) { void GlobalsAAResult::AnalyzeGlobals(Module &M) { SmallPtrSet<Function *, 32> TrackedFunctions; for (Function &F : M) - if (F.hasLocalLinkage()) + if (F.hasLocalLinkage()) { if (!AnalyzeUsesOfPointer(&F)) { // Remember that we are tracking this global. NonAddressTakenGlobals.insert(&F); @@ -294,7 +294,9 @@ void GlobalsAAResult::AnalyzeGlobals(Module &M) { Handles.emplace_front(*this, &F); Handles.front().I = Handles.begin(); ++NumNonAddrTakenFunctions; - } + } else + UnknownFunctionsWithLocalLinkage = true; + } SmallPtrSet<Function *, 16> Readers, Writers; for (GlobalVariable &GV : M.globals()) @@ -526,9 +528,12 @@ void GlobalsAAResult::AnalyzeCallGraph(CallGraph &CG, Module &M) { FI.setMayReadAnyGlobal(); } else { FI.addModRefInfo(ModRefInfo::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(); + if (!F->onlyAccessesArgMemory()) + FI.setMayReadAnyGlobal(); + if (!F->isIntrinsic()) { + KnowNothing = true; + break; + } } continue; } @@ -927,7 +932,9 @@ ModRefInfo GlobalsAAResult::getModRefInfo(const CallBase *Call, // global we are tracking, return information if we have it. if (const GlobalValue *GV = dyn_cast<GlobalValue>(GetUnderlyingObject(Loc.Ptr, DL))) - if (GV->hasLocalLinkage()) + // If GV is internal to this IR and there is no function with local linkage + // that has had their address taken, keep looking for a tighter ModRefInfo. + if (GV->hasLocalLinkage() && !UnknownFunctionsWithLocalLinkage) if (const Function *F = Call->getCalledFunction()) if (NonAddressTakenGlobals.count(GV)) if (const FunctionInfo *FI = getFunctionInfo(F)) |