[clang] [AArch64][PAC] Emit `!dbg` locations in `*_vfpthunk_` functions (PR #179688)
Anatoly Trosinenko via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 7 05:18:56 PST 2026
================
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
+// RUN: -emit-llvm -std=c++11 -O1 -disable-llvm-passes \
+// RUN: -debug-info-kind=limited %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
+// RUN: -emit-llvm -std=c++11 -O1 -disable-llvm-passes \
+// RUN: -debug-info-kind=limited %s -o - | FileCheck %s
+
+// Check that compiler-generated *_vfpthunk_ function has a !dbg location
+// attached to the call instruction.
+
+// CHECK: define {{.*}}@_ZN1A2f0Ev_vfpthunk_{{.*}} !dbg
+// CHECK-NOT: define
+// CHECK: musttail call void %{{[0-9]+}}(ptr
+// CHECK-SAME: [ "ptrauth"(i32 0, i64 %{{[0-9]+}}) ]
+// CHECK-SAME: !dbg
----------------
atrosinenko wrote:
Added more checks in ee7d2b7b55056ebda02e6ac438d6173ab62f1a76, thank you.
For the record, here is the code that is generated for both triples (except for the difference in the particular metadata indices):
```llvm
define linkonce_odr hidden void @_ZN1A2f0Ev_vfpthunk_(ptr noundef %this) #3 !dbg !63 {
entry:
%this.addr = alloca ptr, align 8
store ptr %this, ptr %this.addr, align 8, !tbaa !58
%this1 = load ptr, ptr %this.addr, align 8, !dbg !65
%0 = load ptr, ptr %this.addr, align 8, !dbg !65, !tbaa !58
%vtable = load ptr, ptr %this1, align 8, !dbg !65, !tbaa !49
%1 = ptrtoint ptr %vtable to i64, !dbg !65
%2 = call i64 @llvm.ptrauth.auth(i64 %1, i32 2, i64 0), !dbg !65
%3 = inttoptr i64 %2 to ptr, !dbg !65
%vfn = getelementptr inbounds ptr, ptr %3, i64 0, !dbg !65
%4 = load ptr, ptr %vfn, align 8, !dbg !65
%5 = ptrtoint ptr %vfn to i64, !dbg !65
%6 = call i64 @llvm.ptrauth.blend(i64 %5, i64 9385), !dbg !65
musttail call void %4(ptr noundef nonnull align 8 dereferenceable(8) %0) [ "ptrauth"(i32 0, i64 %6) ], !dbg !65
ret void, !dbg !65
7: ; No predecessors!
ret void, !dbg !65
8: ; No predecessors!
ret void, !dbg !65
}
```
That is, `alloca` and `store` has no `!dbg` attached, all other instructions refer to `!65` and the function itself refers to `!63`. Here are metadata nodes:
```llvm
!63 = distinct !DISubprogram(linkageName: "_ZN1A2f0Ev_vfpthunk_", scope: !10, file: !10, line: 28, type: !64, flags: DIFlagArtificial | DIFlagThunk, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
!64 = !DISubroutineType(types: !51)
!65 = !DILocation(line: 0, scope: !63)
```
https://github.com/llvm/llvm-project/pull/179688
More information about the cfe-commits
mailing list