From 2e17b8a1cca44c57722290567db0e4aba98272c0 Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Fri, 19 Jul 2024 09:47:47 +0300 Subject: [PATCH] [test][PAC][clang] Add missing tests against linux triples (#99482) Summary: Enhance tests introduced in #94056, #96992, #98276 and #98847 by adding RUN and CHECK lines against linux triples. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251378 --- .../ptrauth-function-lvalue-cast-disc.c | 10 +-- ...ptrauth-function-type-discriminator-cast.c | 32 ++++++--- .../ptrauth-function-type-discriminator.c | 33 ++++++--- clang/test/CodeGen/ptrauth-ubsan-vptr.cpp | 3 + ...trauth-explicit-vtable-pointer-control.cpp | 62 ++++++++++------- clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp | 14 ++-- .../CodeGenCXX/ptrauth-static-destructors.cpp | 15 ++-- clang/test/CodeGenCXX/ptrauth-throw.cpp | 15 ++-- clang/test/CodeGenCXX/ptrauth-thunks.cpp | 3 +- .../CodeGenCXX/ptrauth-virtual-function.cpp | 69 +++++++++++-------- ...rauth-vtable-virtual-inheritance-thunk.cpp | 20 ++++-- clang/test/CodeGenCXX/ubsan-vtable-checks.cpp | 4 +- ...irtual-member-function-return-arg-type.cpp | 3 +- ...table_pointer_authentication_attribute.cpp | 3 +- 14 files changed, 185 insertions(+), 101 deletions(-) diff --git a/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c b/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c index 7d76649e2e49c0..40bba99478192e 100644 --- a/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c +++ b/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c @@ -1,12 +1,14 @@ // RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- -fptrauth-function-pointer-type-discrimination | FileCheck -check-prefixes CHECK,TYPE %s +// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- -fptrauth-function-pointer-type-discrimination | FileCheck -check-prefixes CHECK,TYPE %s // RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck -check-prefixes CHECK,ZERO %s +// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck -check-prefixes CHECK,ZERO %s typedef void (*fptr_t)(void); char *cptr; void (*fptr)(void); -// CHECK-LABEL: define void @test1 +// CHECK-LABEL: define{{.*}} void @test1 void test1() { // TYPE: [[LOAD:%.*]] = load ptr, ptr @cptr // TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64 @@ -17,7 +19,7 @@ void test1() { (*(fptr_t)cptr)(); } -// CHECK-LABEL: define i8 @test2 +// CHECK-LABEL: define{{.*}} i8 @test2 char test2() { return *(char *)fptr; @@ -35,7 +37,7 @@ char test2() { // ZERO-NOT: @llvm.ptrauth.resign } -// CHECK-LABEL: define void @test4 +// CHECK-LABEL: define{{.*}} void @test4 void test4() { (*((fptr_t)(&*((char *)(&*(fptr_t)cptr)))))(); @@ -49,7 +51,7 @@ void test4() { } void *vptr; -// CHECK-LABEL: define void @test5 +// CHECK-LABEL: define{{.*}} void @test5 void test5() { vptr = &*(char *)fptr; diff --git a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c index cdf9ee4907525f..1a1dce6f4a66e0 100644 --- a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c +++ b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c @@ -1,6 +1,20 @@ -// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,TYPE -// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,ZERO -// RUN: %clang_cc1 -xc++ %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,CHECKCXX,TYPE,TYPECXX +// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,TYPE + +// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,TYPE + +// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,ZERO + +// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,ZERO + +// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm -xc++ -o- | FileCheck %s --check-prefixes=CHECK,CHECKCXX,TYPE,TYPECXX + +// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm -xc++ -o- | FileCheck %s --check-prefixes=CHECK,CHECKCXX,TYPE,TYPECXX #ifdef __cplusplus extern "C" { @@ -19,12 +33,12 @@ struct ptr_member { ptr_member pm; void (*test_member)() = (void (*)())pm.fptr_; -// CHECKCXX-LABEL: define internal void @__cxx_global_var_init +// CHECKCXX-LABEL: define{{.*}} internal void @__cxx_global_var_init // TYPECXX: call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 2712, i32 0, i64 18983) #endif -// CHECK-LABEL: define void @test_cast_to_opaque +// CHECK-LABEL: define{{.*}} void @test_cast_to_opaque void test_cast_to_opaque() { opaque = (void *)f; @@ -33,7 +47,7 @@ void test_cast_to_opaque() { // ZERO-NOT: @llvm.ptrauth.resign } -// CHECK-LABEL: define void @test_cast_from_opaque +// CHECK-LABEL: define{{.*}} void @test_cast_from_opaque void test_cast_from_opaque() { fptr = (void (*)(void))opaque; @@ -48,7 +62,7 @@ void test_cast_from_opaque() { // ZERO-NOT: @llvm.ptrauth.resign } -// CHECK-LABEL: define void @test_cast_to_intptr +// CHECK-LABEL: define{{.*}} void @test_cast_to_intptr void test_cast_to_intptr() { uintptr = (unsigned long)fptr; @@ -69,14 +83,14 @@ void test_cast_to_intptr() { // ZERO-NOT: @llvm.ptrauth.resign } -// CHECK-LABEL: define void @test_function_to_function_cast +// CHECK-LABEL: define{{.*}} void @test_function_to_function_cast void test_function_to_function_cast() { void (*fptr2)(int) = (void (*)(int))fptr; // TYPE: call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 18983, i32 0, i64 2712) // ZERO-NOT: @llvm.ptrauth.resign } -// CHECK-LABEL: define void @test_call_lvalue_cast +// CHECK-LABEL: define{{.*}} void @test_call_lvalue_cast void test_call_lvalue_cast() { (*(void (*)(int))f)(42); diff --git a/clang/test/CodeGen/ptrauth-function-type-discriminator.c b/clang/test/CodeGen/ptrauth-function-type-discriminator.c index 5dea48fe5915b8..58717015adb6c8 100644 --- a/clang/test/CodeGen/ptrauth-function-type-discriminator.c +++ b/clang/test/CodeGen/ptrauth-function-type-discriminator.c @@ -1,7 +1,18 @@ -// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKC -// RUN: %clang_cc1 -xc++ %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefix=CHECK -// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-pch %s -o %t.ast -// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -x ast -o - %t.ast | FileCheck -check-prefix=CHECK --check-prefix=CHECKC %s +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm %s -o- | FileCheck --check-prefixes=CHECK,CHECKC %s +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm -xc++ %s -o- | FileCheck --check-prefix=CHECK %s +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-pch %s -o %t.ast +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -emit-llvm -x ast -o - %t.ast | FileCheck --check-prefixes=CHECK,CHECKC %s + +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm %s -o- | FileCheck --check-prefixes=CHECK,CHECKC %s +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -disable-llvm-passes -emit-llvm -xc++ %s -o- | FileCheck --check-prefix=CHECK %s +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-pch %s -o %t.ast +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -emit-llvm -x ast -o - %t.ast | FileCheck --check-prefixes=CHECK,CHECKC %s #ifdef __cplusplus extern "C" { @@ -47,14 +58,14 @@ void (*fptr3)(void) = __builtin_ptrauth_sign_constant(&external_function, 2, 26) // CHECK: @fptr4 = global ptr ptrauth (ptr @external_function, i32 2, i64 26, ptr @fptr4) void (*fptr4)(void) = __builtin_ptrauth_sign_constant(&external_function, 2, __builtin_ptrauth_blend_discriminator(&fptr4, 26)); -// CHECK-LABEL: define void @test_call() +// CHECK-LABEL: define{{.*}} void @test_call() void test_call() { // CHECK: [[T0:%.*]] = load ptr, ptr @fnptr, // CHECK-NEXT: call void [[T0]]() [ "ptrauth"(i32 0, i64 18983) ] fnptr(); } -// CHECK-LABEL: define ptr @test_function_pointer() +// CHECK-LABEL: define{{.*}} ptr @test_function_pointer() // CHECK: ret ptr ptrauth (ptr @external_function, i32 0, i64 18983) void (*test_function_pointer())(void) { return external_function; @@ -62,14 +73,14 @@ void (*test_function_pointer())(void) { struct InitiallyIncomplete; extern struct InitiallyIncomplete returns_initially_incomplete(void); -// CHECK-LABEL: define void @use_while_incomplete() +// CHECK-LABEL: define{{.*}} void @use_while_incomplete() void use_while_incomplete() { // CHECK: [[VAR:%.*]] = alloca ptr, // CHECK-NEXT: store ptr ptrauth (ptr @returns_initially_incomplete, i32 0, i64 25106), ptr [[VAR]] struct InitiallyIncomplete (*fnptr)(void) = &returns_initially_incomplete; } struct InitiallyIncomplete { int x; }; -// CHECK-LABEL: define void @use_while_complete() +// CHECK-LABEL: define{{.*}} void @use_while_complete() void use_while_complete() { // CHECK: [[VAR:%.*]] = alloca ptr, // CHECK-NEXT: store ptr ptrauth (ptr @returns_initially_incomplete, i32 0, i64 25106), ptr [[VAR]] @@ -83,7 +94,7 @@ void knr(param) int param; {} -// CHECKC-LABEL: define void @test_knr +// CHECKC-LABEL: define{{.*}} void @test_knr void test_knr() { void (*p)() = knr; p(0); @@ -94,7 +105,7 @@ void test_knr() { // CHECKC: call void [[LOAD]](i32 noundef 0) [ "ptrauth"(i32 0, i64 18983) ] } -// CHECKC-LABEL: define void @test_redeclaration +// CHECKC-LABEL: define{{.*}} void @test_redeclaration void test_redeclaration() { void redecl(); void (*ptr)() = redecl; @@ -113,7 +124,7 @@ void knr2(param) int param; {} -// CHECKC-LABEL: define void @test_redecl_knr +// CHECKC-LABEL: define{{.*}} void @test_redecl_knr void test_redecl_knr() { void (*p)() = knr2; p(); diff --git a/clang/test/CodeGen/ptrauth-ubsan-vptr.cpp b/clang/test/CodeGen/ptrauth-ubsan-vptr.cpp index 6c36004641477d..8045e7bdc74605 100644 --- a/clang/test/CodeGen/ptrauth-ubsan-vptr.cpp +++ b/clang/test/CodeGen/ptrauth-ubsan-vptr.cpp @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -triple arm64e-apple-ios15 -fsanitize=vptr -O0 -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple arm64e-apple-ios15 -fsanitize=vptr -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsanitize=vptr -O0 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsanitize=vptr -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s + struct S { S() {} ~S() {} diff --git a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp index e6497b3f152aa0..1b103719fbe46d 100644 --- a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp +++ b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp @@ -1,15 +1,31 @@ // RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \ // RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,NODISC %s -// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \ +// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \ // RUN: -fptrauth-vtable-pointer-type-discrimination \ // RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,TYPE %s -// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \ +// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \ // RUN: -fptrauth-vtable-pointer-address-discrimination \ // RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,ADDR %s -// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \ +// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -fptrauth-vtable-pointer-type-discrimination \ +// RUN: -fptrauth-vtable-pointer-address-discrimination \ +// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,BOTH %s + +// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,NODISC %s + +// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -fptrauth-vtable-pointer-type-discrimination \ +// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,TYPE %s + +// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ +// RUN: -fptrauth-vtable-pointer-address-discrimination \ +// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,ADDR %s + +// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \ // RUN: -fptrauth-vtable-pointer-type-discrimination \ // RUN: -fptrauth-vtable-pointer-address-discrimination \ // RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,BOTH %s @@ -111,7 +127,7 @@ int TVDisc_ExplicitNoExtraDiscrimination = ptrauth_string_discriminator("_ZTVN5t int TVDisc_ExplicitTypeDiscrimination = ptrauth_string_discriminator("_ZTVN5test126ExplicitTypeDiscriminationE"); -// CHECK-LABEL: define void @test_default(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_default(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = load ptr, ptr {{%.*}}, align 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -133,7 +149,7 @@ void test_default(NoExplicitAuth *a) { a->f(); } -// CHECK-LABEL: define void @test_disabled(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_disabled(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = load ptr, ptr {{%.*}}, align 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // CHECK-NOT: call i64 @llvm.ptrauth.auth @@ -141,7 +157,7 @@ void test_disabled(ExplicitlyDisableAuth *a) { a->f(); } -// CHECK-LABEL: define void @test_addr_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_addr_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = load ptr, ptr {{%.*}}, align 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -166,7 +182,7 @@ void test_addr_disc(ExplicitAddressDiscrimination *a) { a->f(); } -// CHECK-LABEL: define void @test_no_addr_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_no_addr_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = load ptr, ptr {{%.*}}, align 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -185,7 +201,7 @@ void test_no_addr_disc(ExplicitNoAddressDiscrimination *a) { a->f(); } -// CHECK-LABEL: define void @test_no_extra_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_no_extra_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = load ptr, ptr {{%.*}}, align 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -206,7 +222,7 @@ void test_no_extra_disc(ExplicitNoExtraDiscrimination *a) { a->f(); } -// CHECK-LABEL: define void @test_type_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_type_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = load ptr, ptr {{%.*}}, align 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -229,7 +245,7 @@ void test_type_disc(ExplicitTypeDiscrimination *a) { a->f(); } -// CHECK-LABEL: define void @test_custom_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_custom_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = load ptr, ptr {{%.*}}, align 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -257,7 +273,7 @@ void test_custom_disc(ExplicitCustomDiscrimination *a) { // Codegen should be the same as the simple cases above once we have a vtable. // -// CHECK-LABEL: define void @test_subclass_default(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_subclass_default(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = call noundef ptr @_ZN5test113make_subclass // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -279,7 +295,7 @@ void test_subclass_default(NoExplicitAuth *a) { make_subclass(a)->f(); } -// CHECK-LABEL: define void @test_subclass_disabled(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_subclass_disabled(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = call noundef ptr @_ZN5test113make_subclass // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // CHECK-NOT: call i64 @llvm.ptrauth.auth @@ -287,7 +303,7 @@ void test_subclass_disabled(ExplicitlyDisableAuth *a) { make_subclass(a)->f(); } -// CHECK-LABEL: define void @test_subclass_addr_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_subclass_addr_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = call noundef ptr @_ZN5test113make_subclass // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -312,7 +328,7 @@ void test_subclass_addr_disc(ExplicitAddressDiscrimination *a) { make_subclass(a)->f(); } -// CHECK-LABEL: define void @test_subclass_no_addr_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_subclass_no_addr_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = call noundef ptr @_ZN5test113make_subclass // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -331,7 +347,7 @@ void test_subclass_no_addr_disc(ExplicitNoAddressDiscrimination *a) { make_subclass(a)->f(); } -// CHECK-LABEL: define void @test_subclass_no_extra_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_subclass_no_extra_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = call noundef ptr @_ZN5test113make_subclass // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -352,7 +368,7 @@ void test_subclass_no_extra_disc(ExplicitNoExtraDiscrimination *a) { make_subclass(a)->f(); } -// CHECK-LABEL: define void @test_subclass_type_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_subclass_type_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = call noundef ptr @_ZN5test113make_subclass // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -375,7 +391,7 @@ void test_subclass_type_disc(ExplicitTypeDiscrimination *a) { make_subclass(a)->f(); } -// CHECK-LABEL: define void @test_subclass_custom_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_subclass_custom_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTADDR:%.*]] = call noundef ptr @_ZN5test113make_subclass // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // @@ -404,7 +420,7 @@ void test_subclass_custom_disc(ExplicitCustomDiscrimination *a) { // Codegen should be the same as the simple cases above once we have a vtable. // -// CHECK-LABEL: define void @test_multiple_default(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_multiple_default(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[CALL:%.*]] = call noundef ptr @_ZN5test121make_multiple_primary // CHECK: [[VTADDR:%.*]] = getelementptr inbounds i8, ptr [[CALL]], i64 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 @@ -427,7 +443,7 @@ void test_multiple_default(NoExplicitAuth *a) { make_multiple_primary(a)->f(); } -// CHECK-LABEL: define void @test_multiple_disabled(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_multiple_disabled(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[CALL:%.*]] = call noundef ptr @_ZN5test121make_multiple_primary // CHECK: [[VTADDR:%.*]] = getelementptr inbounds i8, ptr [[CALL]], i64 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 @@ -436,7 +452,7 @@ void test_multiple_disabled(ExplicitlyDisableAuth *a) { make_multiple_primary(a)->f(); } -// CHECK-LABEL: define void @test_multiple_custom_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_multiple_custom_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[CALL:%.*]] = call noundef ptr @_ZN5test121make_multiple_primary // CHECK: [[VTADDR:%.*]] = getelementptr inbounds i8, ptr [[CALL]], i64 8 // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 @@ -466,7 +482,7 @@ void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { // but twice for vtt/vtable. The names in the vtt version have "VTT" prefixes. // -// CHECK-LABEL: define void @test_virtual_default(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_virtual_default(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTTADDR:%.*]] = call noundef ptr @_ZN5test120make_virtual_primary // CHECK: [[VTTABLE:%.*]] = load ptr, ptr [[VTTADDR]], align 8 // @@ -509,13 +525,13 @@ void test_virtual_default(NoExplicitAuth *a) { make_virtual_primary(a)->f(); } -// CHECK-LABEL: define void @test_virtual_disabled(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_virtual_disabled(ptr noundef {{%.*}}) {{#.*}} { // CHECK-NOT: call i64 @llvm.ptrauth.auth void test_virtual_disabled(ExplicitlyDisableAuth *a) { make_virtual_primary(a)->f(); } -// CHECK-LABEL: define void @test_virtual_custom_disc(ptr noundef {{%.*}}) {{#.*}} { +// CHECK-LABEL: define{{.*}} void @test_virtual_custom_disc(ptr noundef {{%.*}}) {{#.*}} { // CHECK: [[VTTADDR:%.*]] = call noundef ptr @_ZN5test120make_virtual_primary // CHECK: [[VTTABLE:%.*]] = load ptr, ptr [[VTTADDR]], align 8 // diff --git a/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp b/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp index b4a8784a33d8cd..2b633addd677e0 100644 --- a/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp +++ b/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp @@ -1,10 +1,16 @@ -// RUN: %clang_cc1 %s -I%S -triple=arm64-apple-ios -fptrauth-calls -std=c++11 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -I%S -triple=arm64-apple-ios -fptrauth-calls -std=c++11 -emit-llvm -o - | FileCheck --check-prefix=DARWIN %s +// RUN: %clang_cc1 %s -I%S -triple=aarch64-linux-gnu -fptrauth-calls -std=c++11 -emit-llvm -o - | FileCheck --check-prefix=ELF %s + #include struct A { int a; }; -// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] -// CHECK: @_ZTS1A = linkonce_odr hidden constant [3 x i8] c"1A\00" -// CHECK: @_ZTI1A = linkonce_odr hidden constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1A to i64), i64 -9223372036854775808) to ptr) } +// DARWIN: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] +// DARWIN: @_ZTS1A = linkonce_odr hidden constant [3 x i8] c"1A\00" +// DARWIN: @_ZTI1A = linkonce_odr hidden constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1A to i64), i64 -9223372036854775808) to ptr) } + +// ELF: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] +// ELF: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00" +// ELF: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS1A } auto ATI = typeid(A); diff --git a/clang/test/CodeGenCXX/ptrauth-static-destructors.cpp b/clang/test/CodeGenCXX/ptrauth-static-destructors.cpp index cad43dc0746dfa..1240f26d329da5 100644 --- a/clang/test/CodeGenCXX/ptrauth-static-destructors.cpp +++ b/clang/test/CodeGenCXX/ptrauth-static-destructors.cpp @@ -2,8 +2,13 @@ // RUN: | FileCheck %s --check-prefix=CXAATEXIT // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - \ -// RUN: -fno-use-cxa-atexit \ -// RUN: | FileCheck %s --check-prefix=ATEXIT +// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,DARWIN + +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - \ +// RUN: | FileCheck %s --check-prefix=CXAATEXIT + +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - \ +// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,ELF class Foo { public: @@ -20,5 +25,7 @@ Foo global; // ATEXIT: define internal void @__cxx_global_var_init() // ATEXIT: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, i32 0)) -// ATEXIT: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" { -// ATEXIT: %{{.*}} = call ptr @_ZN3FooD1Ev(ptr @global) +// DARWIN: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" { +// ELF: define internal void @__dtor_global() {{.*}} section ".text.startup" { +// DARWIN: %{{.*}} = call ptr @_ZN3FooD1Ev(ptr @global) +// ELF: call void @_ZN3FooD1Ev(ptr @global) diff --git a/clang/test/CodeGenCXX/ptrauth-throw.cpp b/clang/test/CodeGenCXX/ptrauth-throw.cpp index cea7226547e5a7..0e6091a370223b 100644 --- a/clang/test/CodeGenCXX/ptrauth-throw.cpp +++ b/clang/test/CodeGenCXX/ptrauth-throw.cpp @@ -1,5 +1,8 @@ -// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK -// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECKDISC +// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECKDISC + +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECKDISC class Foo { public: @@ -7,10 +10,10 @@ class Foo { } }; -// CHECK-LABEL: define void @_Z1fv() +// CHECK-LABEL: define{{.*}} void @_Z1fv() // CHECK: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTI3Foo, ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0)) -// CHECKDISC-LABEL: define void @_Z1fv() +// CHECKDISC-LABEL: define{{.*}} void @_Z1fv() // CHECKDISC: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTI3Foo, ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0, i64 10942)) void f() { @@ -18,10 +21,10 @@ void f() { } // __cxa_throw is defined to take its destructor as "void (*)(void *)" in the ABI. -// CHECK-LABEL: define void @__cxa_throw({{.*}}) +// CHECK-LABEL: define{{.*}} void @__cxa_throw({{.*}}) // CHECK: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i32 0, i64 0) ] -// CHECKDISC-LABEL: define void @__cxa_throw({{.*}}) +// CHECKDISC-LABEL: define{{.*}} void @__cxa_throw({{.*}}) // CHECKDISC: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i32 0, i64 10942) ] extern "C" void __cxa_throw(void *exception, void *, void (*dtor)(void *)) { diff --git a/clang/test/CodeGenCXX/ptrauth-thunks.cpp b/clang/test/CodeGenCXX/ptrauth-thunks.cpp index a85c8c4c065c46..f4491a3aab7abc 100644 --- a/clang/test/CodeGenCXX/ptrauth-thunks.cpp +++ b/clang/test/CodeGenCXX/ptrauth-thunks.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - | FileCheck %s namespace Test1 { struct B1 { diff --git a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp index 563d60780769bb..4aa24738d8ce3a 100644 --- a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp +++ b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - | FileCheck --check-prefixes=CHECK,DARWIN %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - | FileCheck --check-prefixes=CHECK,ELF %s // Check virtual function pointers in vtables are signed. @@ -182,7 +183,8 @@ V1::~V1() { // Check sign/authentication of vtable pointers and authentication of virtual // functions. -// CHECK-LABEL: define noundef ptr @_ZN2V1D2Ev( +// DARWIN-LABEL: define noundef ptr @_ZN2V1D2Ev( +// ELF-LABEL: define dso_local void @_ZN2V1D2Ev( // CHECK: %[[THIS1:.*]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T1:[0-9]+]] = ptrtoint ptr %[[T0]] to i64 @@ -193,7 +195,7 @@ V1::~V1() { // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T7]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS1]] -// CHECK-LABEL: define void @_Z8testB0m0P2B0( +// CHECK-LABEL: define{{.*}} void @_Z8testB0m0P2B0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -208,7 +210,7 @@ void testB0m0(B0 *a) { a->m0(); } -// CHECK-LABEL: define void @_Z8testB0m1P2B0( +// CHECK-LABEL: define{{.*}} void @_Z8testB0m1P2B0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -223,7 +225,7 @@ void testB0m1(B0 *a) { a->m1(); } -// CHECK-LABEL: define void @_Z8testB0m2P2B0( +// CHECK-LABEL: define{{.*}} void @_Z8testB0m2P2B0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -238,7 +240,7 @@ void testB0m2(B0 *a) { a->m2(); } -// CHECK-LABEL: define void @_Z8testD0m0P2D0( +// CHECK-LABEL: define{{.*}} void @_Z8testD0m0P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -253,7 +255,7 @@ void testD0m0(D0 *a) { a->m0(); } -// CHECK-LABEL: define void @_Z8testD0m1P2D0( +// CHECK-LABEL: define{{.*}} void @_Z8testD0m1P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -268,7 +270,7 @@ void testD0m1(D0 *a) { a->m1(); } -// CHECK-LABEL: define void @_Z8testD0m2P2D0( +// CHECK-LABEL: define{{.*}} void @_Z8testD0m2P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -283,7 +285,7 @@ void testD0m2(D0 *a) { a->m2(); } -// CHECK-LABEL: define void @_Z8testD0m3P2D0( +// CHECK-LABEL: define{{.*}} void @_Z8testD0m3P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -299,7 +301,7 @@ void testD0m3(D0 *a) { } -// CHECK-LABEL: define void @_Z8testD1m0P2D1( +// CHECK-LABEL: define{{.*}} void @_Z8testD1m0P2D1( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -314,7 +316,7 @@ void testD1m0(D1 *a) { a->m0(); } -// CHECK-LABEL: define void @_Z8testD1m1P2D1( +// CHECK-LABEL: define{{.*}} void @_Z8testD1m1P2D1( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -329,7 +331,7 @@ void testD1m1(D1 *a) { a->m1(); } -// CHECK-LABEL: define void @_Z8testD1m2P2D1( +// CHECK-LABEL: define{{.*}} void @_Z8testD1m2P2D1( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -345,7 +347,7 @@ void testD1m2(D1 *a) { } -// CHECK-LABEL: define void @_Z8testD2m0P2D2( +// CHECK-LABEL: define{{.*}} void @_Z8testD2m0P2D2( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -360,7 +362,7 @@ void testD2m0(D2 *a) { a->m0(); } -// CHECK-LABEL: define void @_Z8testD2m1P2D2( +// CHECK-LABEL: define{{.*}} void @_Z8testD2m1P2D2( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -375,21 +377,21 @@ void testD2m1(D2 *a) { a->m1(); } -// CHECK-LABEL: define void @_Z10testD2m2D0P2D2( +// CHECK-LABEL: define{{.*}} void @_Z10testD2m2D0P2D2( // CHECK: call void @_ZN2B02m2Ev(ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}){{$}} void testD2m2D0(D2 *a) { a->D0::m2(); } -// CHECK-LABEL: define void @_Z10testD2m2D1P2D2( +// CHECK-LABEL: define{{.*}} void @_Z10testD2m2D1P2D2( // CHECK: call void @_ZN2B02m2Ev(ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}){{$}} void testD2m2D1(D2 *a) { a->D1::m2(); } -// CHECK-LABEL: define void @_Z8testD2m3P2D2( +// CHECK-LABEL: define{{.*}} void @_Z8testD2m3P2D2( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -404,7 +406,7 @@ void testD2m3(D2 *a) { a->m3(); } -// CHECK-LABEL: define void @_Z8testD3m0P2D3( +// CHECK-LABEL: define{{.*}} void @_Z8testD3m0P2D3( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -419,7 +421,7 @@ void testD3m0(D3 *a) { a->m0(); } -// CHECK-LABEL: define void @_Z8testD3m1P2D3( +// CHECK-LABEL: define{{.*}} void @_Z8testD3m1P2D3( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 // CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) @@ -434,7 +436,7 @@ void testD3m1(D3 *a) { a->m1(); } -// CHECK: define void @_Z8testD3m2P2D3(ptr noundef %[[A:.*]]) +// CHECK: define{{.*}} void @_Z8testD3m2P2D3(ptr noundef %[[A:.*]]) // CHECK: %[[A_ADDR:.*]] = alloca ptr, align 8 // CHECK: store ptr %[[A]], ptr %[[A_ADDR]], align 8 // CHECK: %[[V0:.*]] = load ptr, ptr %[[A_ADDR]], align 8 @@ -459,7 +461,7 @@ void testD3m2(D3 *a) { a->m2(); } -// CHECK-LABEL: define void @_Z17testD3Destructor0P2D3( +// CHECK-LABEL: define{{.*}} void @_Z17testD3Destructor0P2D3( // CHECK: load ptr, ptr // CHECK: %[[VTABLE:.*]] = load ptr, ptr %{{.*}} // CHECK: %[[T2:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 @@ -475,7 +477,7 @@ void testD3Destructor0(D3 *a) { delete a; } -// CHECK-LABEL: define void @_Z17testD3Destructor1P2D3( +// CHECK-LABEL: define{{.*}} void @_Z17testD3Destructor1P2D3( // CHECK: %[[T6:.*]] = load ptr, ptr % // CHECK: %[[VTABLE0:[a-z0-9]+]] = load ptr, ptr % // CHECK: %[[T2:[0-9]+]] = ptrtoint ptr %[[VTABLE0]] to i64 @@ -492,14 +494,15 @@ void testD3Destructor0(D3 *a) { // CHECK: %[[T12:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T13:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 // CHECK: %[[T14:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T13]], i64 57279) -// CHECK: %call = call noundef ptr %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T14]]) ] +// DARWIN: %call = call noundef ptr %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T14]]) ] +// ELF: call void %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T14]]) ] // CHECK: call void @_ZdlPv(ptr noundef %[[T7]]) void testD3Destructor1(D3 *a) { ::delete a; } -// CHECK-LABEL: define void @_Z17testD3Destructor2P2D3( +// CHECK-LABEL: define{{.*}} void @_Z17testD3Destructor2P2D3( // CHECK: load ptr, ptr // CHECK: %[[VTABLE:.*]] = load ptr, ptr % // CHECK: %[[T2:.*]] = ptrtoint ptr %[[VTABLE]] to i64 @@ -509,7 +512,8 @@ void testD3Destructor1(D3 *a) { // CHECK: %[[T5:.*]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:.*]] = ptrtoint ptr %[[VFN]] to i64 // CHECK: %[[T7:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 57279) -// CHECK: %call = call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// DARWIN: %call = call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// ELF: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T7]]) ] void testD3Destructor2(D3 *a) { a->~D3(); @@ -526,23 +530,27 @@ void materializeConstructors() { V1 V1; } -// CHECK-LABEL: define linkonce_odr noundef ptr @_ZN2B0C2Ev( +// DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2B0C2Ev( +// ELF-LABEL: define linkonce_odr void @_ZN2B0C2Ev( // CHECK: %[[THIS:.*]] = load ptr, ptr % // CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 2) to i64), i32 2, i64 0) // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T0]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS]] -// CHECK-LABEL: define linkonce_odr noundef ptr @_ZN2D0C2Ev( +// DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2D0C2Ev( +// ELF-LABEL: define linkonce_odr void @_ZN2D0C2Ev( // CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 2) to i64), i32 2, i64 0) // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T0]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS]] -// CHECK-LABEL: define linkonce_odr noundef ptr @_ZN2D1C2Ev( +// DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2D1C2Ev( +// ELF-LABEL: define linkonce_odr void @_ZN2D1C2Ev( // CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 48) ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 2) to i64), i32 2, i64 0) // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T0]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS]] -// CHECK-LABEL: define linkonce_odr noundef ptr @_ZN2D2C2Ev( +// DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2D2C2Ev( +// ELF-LABEL: define linkonce_odr void @_ZN2D2C2Ev( // CHECK: %[[SLOT0:.*]] = load ptr, ptr // CHECK: %[[SIGN_VTADDR0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 2) to i64), i32 2, i64 0) // CHECK: %[[T1:[0-9]+]] = inttoptr i64 %[[SIGN_VTADDR0]] to ptr @@ -552,7 +560,8 @@ void materializeConstructors() { // CHECK: %[[T5:[0-9]+]] = inttoptr i64 %[[SIGN_VTADDR1]] to ptr // CHECK: store ptr %[[T5]], ptr %[[T3]] -// CHECK-LABEL: define linkonce_odr noundef ptr @_ZN2V0C2Ev( +// DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2V0C2Ev( +// ELF-LABEL: define linkonce_odr void @_ZN2V0C2Ev( // CHECK: %[[THIS1]] = load ptr, ptr % // CHECK: %[[VTT:[a-z0-9]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = load ptr, ptr %[[VTT]] diff --git a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp index 00b1cbd06e0f03..031bb48608af7c 100644 --- a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp +++ b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp @@ -1,4 +1,7 @@ -// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-intrinsics -fptrauth-calls -fptrauth-vtable-pointer-type-discrimination -emit-llvm -O0 -disable-llvm-passes -o - | FileCheck --check-prefix=CHECK %s +// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -disable-llvm-passes -fptrauth-intrinsics -fptrauth-calls \ +// RUN: -fptrauth-vtable-pointer-type-discrimination -emit-llvm -O0 -o - | FileCheck --check-prefixes=CHECK,DARWIN %s +// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple aarch64-linux-gnu -disable-llvm-passes -fptrauth-intrinsics -fptrauth-calls \ +// RUN: -fptrauth-vtable-pointer-type-discrimination -emit-llvm -O0 -o - | FileCheck --check-prefixes=CHECK,ELF %s // The actual vtable construction @@ -103,9 +106,11 @@ // CHECK: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr] -// CHECK: @_ZTS1B = linkonce_odr hidden constant [3 x i8] c"1B\00", align 1 +// DARWIN: @_ZTS1B = linkonce_odr hidden constant [3 x i8] c"1B\00", align 1 +// ELF: @_ZTS1B = linkonce_odr constant [3 x i8] c"1B\00", comdat, align 1 -// CHECK: @_ZTI1B = linkonce_odr hidden constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1B to i64), i64 -9223372036854775808) to ptr), ptr @_ZTI1A }, align 8 +// DARWIN: @_ZTI1B = linkonce_odr hidden constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1B to i64), i64 -9223372036854775808) to ptr), ptr @_ZTI1A }, align 8 +// ELF: @_ZTI1B = linkonce_odr constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), i32 2), ptr @_ZTS1B, ptr @_ZTI1A }, comdat, align 8 // CHECK: @_ZTI1C = constant { ptr, ptr, i32, i32, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1C, i32 0, i32 1, ptr @_ZTI1B, i64 -6141 }, align 8 @@ -177,7 +182,8 @@ // CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 3)), // CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 4)), // CHECK-SAME: ptr ptrauth (ptr @_ZN1BD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1BD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 6))] }, align 8 +// DARWIN-SAME: ptr ptrauth (ptr @_ZN1BD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 6))] }, align 8 +// ELF-SAME: ptr ptrauth (ptr @_ZN1BD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 6))] }, comdat, align 8 extern "C" int printf(const char *format, ...); @@ -284,13 +290,15 @@ int main() { } // And check the thunks -// CHECK: ptr @_ZTv0_n48_N1CD1Ev(ptr noundef %this) +// DARWIN: ptr @_ZTv0_n48_N1CD1Ev(ptr noundef %this) +// ELF: void @_ZTv0_n48_N1CD1Ev(ptr noundef %this) // CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 62866) // CHECK: void @_ZTv0_n48_N1CD0Ev(ptr noundef %this) // CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 62866) -// CHECK: ptr @_ZTv0_n48_N1DD1Ev(ptr noundef %this) +// DARWIN: ptr @_ZTv0_n48_N1DD1Ev(ptr noundef %this) +// ELF: void @_ZTv0_n48_N1DD1Ev(ptr noundef %this) // CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 62866) // CHECK: void @_ZTv0_n48_N1DD0Ev(ptr noundef %this) diff --git a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp index 72c59cb41c34b1..c891ff0a4fa42c 100644 --- a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp +++ b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp @@ -3,6 +3,8 @@ // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux -emit-llvm -fsanitize=null,vptr %s -o - | FileCheck %s --check-prefix=CHECK-VPTR --check-prefix=ITANIUM // RUN: %clang_cc1 -std=c++11 -triple x86_64-windows -emit-llvm -fsanitize=null,vptr %s -o - | FileCheck %s --check-prefix=CHECK-VPTR --check-prefix=MSABI --check-prefix=CHECK-VPTR-MS // RUN: %clang_cc1 -std=c++11 -triple arm64e-ios-13 -emit-llvm -fptrauth-intrinsics -fptrauth-calls -fptrauth-vtable-pointer-type-discrimination -fptrauth-vtable-pointer-address-discrimination -fsanitize=null,vptr %s -o - | FileCheck %s --check-prefix=CHECK-VPTR --check-prefix=ITANIUM --check-prefix=CHECK-PTRAUTH +// RUN: %clang_cc1 -std=c++11 -triple aarch64-unknown-linux -emit-llvm -fptrauth-intrinsics -fptrauth-calls -fptrauth-vtable-pointer-type-discrimination -fptrauth-vtable-pointer-address-discrimination -fsanitize=null,vptr %s -o - | FileCheck %s --check-prefix=CHECK-VPTR --check-prefix=ITANIUM --check-prefix=CHECK-PTRAUTH + struct T { virtual ~T() {} virtual int v() { return 1; } @@ -29,7 +31,7 @@ int get_v(T* t) { // CHECK-NULL: load ptr, ptr {{.*}} // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr %vtable to i64 - // CHECK-PTRAUTH: [[STRIPPED_VTABLE:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[CAST_VTABLE]], i32 0), !nosanitize !2 + // CHECK-PTRAUTH: [[STRIPPED_VTABLE:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[CAST_VTABLE]], i32 0), !nosanitize // CHECK-PTRAUTH: [[STRIPPED_PTR:%.*]] = inttoptr i64 [[STRIPPED_VTABLE]] to ptr // CHECK-PTRAUTH: [[STRIPPED_INT:%.*]] = ptrtoint ptr [[STRIPPED_PTR]] to i64 // Make sure authed vtable pointer feeds into hashing diff --git a/clang/test/SemaCXX/ptrauth-incomplete-virtual-member-function-return-arg-type.cpp b/clang/test/SemaCXX/ptrauth-incomplete-virtual-member-function-return-arg-type.cpp index 41bbba0e832fda..9cc88750363c62 100644 --- a/clang/test/SemaCXX/ptrauth-incomplete-virtual-member-function-return-arg-type.cpp +++ b/clang/test/SemaCXX/ptrauth-incomplete-virtual-member-function-return-arg-type.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++17 -Wno-vla -fsyntax-only -verify -fptrauth-intrinsics -fptrauth-calls %s +// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++17 -Wno-vla -fsyntax-only -verify -fptrauth-intrinsics -fptrauth-calls %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++17 -Wno-vla -fsyntax-only -verify -fptrauth-intrinsics -fptrauth-calls %s struct Incomplete0; // expected-note 3 {{forward declaration of 'Incomplete0'}} diff --git a/clang/test/SemaCXX/vtable_pointer_authentication_attribute.cpp b/clang/test/SemaCXX/vtable_pointer_authentication_attribute.cpp index 3a3386196fbfa5..f228c4e6ad0c0f 100644 --- a/clang/test/SemaCXX/vtable_pointer_authentication_attribute.cpp +++ b/clang/test/SemaCXX/vtable_pointer_authentication_attribute.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-ios -verify -fptrauth-calls -std=c++2a %s +// RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-ios -verify -fptrauth-calls -std=c++2a %s +// RUN: %clang_cc1 -fsyntax-only -triple aarch64-linux-gnu -verify -fptrauth-calls -std=c++2a %s namespace basic {