[lld] [lld-macho] Fix invalid DWARF with --icf=safe_thunks (PR #111097)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 10:27:38 PDT 2024


================
@@ -49,127 +62,179 @@
 ; CHECK-ARM64-MAP-NEXT: 0x00000004 [  2] _func_3identical_v2
 ; CHECK-ARM64-MAP-NEXT: 0x00000004 [  2] _func_3identical_v3
 
+; ModuleID = 'icf-safe-thunks.cpp'
+source_filename = "icf-safe-thunks.cpp"
 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128-Fn32"
 target triple = "arm64-apple-macosx11.0.0"
-
- at g_val = global i8 0, align 1
- at g_ptr = global ptr null, align 8
-
+ at g_val = global i8 0, align 1, !dbg !0
+ at g_ptr = global ptr null, align 8, !dbg !7
 ; Function Attrs: mustprogress nofree noinline norecurse nounwind ssp memory(readwrite, argmem: none) uwtable(sync)
-define void @func_unique_1() #0 {
+define void @func_unique_1() #0 !dbg !19 {
----------------
alx32 wrote:

Tried for a while but it's very tricky manually editing out the debug info and still getting a valid dSYM that gives us the info we want. We don't typically edit out debug info as it's tricky to get it right. 

Does the (commented) source code at the bottom help understanding the test ? I think that would be a better guide, the only reason we include .ll here is because we can't invoke clang - otherwise the test would just be the C++ code.

On the C++ part the only thing that changed about the code is the addition of `-g` to the clang compile side. If needing to further investigate stripping debug info - is there any in particular that you had in mind ? 



https://github.com/llvm/llvm-project/pull/111097


More information about the llvm-commits mailing list