Author: David Spickett Date: 2025-03-26T15:03:58Z New Revision: 1840957286329da64742ea50a9e28fd79e7baa56
URL: https://github.com/llvm/llvm-project/commit/1840957286329da64742ea50a9e28fd79e7baa56 DIFF: https://github.com/llvm/llvm-project/commit/1840957286329da64742ea50a9e28fd79e7baa56.diff LOG: Revert "[ExecutionEngine] Avoid repeated hash lookups (NFC) (#132587)" This reverts commit 0b181de20665574e086ed147868e34e8787a5286. Added: Modified: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h Removed: ################################################################################ diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index 6333bda0270f8..def117448ab6a 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -1515,15 +1515,15 @@ void RuntimeDyldELF::resolveAArch64Branch(unsigned SectionID, uint64_t Offset = RelI->getOffset(); unsigned RelType = RelI->getType(); // Look for an existing stub. - auto [It, Inserted] = Stubs.try_emplace(Value); - if (!Inserted) { + StubMap::const_iterator i = Stubs.find(Value); + if (i != Stubs.end()) { resolveRelocation(Section, Offset, - Section.getLoadAddressWithOffset(It->second), RelType, 0); + Section.getLoadAddressWithOffset(i->second), RelType, 0); LLVM_DEBUG(dbgs() << " Stub function found\n"); } else if (!resolveAArch64ShortBranch(SectionID, RelI, Value)) { // Create a new stub function. LLVM_DEBUG(dbgs() << " Create a new stub function\n"); - It->second = Section.getStubOffset(); + Stubs[Value] = Section.getStubOffset(); uint8_t *StubTargetAddr = createStubFunction( Section.getAddressWithOffset(Section.getStubOffset())); @@ -1837,15 +1837,15 @@ RuntimeDyldELF::processRelocationRef( SectionEntry &Section = Sections[SectionID]; // Look up for existing stub. - auto [It, Inserted] = Stubs.try_emplace(Value); - if (!Inserted) { - RelocationEntry RE(SectionID, Offset, RelType, It->second); + StubMap::const_iterator i = Stubs.find(Value); + if (i != Stubs.end()) { + RelocationEntry RE(SectionID, Offset, RelType, i->second); addRelocationForSection(RE, SectionID); LLVM_DEBUG(dbgs() << " Stub function found\n"); } else { // Create a new stub function. LLVM_DEBUG(dbgs() << " Create a new stub function\n"); - It->second = Section.getStubOffset(); + Stubs[Value] = Section.getStubOffset(); unsigned AbiVariant = Obj.getPlatformFlags(); @@ -2075,10 +2075,10 @@ RuntimeDyldELF::processRelocationRef( SectionEntry &Section = Sections[SectionID]; // Look for an existing stub. - auto [It, Inserted] = Stubs.try_emplace(Value); + StubMap::const_iterator i = Stubs.find(Value); uintptr_t StubAddress; - if (!Inserted) { - StubAddress = uintptr_t(Section.getAddressWithOffset(It->second)); + if (i != Stubs.end()) { + StubAddress = uintptr_t(Section.getAddressWithOffset(i->second)); LLVM_DEBUG(dbgs() << " Stub function found\n"); } else { // Create a new stub function. @@ -2089,7 +2089,7 @@ RuntimeDyldELF::processRelocationRef( alignTo(BaseAddress + Section.getStubOffset(), getStubAlignment()); unsigned StubOffset = StubAddress - BaseAddress; - It->second = StubOffset; + Stubs[Value] = StubOffset; createStubFunction((uint8_t *)StubAddress); RelocationEntry RE(SectionID, StubOffset + 8, ELF::R_390_64, Value.Offset); diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h index e0d9f2af988fb..79b558eb7796d 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h @@ -307,14 +307,14 @@ class RuntimeDyldMachOARM // This is an ARM branch relocation, need to use a stub function. // Look up for existing stub. SectionEntry &Section = Sections[RE.SectionID]; - auto [It, Inserted] = Stubs.try_emplace(Value); + RuntimeDyldMachO::StubMap::const_iterator i = Stubs.find(Value); uint8_t *Addr; - if (!Inserted) { - Addr = Section.getAddressWithOffset(It->second); + if (i != Stubs.end()) { + Addr = Section.getAddressWithOffset(i->second); } else { // Create a new stub function. assert(Section.getStubOffset() % 4 == 0 && "Misaligned stub"); - It->second = Section.getStubOffset(); + Stubs[Value] = Section.getStubOffset(); uint32_t StubOpcode = 0; if (RE.RelType == MachO::ARM_RELOC_BR24) StubOpcode = 0xe51ff004; // ldr pc, [pc, #-4] diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h index 4b0d4d884607a..bd0d72f9e1172 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h @@ -131,12 +131,12 @@ class RuntimeDyldMachOX86_64 assert(RE.IsPCRel); assert(RE.Size == 2); Value.Offset -= RE.Addend; - auto [It, Inserted] = Stubs.try_emplace(Value); + RuntimeDyldMachO::StubMap::const_iterator i = Stubs.find(Value); uint8_t *Addr; - if (!Inserted) { - Addr = Section.getAddressWithOffset(It->second); + if (i != Stubs.end()) { + Addr = Section.getAddressWithOffset(i->second); } else { - It->second = Section.getStubOffset(); + Stubs[Value] = Section.getStubOffset(); uint8_t *GOTEntry = Section.getAddressWithOffset(Section.getStubOffset()); RelocationEntry GOTRE(RE.SectionID, Section.getStubOffset(), MachO::X86_64_RELOC_UNSIGNED, Value.Offset, false, _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits