@@ -1680,16 +1680,16 @@ RuntimeDyldELF::processRelocationRef(
16801680 SectionEntry &Section = Sections[SectionID];
16811681
16821682 // Look for an existing stub.
1683- StubMap::const_iterator i = Stubs.find (Value);
1684- if (i != Stubs. end () ) {
1683+ auto [It, Inserted] = Stubs.try_emplace (Value);
1684+ if (!Inserted ) {
16851685 resolveRelocation (Section, Offset,
1686- Section.getLoadAddressWithOffset (i ->second ), RelType,
1686+ Section.getLoadAddressWithOffset (It ->second ), RelType,
16871687 0 );
16881688 LLVM_DEBUG (dbgs () << " Stub function found\n " );
16891689 } else {
16901690 // Create a new stub function.
16911691 LLVM_DEBUG (dbgs () << " Create a new stub function\n " );
1692- Stubs[Value] = Section.getStubOffset ();
1692+ It-> second = Section.getStubOffset ();
16931693 uint8_t *StubTargetAddr = createStubFunction (
16941694 Section.getAddressWithOffset (Section.getStubOffset ()));
16951695 RelocationEntry RE (SectionID, StubTargetAddr - Section.getAddress (),
@@ -1745,15 +1745,15 @@ RuntimeDyldELF::processRelocationRef(
17451745 Value.Addend += Addend;
17461746
17471747 // Look up for existing stub.
1748- StubMap::const_iterator i = Stubs.find (Value);
1749- if (i != Stubs. end () ) {
1750- RelocationEntry RE (SectionID, Offset, RelType, i ->second );
1748+ auto [It, Inserted] = Stubs.try_emplace (Value);
1749+ if (!Inserted ) {
1750+ RelocationEntry RE (SectionID, Offset, RelType, It ->second );
17511751 addRelocationForSection (RE, SectionID);
17521752 LLVM_DEBUG (dbgs () << " Stub function found\n " );
17531753 } else {
17541754 // Create a new stub function.
17551755 LLVM_DEBUG (dbgs () << " Create a new stub function\n " );
1756- Stubs[Value] = Section.getStubOffset ();
1756+ It-> second = Section.getStubOffset ();
17571757
17581758 unsigned AbiVariant = Obj.getPlatformFlags ();
17591759
@@ -1945,17 +1945,17 @@ RuntimeDyldELF::processRelocationRef(
19451945 RangeOverflow) {
19461946 // It is an external symbol (either Value.SymbolName is set, or
19471947 // SymType is SymbolRef::ST_Unknown) or out of range.
1948- StubMap::const_iterator i = Stubs.find (Value);
1949- if (i != Stubs. end () ) {
1948+ auto [It, Inserted] = Stubs.try_emplace (Value);
1949+ if (!Inserted ) {
19501950 // Symbol function stub already created, just relocate to it
19511951 resolveRelocation (Section, Offset,
1952- Section.getLoadAddressWithOffset (i ->second ),
1952+ Section.getLoadAddressWithOffset (It ->second ),
19531953 RelType, 0 );
19541954 LLVM_DEBUG (dbgs () << " Stub function found\n " );
19551955 } else {
19561956 // Create a new stub function.
19571957 LLVM_DEBUG (dbgs () << " Create a new stub function\n " );
1958- Stubs[Value] = Section.getStubOffset ();
1958+ It-> second = Section.getStubOffset ();
19591959 uint8_t *StubTargetAddr = createStubFunction (
19601960 Section.getAddressWithOffset (Section.getStubOffset ()),
19611961 AbiVariant);
@@ -2127,10 +2127,10 @@ RuntimeDyldELF::processRelocationRef(
21272127 // This is a call to an external function.
21282128 // Look for an existing stub.
21292129 SectionEntry *Section = &Sections[SectionID];
2130- StubMap::const_iterator i = Stubs.find (Value);
2130+ auto [It, Inserted] = Stubs.try_emplace (Value);
21312131 uintptr_t StubAddress;
2132- if (i != Stubs. end () ) {
2133- StubAddress = uintptr_t (Section->getAddress ()) + i ->second ;
2132+ if (!Inserted ) {
2133+ StubAddress = uintptr_t (Section->getAddress ()) + It ->second ;
21342134 LLVM_DEBUG (dbgs () << " Stub function found\n " );
21352135 } else {
21362136 // Create a new stub function (equivalent to a PLT entry).
@@ -2140,7 +2140,7 @@ RuntimeDyldELF::processRelocationRef(
21402140 StubAddress = alignTo (BaseAddress + Section->getStubOffset (),
21412141 getStubAlignment ());
21422142 unsigned StubOffset = StubAddress - BaseAddress;
2143- Stubs[Value] = StubOffset;
2143+ It-> second = StubOffset;
21442144 createStubFunction ((uint8_t *)StubAddress);
21452145
21462146 // Bump our stub offset counter
0 commit comments