diff options
author | Lang Hames <lhames@gmail.com> | 2024-11-01 04:27:45 +1100 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2024-11-01 04:50:24 +1100 |
commit | 244ea4062590b4fbda56bbae6cd3700159db19bf (patch) | |
tree | 5351b53b426d18dd3f36fef8099cdf5b7ea8e00d | |
parent | e05def081e43f8fe8be7f3a4ed2749ae01ab0ab3 (diff) | |
download | llvm-244ea4062590b4fbda56bbae6cd3700159db19bf.zip llvm-244ea4062590b4fbda56bbae6cd3700159db19bf.tar.gz llvm-244ea4062590b4fbda56bbae6cd3700159db19bf.tar.bz2 |
Revert "[JITLink] Use MapVector to stabilize iteration order"
This reverts commit f8f4235612b9668bbcbb6a58634fcb756794045e 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.
4 files changed, 16 insertions, 10 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h index e8a971b..75dcd9f 100644 --- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h +++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h @@ -15,7 +15,6 @@ #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" @@ -854,7 +853,7 @@ private: class LinkGraph { private: - using SectionMap = MapVector<StringRef, std::unique_ptr<Section>>; + using SectionMap = DenseMap<StringRef, std::unique_ptr<Section>>; using ExternalSymbolMap = StringMap<Symbol *>; using AbsoluteSymbolSet = DenseSet<Symbol *>; using BlockSet = DenseSet<Block *>; @@ -1596,7 +1595,7 @@ private: unsigned PointerSize; llvm::endianness Endianness; GetEdgeKindNameFunction GetEdgeKindName = nullptr; - MapVector<StringRef, std::unique_ptr<Section>> Sections; + DenseMap<StringRef, std::unique_ptr<Section>> Sections; ExternalSymbolMap ExternalSymbols; AbsoluteSymbolSet AbsoluteSymbols; orc::shared::AllocActions AAs; diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp index 45ae701..ef382c3 100644 --- a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp @@ -291,11 +291,18 @@ void LinkGraph::dump(raw_ostream &OS) { return false; }); - for (auto &Sec : sections()) { - OS << "section " << Sec.getName() << ":\n\n"; + 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"; 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(); }); diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_comdat_associative_dead_strip.test b/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_comdat_associative_dead_strip.test index 99f4d7a41..29cac33 100644 --- a/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_comdat_associative_dead_strip.test +++ b/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_comdat_associative_dead_strip.test @@ -7,10 +7,10 @@ # parent block is dead. # # CHECK: Link graph -# CHECK-DAG: section parent: -# CHECK-EMPTY: # CHECK-DAG: section child: # CHECK-EMPTY: +# CHECK-DAG: section parent: +# CHECK-EMPTY: --- !COFF header: diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_pdata_strip.s b/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_pdata_strip.s index e3a752d..06e81fc 100644 --- a/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_pdata_strip.s +++ b/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_pdata_strip.s @@ -8,10 +8,10 @@ # # CHECK: section .func: # CHECK-EMPTY: -# CHECK-NEXT: section .xdata: -# CHECK-EMPTY: # CHECK-NEXT: section .pdata: # CHECK-EMPTY: +# CHECK: section .xdata: +# CHECK-EMPTY: .text |