[llvm] [llvm-gsymutil] Don't warn about duplicate debug info for merged functions (PR #122973)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 17 09:19:43 PST 2025
https://github.com/alx32 updated https://github.com/llvm/llvm-project/pull/122973
>From 16c325aa48ffc3848080141186d90569f85f0e9b Mon Sep 17 00:00:00 2001
From: Alex Borcan <alexborcan at fb.com>
Date: Tue, 14 Jan 2025 13:31:24 -0800
Subject: [PATCH 1/3] [llvm-gsymutil] Don't warn about duplicate debug info for
merged functions
---
.../include/llvm/DebugInfo/GSYM/GsymCreator.h | 10 +++++++--
llvm/lib/DebugInfo/GSYM/GsymCreator.cpp | 21 ++++++++++++-------
.../ARM_AArch64/macho-merged-funcs-dwarf.yaml | 6 ++++--
llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp | 2 +-
4 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
index 0d098da96dd278..4433111327d67a 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
@@ -147,7 +147,8 @@ class GsymCreator {
bool IsSegment = false;
bool Finalized = false;
bool Quiet;
-
+ // Specifies weather the input might contain merged functions
+ bool InputHasMergedFunctions;
/// Get the first function start address.
///
@@ -292,7 +293,12 @@ class GsymCreator {
}
public:
- GsymCreator(bool Quiet = false);
+ /// Construct a GsymCreator object.
+ ///
+ /// \param Quiet Whether to suppress warning messages
+ /// \param InputHasMergedFunctions Weather the input might contain merged
+ /// functions - functions with identical address ranges.
+ GsymCreator(bool Quiet = false, bool InputHasMergedFunctions = false);
/// Save a GSYM file to a stand alone file.
///
diff --git a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
index 14078f5aaf9a46..8c8892cace8538 100644
--- a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
+++ b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
@@ -21,8 +21,9 @@
using namespace llvm;
using namespace gsym;
-GsymCreator::GsymCreator(bool Quiet)
- : StrTab(StringTableBuilder::ELF), Quiet(Quiet) {
+GsymCreator::GsymCreator(bool Quiet, bool InputHasMergedFunctions)
+ : StrTab(StringTableBuilder::ELF), Quiet(Quiet),
+ InputHasMergedFunctions(InputHasMergedFunctions) {
insertFile(StringRef());
}
@@ -314,12 +315,16 @@ llvm::Error GsymCreator::finalize(OutputAggregator &Out) {
std::swap(Prev, Curr);
}
} else {
- Out.Report("Overlapping function ranges", [&](raw_ostream &OS) {
- // print warnings about overlaps
- OS << "warning: function ranges overlap:\n"
- << Prev << "\n"
- << Curr << "\n";
- });
+ // Equal ranges are invalid only in the case where merged functions
+ // are not expected.
+ if (!InputHasMergedFunctions) {
+ Out.Report("Overlapping function ranges", [&](raw_ostream &OS) {
+ // print warnings about overlaps
+ OS << "warning: function ranges overlap:\n"
+ << Prev << "\n"
+ << Curr << "\n";
+ });
+ }
FinalizedFuncs.emplace_back(std::move(Curr));
}
} else {
diff --git a/llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-merged-funcs-dwarf.yaml b/llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-merged-funcs-dwarf.yaml
index 6bf359cbe1ee15..1fe0127bee3412 100644
--- a/llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-merged-funcs-dwarf.yaml
+++ b/llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-merged-funcs-dwarf.yaml
@@ -1,16 +1,18 @@
# RUN: yaml2obj %s -o %t.dSYM
## Verify that we don't keep merged functions by default
-# RUN: llvm-gsymutil --num-threads=1 --convert %t.dSYM --out-file=%t.default.gSYM
+# RUN: llvm-gsymutil --num-threads=1 --convert %t.dSYM --out-file=%t.default.gSYM | FileCheck --check-prefix=CHECK-GSYM-CREATE-NOMERGE %s
# RUN: llvm-gsymutil --verify --verbose %t.default.gSYM | FileCheck --check-prefix=CHECK-GSYM-DEFAULT %s
## Verify that we keep merged functions when specyfing --merged-functions
-# RUN: llvm-gsymutil --num-threads=1 --convert %t.dSYM --out-file=%t.keep.gSYM --merged-functions
+# RUN: llvm-gsymutil --num-threads=1 --convert %t.dSYM --out-file=%t.keep.gSYM --merged-functions | FileCheck --check-prefix=CHECK-GSYM-CREATE-MERGE %s
# RUN: llvm-gsymutil --verify --verbose %t.keep.gSYM | FileCheck --check-prefix=CHECK-GSYM-KEEP %s
## Note: For identical functions, the dSYM / gSYM cannot be counted on to be deterministic.
## So we can only match the general structure, not exact function names / offsets
+# CHECK-GSYM-CREATE-NOMERGE: warning: same address range contains different debug info.
+# CHECK-GSYM-CREATE-MERGE-NOT: warning: same address range contains different debug info.
# CHECK-GSYM-DEFAULT-NOT: Merged FunctionInfos
# CHECK-GSYM-DEFAULT: FunctionInfo @ 0x{{[0-9a-fA-F]+}}: [0x{{[0-9a-fA-F]+}} - 0x{{[0-9a-fA-F]+}}) "my_func_03"
diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
index 654da68bb69600..6cafe68aaca18e 100644
--- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
+++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
@@ -330,7 +330,7 @@ static llvm::Error handleObjectFile(ObjectFile &Obj, const std::string &OutFile,
auto ThreadCount =
NumThreads > 0 ? NumThreads : std::thread::hardware_concurrency();
- GsymCreator Gsym(Quiet);
+ GsymCreator Gsym(Quiet, UseMergedFunctions);
// See if we can figure out the base address for a given object file, and if
// we can, then set the base address to use to this value. This will ease
>From 0cf8f4fd9eebdd1e3ea4acab6efe7909483e2fb1 Mon Sep 17 00:00:00 2001
From: alx32 <103613512+alx32 at users.noreply.github.com>
Date: Fri, 17 Jan 2025 09:19:24 -0800
Subject: [PATCH 2/3] Update llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
Typo
Co-authored-by: Kyungwoo Lee <kyulee at meta.com>
---
llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
index 4433111327d67a..4d1173a34802d4 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
@@ -147,7 +147,7 @@ class GsymCreator {
bool IsSegment = false;
bool Finalized = false;
bool Quiet;
- // Specifies weather the input might contain merged functions
+ // Specifies whether the input might contain merged functions
bool InputHasMergedFunctions;
/// Get the first function start address.
>From 2db4c32b7262f80957cbbe16806de0f8a3ecf880 Mon Sep 17 00:00:00 2001
From: alx32 <103613512+alx32 at users.noreply.github.com>
Date: Fri, 17 Jan 2025 09:19:34 -0800
Subject: [PATCH 3/3] Update llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
Typo 2
Co-authored-by: Kyungwoo Lee <kyulee at meta.com>
---
llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
index 4d1173a34802d4..beb6f6e5faf450 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
@@ -296,7 +296,7 @@ class GsymCreator {
/// Construct a GsymCreator object.
///
/// \param Quiet Whether to suppress warning messages
- /// \param InputHasMergedFunctions Weather the input might contain merged
+ /// \param InputHasMergedFunctions Whether the input might contain merged
/// functions - functions with identical address ranges.
GsymCreator(bool Quiet = false, bool InputHasMergedFunctions = false);
More information about the llvm-commits
mailing list