[llvm] [LLVM][DWARF] Fix uniquness of AccelTable Values (PR #74391)
Alexander Yermolovich via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 4 15:58:29 PST 2023
https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/74391
The finalize function sorts by order, which is DieOffset. It then uses erase in
combination of std::unique to remove duplicates, but it doesn't specify
comparison function. So pointer addresses are used. Presumably it should also use
order() for compare?
>From 209f01bbbe8d726d59c5687a48f921932148ed68 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich <ayermolo at meta.com>
Date: Mon, 4 Dec 2023 15:53:53 -0800
Subject: [PATCH] [LLVM][DWARF] Fix uniquness of AccelTable Values
The finalize function sorts by order, which is DieOffset. It then uses erase in
combination of std::unique to remove duplicates, but it doesn't specify
comparison function. Presumably it should also use order() for compare?
---
llvm/include/llvm/CodeGen/AccelTable.h | 4 ++++
llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp | 5 ++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h
index 0f35fd3514fae..404d6f0baf8d3 100644
--- a/llvm/include/llvm/CodeGen/AccelTable.h
+++ b/llvm/include/llvm/CodeGen/AccelTable.h
@@ -120,6 +120,10 @@ class AccelTableData {
return order() < Other.order();
}
+ bool operator==(const AccelTableData &Other) const {
+ return order() == Other.order();
+ }
+
// Subclasses should implement:
// static uint32_t hash(StringRef Name);
diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
index d6f487c18b030..801fa558dac8e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
@@ -59,7 +59,10 @@ void AccelTableBase::finalize(AsmPrinter *Asm, StringRef Prefix) {
return *A < *B;
});
E.second.Values.erase(
- std::unique(E.second.Values.begin(), E.second.Values.end()),
+ std::unique(E.second.Values.begin(), E.second.Values.end(),
+ [](const AccelTableData *A, const AccelTableData *B) {
+ return *A == *B;
+ }),
E.second.Values.end());
}
More information about the llvm-commits
mailing list