llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-codegen
Author: Anatoly Trosinenko (atrosinenko)
<details>
<summary>Changes</summary>
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").
---
Full diff: https://github.com/llvm/llvm-project/pull/179688.diff
2 Files Affected:
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+4)
- (added)
clang/test/DebugInfo/CXX/ptrauth-member-function-pointer-debuglocs.cpp (+31)
``````````diff
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)();
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/179688
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits