Skip to content

[ExecutionEngine] Use range-based for loops (NFC) #98110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions llvm/lib/ExecutionEngine/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ bool ExecutionEngine::removeModule(Module *M) {
}

Function *ExecutionEngine::FindFunctionNamed(StringRef FnName) {
for (unsigned i = 0, e = Modules.size(); i != e; ++i) {
Function *F = Modules[i]->getFunction(FnName);
for (const auto &M : Modules) {
Function *F = M->getFunction(FnName);
if (F && !F->isDeclaration())
return F;
}
return nullptr;
}

GlobalVariable *ExecutionEngine::FindGlobalVariableNamed(StringRef Name, bool AllowInternal) {
for (unsigned i = 0, e = Modules.size(); i != e; ++i) {
GlobalVariable *GV = Modules[i]->getGlobalVariable(Name,AllowInternal);
for (const auto &M : Modules) {
GlobalVariable *GV = M->getGlobalVariable(Name, AllowInternal);
if (GV && !GV->isDeclaration())
return GV;
}
Expand Down Expand Up @@ -314,8 +314,8 @@ const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {

if (I != EEState.getGlobalAddressReverseMap().end()) {
StringRef Name = I->second;
for (unsigned i = 0, e = Modules.size(); i != e; ++i)
if (GlobalValue *GV = Modules[i]->getNamedValue(Name))
for (const auto &M : Modules)
if (GlobalValue *GV = M->getNamedValue(Name))
return GV;
}
return nullptr;
Expand Down Expand Up @@ -1219,9 +1219,8 @@ void ExecutionEngine::emitGlobals() {
const GlobalValue*> LinkedGlobalsMap;

if (Modules.size() != 1) {
for (unsigned m = 0, e = Modules.size(); m != e; ++m) {
Module &M = *Modules[m];
for (const auto &GV : M.globals()) {
for (const auto &M : Modules) {
for (const auto &GV : M->globals()) {
if (GV.hasLocalLinkage() || GV.isDeclaration() ||
GV.hasAppendingLinkage() || !GV.hasName())
continue;// Ignore external globals and globals with internal linkage.
Expand Down Expand Up @@ -1249,9 +1248,8 @@ void ExecutionEngine::emitGlobals() {
}

std::vector<const GlobalValue*> NonCanonicalGlobals;
for (unsigned m = 0, e = Modules.size(); m != e; ++m) {
Module &M = *Modules[m];
for (const auto &GV : M.globals()) {
for (const auto &M : Modules) {
for (const auto &GV : M->globals()) {
// In the multi-module case, see what this global maps to.
if (!LinkedGlobalsMap.empty()) {
if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
Expand Down Expand Up @@ -1293,7 +1291,7 @@ void ExecutionEngine::emitGlobals() {

// Now that all of the globals are set up in memory, loop through them all
// and initialize their contents.
for (const auto &GV : M.globals()) {
for (const auto &GV : M->globals()) {
if (!GV.isDeclaration()) {
if (!LinkedGlobalsMap.empty()) {
if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,7 @@ void RuntimeDyldImpl::reassignSectionAddress(unsigned SectionID,

void RuntimeDyldImpl::resolveRelocationList(const RelocationList &Relocs,
uint64_t Value) {
for (unsigned i = 0, e = Relocs.size(); i != e; ++i) {
const RelocationEntry &RE = Relocs[i];
for (const RelocationEntry &RE : Relocs) {
// Ignore relocations for sections that were not loaded
if (RE.SectionID != AbsoluteSymbolSection &&
Sections[RE.SectionID].getAddress() == nullptr)
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ RuntimeDyldELF::RuntimeDyldELF(RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyldELF::~RuntimeDyldELF() = default;

void RuntimeDyldELF::registerEHFrames() {
for (int i = 0, e = UnregisteredEHFrameSections.size(); i != e; ++i) {
SID EHFrameSID = UnregisteredEHFrameSections[i];
for (SID EHFrameSID : UnregisteredEHFrameSections) {
uint8_t *EHFrameAddr = Sections[EHFrameSID].getAddress();
uint64_t EHFrameLoadAddr = Sections[EHFrameSID].getLoadAddress();
size_t EHFrameSize = Sections[EHFrameSID].getSize();
Expand Down
Loading