llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Oliver Hunt (ojhunt) <details> <summary>Changes</summary> Under the c++ relative vtable abi vtable slots are only 32 bits so cannot be signed. --- Full diff: https://github.com/llvm/llvm-project/pull/244800.diff 3 Files Affected: - (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1) - (modified) clang/lib/Frontend/CompilerInvocation.cpp (+5-3) - (added) clang/test/CodeGenCXX/RelativeVTablesABI/ptrauth-virtual-function-call.cpp (+16) ``````````diff diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 3fbee4dc6bb031..1bb3682c0c69b9 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -2300,6 +2300,7 @@ CGCallee ItaniumCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF, CGPointerAuthInfo PointerAuth; if (Schema) { + assert(!CGM.getLangOpts().RelativeCXXABIVTables); assert(VTableSlotPtr && "virtual function pointer not set"); GD = CGM.getItaniumVTableContext().findOriginalMethod(GD.getCanonicalDecl()); PointerAuth = CGF.EmitPointerAuthInfo(Schema, VTableSlotPtr, GD, QualType()); diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 9af6f6c41eb756..e4aa33ced0ded1 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1506,9 +1506,11 @@ void CompilerInvocation::setDefaultPointerAuthOptions( else Opts.CXXVTTVTablePointers = PointerAuthSchema(Key::ASDA, false, Discrimination::None); - - Opts.CXXVirtualFunctionPointers = Opts.CXXVirtualVariadicFunctionPointers = - PointerAuthSchema(Key::ASIA, true, Discrimination::Decl); + if (!LangOpts.RelativeCXXABIVTables) { + Opts.CXXVirtualFunctionPointers = + Opts.CXXVirtualVariadicFunctionPointers = + PointerAuthSchema(Key::ASIA, true, Discrimination::Decl); + } Opts.CXXMemberFunctionPointers = PointerAuthSchema(Key::ASIA, false, Discrimination::Type); diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/ptrauth-virtual-function-call.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/ptrauth-virtual-function-call.cpp new file mode 100644 index 00000000000000..a4dcf778df3c80 --- /dev/null +++ b/clang/test/CodeGenCXX/RelativeVTablesABI/ptrauth-virtual-function-call.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s -triple arm64-apple-ios -fptrauth-calls -fexperimental-relative-c++-abi-vtables -emit-llvm -o - | FileCheck %s + +// CHECK-LABEL: define{{.*}} void @_Z8call_fooP1A( +// CHECK: [[THIS:%.*]] = load ptr, ptr %a.addr +// CHECK: [[VTABLE:%.*]] = load ptr, ptr [[THIS]] +// CHECK: [[VTABLE_INT:%.*]] = ptrtoint ptr [[VTABLE]] to i64 +// CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLE_INT]], i32 2, i64 0) +// CHECK: [[VTABLE_AUTH:%.*]] = inttoptr i64 [[AUTH]] to ptr +// CHECK: [[FN:%.*]] = call ptr @llvm.load.relative.i32(ptr [[VTABLE_AUTH]], i32 0) +// CHECK: call void [[FN]](ptr {{.*}}[[THIS]]){{$}} + +struct A { + virtual void foo(); +}; + +void call_foo(A *a) { a->foo(); } `````````` </details> https://github.com/llvm/llvm-project/pull/244800 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
