Skip to content

Commit 2e17b8a

Browse files
kovdan01yuxuanchen1997
authored andcommitted
[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
1 parent e5718ce commit 2e17b8a

14 files changed

+185
-101
lines changed

clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// 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
2+
// 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
23
// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck -check-prefixes CHECK,ZERO %s
4+
// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck -check-prefixes CHECK,ZERO %s
35

46
typedef void (*fptr_t)(void);
57

68
char *cptr;
79
void (*fptr)(void);
810

9-
// CHECK-LABEL: define void @test1
11+
// CHECK-LABEL: define{{.*}} void @test1
1012
void test1() {
1113
// TYPE: [[LOAD:%.*]] = load ptr, ptr @cptr
1214
// TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64
@@ -17,7 +19,7 @@ void test1() {
1719
(*(fptr_t)cptr)();
1820
}
1921

20-
// CHECK-LABEL: define i8 @test2
22+
// CHECK-LABEL: define{{.*}} i8 @test2
2123
char test2() {
2224
return *(char *)fptr;
2325

@@ -35,7 +37,7 @@ char test2() {
3537
// ZERO-NOT: @llvm.ptrauth.resign
3638
}
3739

38-
// CHECK-LABEL: define void @test4
40+
// CHECK-LABEL: define{{.*}} void @test4
3941
void test4() {
4042
(*((fptr_t)(&*((char *)(&*(fptr_t)cptr)))))();
4143

@@ -49,7 +51,7 @@ void test4() {
4951
}
5052

5153
void *vptr;
52-
// CHECK-LABEL: define void @test5
54+
// CHECK-LABEL: define{{.*}} void @test5
5355
void test5() {
5456
vptr = &*(char *)fptr;
5557

clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
// 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
2-
// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,ZERO
3-
// 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
1+
// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \
2+
// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,TYPE
3+
4+
// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
5+
// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,TYPE
6+
7+
// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \
8+
// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,ZERO
9+
10+
// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
11+
// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,ZERO
12+
13+
// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \
14+
// RUN: -disable-llvm-passes -emit-llvm -xc++ -o- | FileCheck %s --check-prefixes=CHECK,CHECKCXX,TYPE,TYPECXX
15+
16+
// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
17+
// RUN: -disable-llvm-passes -emit-llvm -xc++ -o- | FileCheck %s --check-prefixes=CHECK,CHECKCXX,TYPE,TYPECXX
418

519
#ifdef __cplusplus
620
extern "C" {
@@ -19,12 +33,12 @@ struct ptr_member {
1933
ptr_member pm;
2034
void (*test_member)() = (void (*)())pm.fptr_;
2135

22-
// CHECKCXX-LABEL: define internal void @__cxx_global_var_init
36+
// CHECKCXX-LABEL: define{{.*}} internal void @__cxx_global_var_init
2337
// TYPECXX: call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 2712, i32 0, i64 18983)
2438
#endif
2539

2640

27-
// CHECK-LABEL: define void @test_cast_to_opaque
41+
// CHECK-LABEL: define{{.*}} void @test_cast_to_opaque
2842
void test_cast_to_opaque() {
2943
opaque = (void *)f;
3044

@@ -33,7 +47,7 @@ void test_cast_to_opaque() {
3347
// ZERO-NOT: @llvm.ptrauth.resign
3448
}
3549

36-
// CHECK-LABEL: define void @test_cast_from_opaque
50+
// CHECK-LABEL: define{{.*}} void @test_cast_from_opaque
3751
void test_cast_from_opaque() {
3852
fptr = (void (*)(void))opaque;
3953

@@ -48,7 +62,7 @@ void test_cast_from_opaque() {
4862
// ZERO-NOT: @llvm.ptrauth.resign
4963
}
5064

51-
// CHECK-LABEL: define void @test_cast_to_intptr
65+
// CHECK-LABEL: define{{.*}} void @test_cast_to_intptr
5266
void test_cast_to_intptr() {
5367
uintptr = (unsigned long)fptr;
5468

@@ -69,14 +83,14 @@ void test_cast_to_intptr() {
6983
// ZERO-NOT: @llvm.ptrauth.resign
7084
}
7185

72-
// CHECK-LABEL: define void @test_function_to_function_cast
86+
// CHECK-LABEL: define{{.*}} void @test_function_to_function_cast
7387
void test_function_to_function_cast() {
7488
void (*fptr2)(int) = (void (*)(int))fptr;
7589
// TYPE: call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 18983, i32 0, i64 2712)
7690
// ZERO-NOT: @llvm.ptrauth.resign
7791
}
7892

79-
// CHECK-LABEL: define void @test_call_lvalue_cast
93+
// CHECK-LABEL: define{{.*}} void @test_call_lvalue_cast
8094
void test_call_lvalue_cast() {
8195
(*(void (*)(int))f)(42);
8296

clang/test/CodeGen/ptrauth-function-type-discriminator.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
// 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
2-
// 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
3-
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-pch %s -o %t.ast
4-
// 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
1+
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \
2+
// RUN: -disable-llvm-passes -emit-llvm %s -o- | FileCheck --check-prefixes=CHECK,CHECKC %s
3+
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \
4+
// RUN: -disable-llvm-passes -emit-llvm -xc++ %s -o- | FileCheck --check-prefix=CHECK %s
5+
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-pch %s -o %t.ast
6+
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
7+
// RUN: -emit-llvm -x ast -o - %t.ast | FileCheck --check-prefixes=CHECK,CHECKC %s
8+
9+
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
10+
// RUN: -disable-llvm-passes -emit-llvm %s -o- | FileCheck --check-prefixes=CHECK,CHECKC %s
11+
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
12+
// RUN: -disable-llvm-passes -emit-llvm -xc++ %s -o- | FileCheck --check-prefix=CHECK %s
13+
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-pch %s -o %t.ast
14+
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
15+
// RUN: -emit-llvm -x ast -o - %t.ast | FileCheck --check-prefixes=CHECK,CHECKC %s
516

617
#ifdef __cplusplus
718
extern "C" {
@@ -47,29 +58,29 @@ void (*fptr3)(void) = __builtin_ptrauth_sign_constant(&external_function, 2, 26)
4758
// CHECK: @fptr4 = global ptr ptrauth (ptr @external_function, i32 2, i64 26, ptr @fptr4)
4859
void (*fptr4)(void) = __builtin_ptrauth_sign_constant(&external_function, 2, __builtin_ptrauth_blend_discriminator(&fptr4, 26));
4960

50-
// CHECK-LABEL: define void @test_call()
61+
// CHECK-LABEL: define{{.*}} void @test_call()
5162
void test_call() {
5263
// CHECK: [[T0:%.*]] = load ptr, ptr @fnptr,
5364
// CHECK-NEXT: call void [[T0]]() [ "ptrauth"(i32 0, i64 18983) ]
5465
fnptr();
5566
}
5667

57-
// CHECK-LABEL: define ptr @test_function_pointer()
68+
// CHECK-LABEL: define{{.*}} ptr @test_function_pointer()
5869
// CHECK: ret ptr ptrauth (ptr @external_function, i32 0, i64 18983)
5970
void (*test_function_pointer())(void) {
6071
return external_function;
6172
}
6273

6374
struct InitiallyIncomplete;
6475
extern struct InitiallyIncomplete returns_initially_incomplete(void);
65-
// CHECK-LABEL: define void @use_while_incomplete()
76+
// CHECK-LABEL: define{{.*}} void @use_while_incomplete()
6677
void use_while_incomplete() {
6778
// CHECK: [[VAR:%.*]] = alloca ptr,
6879
// CHECK-NEXT: store ptr ptrauth (ptr @returns_initially_incomplete, i32 0, i64 25106), ptr [[VAR]]
6980
struct InitiallyIncomplete (*fnptr)(void) = &returns_initially_incomplete;
7081
}
7182
struct InitiallyIncomplete { int x; };
72-
// CHECK-LABEL: define void @use_while_complete()
83+
// CHECK-LABEL: define{{.*}} void @use_while_complete()
7384
void use_while_complete() {
7485
// CHECK: [[VAR:%.*]] = alloca ptr,
7586
// CHECK-NEXT: store ptr ptrauth (ptr @returns_initially_incomplete, i32 0, i64 25106), ptr [[VAR]]
@@ -83,7 +94,7 @@ void knr(param)
8394
int param;
8495
{}
8596

86-
// CHECKC-LABEL: define void @test_knr
97+
// CHECKC-LABEL: define{{.*}} void @test_knr
8798
void test_knr() {
8899
void (*p)() = knr;
89100
p(0);
@@ -94,7 +105,7 @@ void test_knr() {
94105
// CHECKC: call void [[LOAD]](i32 noundef 0) [ "ptrauth"(i32 0, i64 18983) ]
95106
}
96107

97-
// CHECKC-LABEL: define void @test_redeclaration
108+
// CHECKC-LABEL: define{{.*}} void @test_redeclaration
98109
void test_redeclaration() {
99110
void redecl();
100111
void (*ptr)() = redecl;
@@ -113,7 +124,7 @@ void knr2(param)
113124
int param;
114125
{}
115126

116-
// CHECKC-LABEL: define void @test_redecl_knr
127+
// CHECKC-LABEL: define{{.*}} void @test_redecl_knr
117128
void test_redecl_knr() {
118129
void (*p)() = knr2;
119130
p();

clang/test/CodeGen/ptrauth-ubsan-vptr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 -triple arm64e-apple-ios15 -fsanitize=vptr -O0 -emit-llvm -o - %s | FileCheck %s
22
// RUN: %clang_cc1 -triple arm64e-apple-ios15 -fsanitize=vptr -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
33

4+
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsanitize=vptr -O0 -emit-llvm -o - %s | FileCheck %s
5+
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsanitize=vptr -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
6+
47
struct S {
58
S() {}
69
~S() {}

0 commit comments

Comments
 (0)