[lld] [lld-macho] Fix invalid DWARF with --icf=safe_thunks (PR #111097)
Kyungwoo Lee via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 4 16:46:45 PDT 2024
================
@@ -0,0 +1,115 @@
+; REQUIRES: aarch64
+
+;;; Build the
+; RUN: rm -rf %t; mkdir %t
+; RUN: llc -filetype=obj %s -O3 -o %t/icf-obj-safe-thunks-dwarf.o -enable-machine-outliner=never -mtriple arm64-apple-macos -addrsig
+; RUN: %lld -arch arm64 -lSystem --icf=safe_thunks -dylib -o %t/icf-safe-dwarf.dylib %t/icf-obj-safe-thunks-dwarf.o
+
+;;; Check that we generate valid dSYM
+; RUN: dsymutil %t/icf-safe-dwarf.dylib -o %t/icf-safe.dSYM
+; RUN: llvm-dwarfdump --verify %t/icf-safe.dSYM | FileCheck %s --check-prefix=VERIFY-DSYM
+; VERIFY-DSYM: No errors.
+
+;;; Check that we don't generate STABS entries (N_FUN) for ICF'ed function thunks
+; RUN: dsymutil -s %t/icf-safe-dwarf.dylib | FileCheck %s --check-prefix=VERIFY-STABS
+; VERIFY-STABS-NOT: N_FUN{{.*}}_func_B
+; VERIFY-STABS-NOT: N_FUN{{.*}}_func_C
+
+;;; Check that we do generate STABS entries (N_FUN) for non-ICF'ed functions
+; VERIFY-STABS: N_FUN{{.*}}_func_A
+; VERIFY-STABS: N_FUN{{.*}}_take_func_addr
+
+
+; ModuleID = 'icf-safe-thunks-dwarf.cpp'
+source_filename = "icf-safe-thunks-dwarf.cpp"
+target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128-Fn32"
+target triple = "arm64-apple-macosx11.0.0"
+
+; Function Attrs: mustprogress noinline nounwind optnone ssp uwtable(sync)
+define i32 @func_A() #0 !dbg !13 {
+entry:
+ ret i32 1
+}
+
+; Function Attrs: mustprogress noinline nounwind optnone ssp uwtable(sync)
+define i32 @func_B() #0 !dbg !18 {
+entry:
+ ret i32 1
+}
+
+; Function Attrs: mustprogress noinline nounwind optnone ssp uwtable(sync)
+define i32 @func_C() #0 !dbg !20 {
+entry:
+ ret i32 1
+}
+
+; Function Attrs: mustprogress noinline nounwind optnone ssp uwtable(sync)
+define i64 @take_func_addr() #0 !dbg !22 {
+entry:
+ %val = alloca i64, align 8
+ store i64 0, ptr %val, align 8
+ %0 = load i64, ptr %val, align 8
+ %add = add i64 %0, ptrtoint (ptr @func_A to i64)
+ store i64 %add, ptr %val, align 8
+ %1 = load i64, ptr %val, align 8
+ %add1 = add i64 %1, ptrtoint (ptr @func_B to i64)
+ store i64 %add1, ptr %val, align 8
+ %2 = load i64, ptr %val, align 8
+ %add2 = add i64 %2, ptrtoint (ptr @func_C to i64)
+ store i64 %add2, ptr %val, align 8
+ %3 = load i64, ptr %val, align 8
+ ret i64 %3
+}
+
+attributes #0 = { mustprogress noinline nounwind optnone ssp uwtable(sync) "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+altnzcv,+ccdp,+ccidx,+complxnum,+crc,+dit,+dotprod,+flagm,+fp-armv8,+fp16fml,+fptoint,+fullfp16,+jsconv,+lse,+neon,+pauth,+perfmon,+predres,+ras,+rcpc,+rdm,+sb,+sha2,+sha3,+specrestrict,+ssbs,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a,+zcm,+zcz" }
----------------
kyulee-com wrote:
I think many of these attributes are unnecessary.
https://github.com/llvm/llvm-project/pull/111097
More information about the llvm-commits
mailing list