Skip to content

Revert "[ExecutionEngine] Avoid repeated hash lookups (NFC)" #133101

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: 12 additions & 12 deletions llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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.
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading