mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
[PM/AA] Cleanup some loops to be range-based. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242275 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -207,35 +207,34 @@ Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); }
|
|||||||
/// and record the functions that they are used directly in.
|
/// and record the functions that they are used directly in.
|
||||||
void GlobalsModRef::AnalyzeGlobals(Module &M) {
|
void GlobalsModRef::AnalyzeGlobals(Module &M) {
|
||||||
std::vector<Function *> Readers, Writers;
|
std::vector<Function *> Readers, Writers;
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
for (Function &F : M)
|
||||||
if (I->hasLocalLinkage()) {
|
if (F.hasLocalLinkage()) {
|
||||||
if (!AnalyzeUsesOfPointer(I, Readers, Writers)) {
|
if (!AnalyzeUsesOfPointer(&F, Readers, Writers)) {
|
||||||
// Remember that we are tracking this global.
|
// Remember that we are tracking this global.
|
||||||
NonAddressTakenGlobals.insert(I);
|
NonAddressTakenGlobals.insert(&F);
|
||||||
++NumNonAddrTakenFunctions;
|
++NumNonAddrTakenFunctions;
|
||||||
}
|
}
|
||||||
Readers.clear();
|
Readers.clear();
|
||||||
Writers.clear();
|
Writers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E;
|
for (GlobalVariable &GV : M.globals())
|
||||||
++I)
|
if (GV.hasLocalLinkage()) {
|
||||||
if (I->hasLocalLinkage()) {
|
if (!AnalyzeUsesOfPointer(&GV, Readers, Writers)) {
|
||||||
if (!AnalyzeUsesOfPointer(I, Readers, Writers)) {
|
|
||||||
// Remember that we are tracking this global, and the mod/ref fns
|
// Remember that we are tracking this global, and the mod/ref fns
|
||||||
NonAddressTakenGlobals.insert(I);
|
NonAddressTakenGlobals.insert(&GV);
|
||||||
|
|
||||||
for (unsigned i = 0, e = Readers.size(); i != e; ++i)
|
for (Function *Reader : Readers)
|
||||||
FunctionInfo[Readers[i]].GlobalInfo[I] |= Ref;
|
FunctionInfo[Reader].GlobalInfo[&GV] |= Ref;
|
||||||
|
|
||||||
if (!I->isConstant()) // No need to keep track of writers to constants
|
if (!GV.isConstant()) // No need to keep track of writers to constants
|
||||||
for (unsigned i = 0, e = Writers.size(); i != e; ++i)
|
for (Function *Writer : Writers)
|
||||||
FunctionInfo[Writers[i]].GlobalInfo[I] |= Mod;
|
FunctionInfo[Writer].GlobalInfo[&GV] |= Mod;
|
||||||
++NumNonAddrTakenGlobalVars;
|
++NumNonAddrTakenGlobalVars;
|
||||||
|
|
||||||
// If this global holds a pointer type, see if it is an indirect global.
|
// If this global holds a pointer type, see if it is an indirect global.
|
||||||
if (I->getType()->getElementType()->isPointerTy() &&
|
if (GV.getType()->getElementType()->isPointerTy() &&
|
||||||
AnalyzeIndirectGlobalMemory(I))
|
AnalyzeIndirectGlobalMemory(&GV))
|
||||||
++NumIndirectGlobalVars;
|
++NumIndirectGlobalVars;
|
||||||
}
|
}
|
||||||
Readers.clear();
|
Readers.clear();
|
||||||
@ -370,8 +369,8 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
|
|||||||
if (!SCC[0]->getFunction()) {
|
if (!SCC[0]->getFunction()) {
|
||||||
// Calls externally - can't say anything useful. Remove any existing
|
// Calls externally - can't say anything useful. Remove any existing
|
||||||
// function records (may have been created when scanning globals).
|
// function records (may have been created when scanning globals).
|
||||||
for (unsigned i = 0, e = SCC.size(); i != e; ++i)
|
for (auto *Node : SCC)
|
||||||
FunctionInfo.erase(SCC[i]->getFunction());
|
FunctionInfo.erase(Node->getFunction());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,8 +433,8 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
|
|||||||
// If we can't say anything useful about this SCC, remove all SCC functions
|
// If we can't say anything useful about this SCC, remove all SCC functions
|
||||||
// from the FunctionInfo map.
|
// from the FunctionInfo map.
|
||||||
if (KnowNothing) {
|
if (KnowNothing) {
|
||||||
for (unsigned i = 0, e = SCC.size(); i != e; ++i)
|
for (auto *Node : SCC)
|
||||||
FunctionInfo.erase(SCC[i]->getFunction());
|
FunctionInfo.erase(Node->getFunction());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user