@@ -1680,16 +1680,16 @@ RuntimeDyldELF::processRelocationRef(
1680
1680
SectionEntry &Section = Sections[SectionID];
1681
1681
1682
1682
// 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 ) {
1685
1685
resolveRelocation (Section, Offset,
1686
- Section.getLoadAddressWithOffset (i ->second ), RelType,
1686
+ Section.getLoadAddressWithOffset (It ->second ), RelType,
1687
1687
0 );
1688
1688
LLVM_DEBUG (dbgs () << " Stub function found\n " );
1689
1689
} else {
1690
1690
// Create a new stub function.
1691
1691
LLVM_DEBUG (dbgs () << " Create a new stub function\n " );
1692
- Stubs[Value] = Section.getStubOffset ();
1692
+ It-> second = Section.getStubOffset ();
1693
1693
uint8_t *StubTargetAddr = createStubFunction (
1694
1694
Section.getAddressWithOffset (Section.getStubOffset ()));
1695
1695
RelocationEntry RE (SectionID, StubTargetAddr - Section.getAddress (),
@@ -1745,15 +1745,15 @@ RuntimeDyldELF::processRelocationRef(
1745
1745
Value.Addend += Addend;
1746
1746
1747
1747
// 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 );
1751
1751
addRelocationForSection (RE, SectionID);
1752
1752
LLVM_DEBUG (dbgs () << " Stub function found\n " );
1753
1753
} else {
1754
1754
// Create a new stub function.
1755
1755
LLVM_DEBUG (dbgs () << " Create a new stub function\n " );
1756
- Stubs[Value] = Section.getStubOffset ();
1756
+ It-> second = Section.getStubOffset ();
1757
1757
1758
1758
unsigned AbiVariant = Obj.getPlatformFlags ();
1759
1759
@@ -1945,17 +1945,17 @@ RuntimeDyldELF::processRelocationRef(
1945
1945
RangeOverflow) {
1946
1946
// It is an external symbol (either Value.SymbolName is set, or
1947
1947
// 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 ) {
1950
1950
// Symbol function stub already created, just relocate to it
1951
1951
resolveRelocation (Section, Offset,
1952
- Section.getLoadAddressWithOffset (i ->second ),
1952
+ Section.getLoadAddressWithOffset (It ->second ),
1953
1953
RelType, 0 );
1954
1954
LLVM_DEBUG (dbgs () << " Stub function found\n " );
1955
1955
} else {
1956
1956
// Create a new stub function.
1957
1957
LLVM_DEBUG (dbgs () << " Create a new stub function\n " );
1958
- Stubs[Value] = Section.getStubOffset ();
1958
+ It-> second = Section.getStubOffset ();
1959
1959
uint8_t *StubTargetAddr = createStubFunction (
1960
1960
Section.getAddressWithOffset (Section.getStubOffset ()),
1961
1961
AbiVariant);
@@ -2127,10 +2127,10 @@ RuntimeDyldELF::processRelocationRef(
2127
2127
// This is a call to an external function.
2128
2128
// Look for an existing stub.
2129
2129
SectionEntry *Section = &Sections[SectionID];
2130
- StubMap::const_iterator i = Stubs.find (Value);
2130
+ auto [It, Inserted] = Stubs.try_emplace (Value);
2131
2131
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 ;
2134
2134
LLVM_DEBUG (dbgs () << " Stub function found\n " );
2135
2135
} else {
2136
2136
// Create a new stub function (equivalent to a PLT entry).
@@ -2140,7 +2140,7 @@ RuntimeDyldELF::processRelocationRef(
2140
2140
StubAddress = alignTo (BaseAddress + Section->getStubOffset (),
2141
2141
getStubAlignment ());
2142
2142
unsigned StubOffset = StubAddress - BaseAddress;
2143
- Stubs[Value] = StubOffset;
2143
+ It-> second = StubOffset;
2144
2144
createStubFunction ((uint8_t *)StubAddress);
2145
2145
2146
2146
// Bump our stub offset counter
0 commit comments