https://github.com/atrosinenko created
https://github.com/llvm/llvm-project/pull/179688
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").
>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] [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)();
+}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits