[llvm] 244ea40 - Revert "[JITLink] Use MapVector to stabilize iteration order"
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 10:50:31 PDT 2024
Author: Lang Hames
Date: 2024-11-01T04:50:24+11:00
New Revision: 244ea4062590b4fbda56bbae6cd3700159db19bf
URL: https://github.com/llvm/llvm-project/commit/244ea4062590b4fbda56bbae6cd3700159db19bf
DIFF: https://github.com/llvm/llvm-project/commit/244ea4062590b4fbda56bbae6cd3700159db19bf.diff
LOG: 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.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
llvm/test/ExecutionEngine/JITLink/x86-64/COFF_comdat_associative_dead_strip.test
llvm/test/ExecutionEngine/JITLink/x86-64/COFF_pdata_strip.s
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
index e8a971bbfd2cb6..75dcd9f597b2c8 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 @@ class SectionRange {
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 @@ class LinkGraph {
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 45ae70113aa26c..ef382c3ce695a9 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 99f4d7a41bbcb1..29cac33c3e6f76 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 e3a752df471c24..06e81fc9694e79 100644
--- a/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_pdata_strip.s
+++ b/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_pdata_strip.s
@@ -8,9 +8,9 @@
#
# CHECK: section .func:
# CHECK-EMPTY:
-# CHECK-NEXT: section .xdata:
-# CHECK-EMPTY:
# CHECK-NEXT: section .pdata:
+# CHECK-EMPTY:
+# CHECK: section .xdata:
# CHECK-EMPTY:
.text
More information about the llvm-commits
mailing list