Skip to content

Commit 244ea40

Browse files
committed
Revert "[JITLink] Use MapVector to stabilize iteration order"
This reverts commit f8f4235 and replaces the MapVector with a sorted vector in the debug dump: We only need to sort the sections for debug dumping, and don't want LinkGraph API clients assuming anything about the section iteration order.
1 parent e05def0 commit 244ea40

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "llvm/ADT/DenseMap.h"
1717
#include "llvm/ADT/DenseSet.h"
18-
#include "llvm/ADT/MapVector.h"
1918
#include "llvm/ADT/FunctionExtras.h"
2019
#include "llvm/ADT/STLExtras.h"
2120
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
@@ -854,7 +853,7 @@ class SectionRange {
854853

855854
class LinkGraph {
856855
private:
857-
using SectionMap = MapVector<StringRef, std::unique_ptr<Section>>;
856+
using SectionMap = DenseMap<StringRef, std::unique_ptr<Section>>;
858857
using ExternalSymbolMap = StringMap<Symbol *>;
859858
using AbsoluteSymbolSet = DenseSet<Symbol *>;
860859
using BlockSet = DenseSet<Block *>;
@@ -1596,7 +1595,7 @@ class LinkGraph {
15961595
unsigned PointerSize;
15971596
llvm::endianness Endianness;
15981597
GetEdgeKindNameFunction GetEdgeKindName = nullptr;
1599-
MapVector<StringRef, std::unique_ptr<Section>> Sections;
1598+
DenseMap<StringRef, std::unique_ptr<Section>> Sections;
16001599
ExternalSymbolMap ExternalSymbols;
16011600
AbsoluteSymbolSet AbsoluteSymbols;
16021601
orc::shared::AllocActions AAs;

llvm/lib/ExecutionEngine/JITLink/JITLink.cpp

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

294-
for (auto &Sec : sections()) {
295-
OS << "section " << Sec.getName() << ":\n\n";
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";
296303

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

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

+2-2
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 parent:
11-
# CHECK-EMPTY:
1210
# CHECK-DAG: section child:
1311
# CHECK-EMPTY:
12+
# CHECK-DAG: section parent:
13+
# CHECK-EMPTY:
1414

1515
--- !COFF
1616
header:

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#
99
# CHECK: section .func:
1010
# CHECK-EMPTY:
11-
# CHECK-NEXT: section .xdata:
12-
# CHECK-EMPTY:
1311
# CHECK-NEXT: section .pdata:
12+
# CHECK-EMPTY:
13+
# CHECK: section .xdata:
1414
# CHECK-EMPTY:
1515

1616
.text

0 commit comments

Comments
 (0)