[llvm] Use MapVector to fix lld thinLTO "nondeterminism" issue. (PR #117551)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 2 11:01:45 PST 2024


https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/117551

>From 56e28a917cb74296917e77dc6dc6b03d32f6e256 Mon Sep 17 00:00:00 2001
From: shaosenhao <shaosenhao at huawei.com>
Date: Mon, 2 Dec 2024 17:42:35 +0800
Subject: [PATCH 1/2]     Use MapVector to fix lld thinLTO nondeterminism
 issue.

    When the ModuleSymbolTable is generated, the
    binary consistency problem occurs due to the
    unorder of the data structure when collecting
    asm symbols.
---
 llvm/lib/Object/RecordStreamer.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Object/RecordStreamer.h b/llvm/lib/Object/RecordStreamer.h
index 70b41f270720b4..73278dd67545b6 100644
--- a/llvm/lib/Object/RecordStreamer.h
+++ b/llvm/lib/Object/RecordStreamer.h
@@ -11,6 +11,7 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/MC/MCDirectives.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/Support/SMLoc.h"
@@ -32,7 +33,7 @@ class RecordStreamer : public MCStreamer {
   // Map of aliases created by .symver directives, saved so we can update
   // their symbol binding after parsing complete. This maps from each
   // aliasee to its list of aliases.
-  DenseMap<const MCSymbol *, std::vector<StringRef>> SymverAliasMap;
+  MapVector<const MCSymbol *, std::vector<StringRef>> SymverAliasMap;
 
   /// Get the state recorded for the given symbol.
   State getSymbolState(const MCSymbol *Sym);

>From 5afae5c46247ea13c4263543f534532e0c225e38 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at gmail.com>
Date: Mon, 2 Dec 2024 11:01:36 -0800
Subject: [PATCH 2/2] Order includes

---
 llvm/lib/Object/RecordStreamer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Object/RecordStreamer.h b/llvm/lib/Object/RecordStreamer.h
index 73278dd67545b6..d9ef27c7901683 100644
--- a/llvm/lib/Object/RecordStreamer.h
+++ b/llvm/lib/Object/RecordStreamer.h
@@ -10,8 +10,8 @@
 #define LLVM_LIB_OBJECT_RECORDSTREAMER_H
 
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/MC/MCDirectives.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/Support/SMLoc.h"



More information about the llvm-commits mailing list