Skip to content

Commit 030b3db

Browse files
lhamessmallp-o-p
authored andcommitted
Revert "Revert "[JITLink] Use MapVector to stabilize iteration order""
This reverts commit 244ea40 while I test a fix for a build failure: https://lab.llvm.org/buildbot/#/builders/174/builds/7685.
1 parent 8305fd9 commit 030b3db

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "llvm/ADT/DenseMap.h"
1717
#include "llvm/ADT/DenseSet.h"
18+
#include "llvm/ADT/MapVector.h"
1819
#include "llvm/ADT/FunctionExtras.h"
1920
#include "llvm/ADT/STLExtras.h"
2021
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
@@ -853,7 +854,7 @@ class SectionRange {
853854

854855
class LinkGraph {
855856
private:
856-
using SectionMap = DenseMap<StringRef, std::unique_ptr<Section>>;
857+
using SectionMap = MapVector<StringRef, std::unique_ptr<Section>>;
857858
using ExternalSymbolMap = StringMap<Symbol *>;
858859
using AbsoluteSymbolSet = DenseSet<Symbol *>;
859860
using BlockSet = DenseSet<Block *>;
@@ -1595,7 +1596,7 @@ class LinkGraph {
15951596
unsigned PointerSize;
15961597
llvm::endianness Endianness;
15971598
GetEdgeKindNameFunction GetEdgeKindName = nullptr;
1598-
DenseMap<StringRef, std::unique_ptr<Section>> Sections;
1599+
MapVector<StringRef, std::unique_ptr<Section>> Sections;
15991600
ExternalSymbolMap ExternalSymbols;
16001601
AbsoluteSymbolSet AbsoluteSymbols;
16011602
orc::shared::AllocActions AAs;

llvm/lib/ExecutionEngine/JITLink/JITLink.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,11 @@ void LinkGraph::dump(raw_ostream &OS) {
291291
return false;
292292
});
293293

294-
std::vector<Section *> SortedSections;
295-
for (auto &Sec : sections())
296-
SortedSections.push_back(&Sec);
297-
llvm::sort(SortedSections, [](const Section *LHS, const Section *RHS) {
298-
return LHS->getName() < RHS->getName();
299-
});
300-
301-
for (auto *Sec : SortedSections) {
302-
OS << "section " << Sec->getName() << ":\n\n";
294+
for (auto &Sec : sections()) {
295+
OS << "section " << Sec.getName() << ":\n\n";
303296

304297
std::vector<Block *> SortedBlocks;
305-
llvm::copy(Sec->blocks(), std::back_inserter(SortedBlocks));
298+
llvm::copy(Sec.blocks(), std::back_inserter(SortedBlocks));
306299
llvm::sort(SortedBlocks, [](const Block *LHS, const Block *RHS) {
307300
return LHS->getAddress() < RHS->getAddress();
308301
});

llvm/test/ExecutionEngine/JITLink/x86-64/COFF_comdat_associative_dead_strip.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
# parent block is dead.
88
#
99
# CHECK: Link graph
10-
# CHECK-DAG: section child:
11-
# CHECK-EMPTY:
1210
# CHECK-DAG: section parent:
1311
# CHECK-EMPTY:
12+
# CHECK-DAG: section child:
13+
# CHECK-EMPTY:
1414

1515
--- !COFF
1616
header:

llvm/test/ExecutionEngine/JITLink/x86-64/COFF_pdata_strip.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#
99
# CHECK: section .func:
1010
# CHECK-EMPTY:
11-
# CHECK-NEXT: section .pdata:
11+
# CHECK-NEXT: section .xdata:
1212
# CHECK-EMPTY:
13-
# CHECK: section .xdata:
13+
# CHECK-NEXT: section .pdata:
1414
# CHECK-EMPTY:
1515

1616
.text

0 commit comments

Comments
 (0)