https://github.com/atrosinenko updated https://github.com/llvm/llvm-project/pull/179688
>From 6e4c7879cf1504e0faadf88aab4fdc21f2469226 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko <[email protected]> Date: Wed, 4 Feb 2026 15:37:50 +0300 Subject: [PATCH 1/2] [AArch64][PAC] Emit `!dbg` locations in `*_vfpthunk_` functions In absence of `!dbg` metadata, it is possible for indirect authenticated call to be replaced with a direct call instruction without `!dbg` metadata. This may result in an error reported by LLVM IR verifier ("inlinable function call in a function with debug info must have a !dbg location") or an assertion triggered after inlining this call ("!dbg attachment points at wrong subprogram for function"). --- clang/lib/CodeGen/ItaniumCXXABI.cpp | 4 +++ ...auth-member-function-pointer-debuglocs.cpp | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 clang/test/DebugInfo/CXX/ptrauth-member-function-pointer-debuglocs.cpp diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index a6c80cd083bb8..63cb4b6989917 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3479,6 +3479,10 @@ ItaniumCXXABI::getOrCreateVirtualFunctionPointerThunk(const CXXMethodDecl *MD) { CGF.StartFunction(GlobalDecl(), FnInfo.getReturnType(), ThunkFn, FnInfo, FunctionArgs, MD->getLocation(), SourceLocation()); + + // Emit an artificial location for this function. + auto AL = ApplyDebugLocation::CreateArtificial(CGF); + llvm::Value *ThisVal = loadIncomingCXXThis(CGF); setCXXABIThisValue(CGF, ThisVal); diff --git a/clang/test/DebugInfo/CXX/ptrauth-member-function-pointer-debuglocs.cpp b/clang/test/DebugInfo/CXX/ptrauth-member-function-pointer-debuglocs.cpp new file mode 100644 index 0000000000000..cfc10a5207087 --- /dev/null +++ b/clang/test/DebugInfo/CXX/ptrauth-member-function-pointer-debuglocs.cpp @@ -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 + +volatile long T; + +struct A { + virtual void f0() { + T = 0; + } +}; +typedef void (A::*MFP)(); + +void caller() { + A a; + + MFP x = &A::f0; + (a.*x)(); +} >From ee7d2b7b55056ebda02e6ac438d6173ab62f1a76 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko <[email protected]> Date: Sat, 7 Feb 2026 15:51:38 +0300 Subject: [PATCH 2/2] Address review comments --- .../ptrauth-member-function-pointer-debuglocs.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/clang/test/DebugInfo/CXX/ptrauth-member-function-pointer-debuglocs.cpp b/clang/test/DebugInfo/CXX/ptrauth-member-function-pointer-debuglocs.cpp index cfc10a5207087..c1fcb2f9dd5fb 100644 --- a/clang/test/DebugInfo/CXX/ptrauth-member-function-pointer-debuglocs.cpp +++ b/clang/test/DebugInfo/CXX/ptrauth-member-function-pointer-debuglocs.cpp @@ -8,11 +8,19 @@ // Check that compiler-generated *_vfpthunk_ function has a !dbg location // attached to the call instruction. -// CHECK: define {{.*}}@_ZN1A2f0Ev_vfpthunk_{{.*}} !dbg +// CHECK: define {{.*}}@_ZN1A2f0Ev_vfpthunk_({{.*}}) +// CHECK-SAME: !dbg ![[SCOPE_INDEX:[0-9]+]] +// CHECK-NOT: define +// CHECK: %[[DISCR:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %{{[0-9]+}}, i64 9385) // CHECK-NOT: define // CHECK: musttail call void %{{[0-9]+}}(ptr -// CHECK-SAME: [ "ptrauth"(i32 0, i64 %{{[0-9]+}}) ] -// CHECK-SAME: !dbg +// CHECK-SAME: [ "ptrauth"(i32 0, i64 %[[DISCR]]) ] +// CHECK-SAME: !dbg ![[LOCATION_INDEX:[0-9]+]] + +// CHECK: ![[SCOPE_INDEX]] = distinct !DISubprogram( +// CHECK-SAME: linkageName: "_ZN1A2f0Ev_vfpthunk_" +// CHECK-SAME: flags: DIFlagArtificial | DIFlagThunk +// CHECK: ![[LOCATION_INDEX]] = !DILocation(line: 0, scope: ![[SCOPE_INDEX]]) volatile long T; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
