Revert "Revert "[JITLink] Use MapVector to stabilize iteration order""

This reverts commit 244ea40625 while I test a fix
for a build failure: https://lab.llvm.org/buildbot/#/builders/174/builds/7685.
This commit is contained in:
Lang Hames
2024-10-31 19:18:34 -07:00
parent 466b58ba38
commit 0019d06185
4 changed files with 10 additions and 16 deletions

View File

@@ -15,6 +15,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
@@ -853,7 +854,7 @@ private:
class LinkGraph {
private:
using SectionMap = DenseMap<StringRef, std::unique_ptr<Section>>;
using SectionMap = MapVector<StringRef, std::unique_ptr<Section>>;
using ExternalSymbolMap = StringMap<Symbol *>;
using AbsoluteSymbolSet = DenseSet<Symbol *>;
using BlockSet = DenseSet<Block *>;
@@ -1595,7 +1596,7 @@ private:
unsigned PointerSize;
llvm::endianness Endianness;
GetEdgeKindNameFunction GetEdgeKindName = nullptr;
DenseMap<StringRef, std::unique_ptr<Section>> Sections;
MapVector<StringRef, std::unique_ptr<Section>> Sections;
ExternalSymbolMap ExternalSymbols;
AbsoluteSymbolSet AbsoluteSymbols;
orc::shared::AllocActions AAs;

View File

@@ -291,18 +291,11 @@ void LinkGraph::dump(raw_ostream &OS) {
return false;
});
std::vector<Section *> SortedSections;
for (auto &Sec : sections())
SortedSections.push_back(&Sec);
llvm::sort(SortedSections, [](const Section *LHS, const Section *RHS) {
return LHS->getName() < RHS->getName();
});
for (auto *Sec : SortedSections) {
OS << "section " << Sec->getName() << ":\n\n";
for (auto &Sec : sections()) {
OS << "section " << Sec.getName() << ":\n\n";
std::vector<Block *> SortedBlocks;
llvm::copy(Sec->blocks(), std::back_inserter(SortedBlocks));
llvm::copy(Sec.blocks(), std::back_inserter(SortedBlocks));
llvm::sort(SortedBlocks, [](const Block *LHS, const Block *RHS) {
return LHS->getAddress() < RHS->getAddress();
});

View File

@@ -7,10 +7,10 @@
# parent block is dead.
#
# CHECK: Link graph
# CHECK-DAG: section child:
# CHECK-EMPTY:
# CHECK-DAG: section parent:
# CHECK-EMPTY:
# CHECK-DAG: section child:
# CHECK-EMPTY:
--- !COFF
header:

View File

@@ -8,9 +8,9 @@
#
# CHECK: section .func:
# CHECK-EMPTY:
# CHECK-NEXT: section .pdata:
# CHECK-NEXT: section .xdata:
# CHECK-EMPTY:
# CHECK: section .xdata:
# CHECK-NEXT: section .pdata:
# CHECK-EMPTY:
.text