1- //  RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -o - %s | FileCheck -check-prefixes=CHECK,NODEBUG %s
2- //  RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -debug-info-kind=limited -o - %s | FileCheck -check-prefixes=CHECK %s
3- //  RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 1 -o - %s | FileCheck %s -check-prefix=STACK-PROT
4- //  RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 2 -o - %s | FileCheck %s -check-prefix=STACK-PROT
5- //  RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 3 -o - %s | FileCheck %s -check-prefix=STACK-PROT
1+ //  RUN: %clang_cc1 -triple arm64-apple-ios   -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -o - %s | FileCheck -check-prefixes=CHECK,NODEBUG,DARWIN %s
2+ //  RUN: %clang_cc1 -triple arm64-apple-ios   -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -debug-info-kind=limited -o - %s | FileCheck -check-prefixes=CHECK,DARWIN %s
3+ //  RUN: %clang_cc1 -triple arm64-apple-ios   -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 1 -o - %s | FileCheck %s -check-prefix=STACK-PROT
4+ //  RUN: %clang_cc1 -triple arm64-apple-ios   -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 2 -o - %s | FileCheck %s -check-prefix=STACK-PROT
5+ //  RUN: %clang_cc1 -triple arm64-apple-ios   -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 3 -o - %s | FileCheck %s -check-prefix=STACK-PROT
6+ 
7+ //  RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -o - %s | FileCheck -check-prefixes=CHECK,NODEBUG,ELF %s
8+ //  RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -debug-info-kind=limited -o - %s | FileCheck -check-prefixes=CHECK,ELF %s
9+ //  RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 1 -o - %s | FileCheck %s -check-prefix=STACK-PROT
10+ //  RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 2 -o - %s | FileCheck %s -check-prefix=STACK-PROT
11+ //  RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 3 -o - %s | FileCheck %s -check-prefix=STACK-PROT
612
713
814//  CHECK: @gmethod0 = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, i32 0, i64 [[TYPEDISC1:35591]]) to i64), i64 0 }, align 8
@@ -78,9 +84,9 @@ struct Class0 {
7884  MethodTy1 m0;
7985};
8086
81- //  CHECK: define void @_ZN5Base08virtual1Ev(
87+ //  CHECK: define{{.*}}  void @_ZN5Base08virtual1Ev(
8288
83- //  CHECK: define void @_Z5test0v()
89+ //  CHECK: define{{.*}}  void @_Z5test0v()
8490//  CHECK: %[[METHOD0:.*]] = alloca { i64, i64 }, align 8
8591//  CHECK-NEXT: %[[VARMETHOD1:.*]] = alloca { i64, i64 }, align 8
8692//  CHECK-NEXT: %[[METHOD2:.*]] = alloca { i64, i64 }, align 8
@@ -246,7 +252,7 @@ void test0() {
246252  method7 = &Derived1::virtual1;
247253}
248254
249- //  CHECK: define void @_Z5test1P5Base0MS_FvvE(ptr noundef %[[A0:.*]], [2 x i64] %[[A1_COERCE:.*]])
255+ //  CHECK: define{{.*}}  void @_Z5test1P5Base0MS_FvvE(ptr noundef %[[A0:.*]], [2 x i64] %[[A1_COERCE:.*]])
250256//  CHECK: %[[A1:.*]] = alloca { i64, i64 }, align 8
251257//  CHECK: %[[A0_ADDR:.*]] = alloca ptr, align 8
252258//  CHECK: %[[A1_ADDR:.*]] = alloca { i64, i64 }, align 8
@@ -264,15 +270,16 @@ void test0() {
264270//  CHECK: %[[MEMPTR_ISVIRTUAL:.*]] = icmp ne i64 %[[V5]], 0
265271//  CHECK: br i1 %[[MEMPTR_ISVIRTUAL]]
266272
267- //  CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[V4]], align 8
268- //  CHECK: %[[V7:.*]] = ptrtoint ptr %[[VTABLE]] to i64
269- //  CHECK: %[[V8:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V7]], i32 2, i64 0)
270- //  CHECK: %[[V9:.*]] = inttoptr i64 %[[V8]] to ptr
271- //  CHECK: %[[V10:.*]] = trunc i64 %[[MEMPTR_PTR]] to i32
272- //  CHECK: %[[V11:.*]] = zext i32 %[[V10]] to i64
273- //  CHECK: %[[V12:.*]] = getelementptr i8, ptr %[[V9]], i64 %[[V11]]
274- //  CHECK: %[[MEMPTR_VIRTUALFN:.*]] = load ptr, ptr %[[V12]], align 8
275- //  CHECK: br
273+ //  CHECK:  %[[VTABLE:.*]] = load ptr, ptr %[[V4]], align 8
274+ //  CHECK:  %[[V7:.*]] = ptrtoint ptr %[[VTABLE]] to i64
275+ //  CHECK:  %[[V8:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V7]], i32 2, i64 0)
276+ //  CHECK:  %[[V9:.*]] = inttoptr i64 %[[V8]] to ptr
277+ //  DARWIN: %[[V10:.*]] = trunc i64 %[[MEMPTR_PTR]] to i32
278+ //  DARWIN: %[[V11:.*]] = zext i32 %[[V10]] to i64
279+ //  DARWIN: %[[V12:.*]] = getelementptr i8, ptr %[[V9]], i64 %[[V11]]
280+ //  ELF:    %[[V12:.*]] = getelementptr i8, ptr %[[V9]], i64 %[[MEMPTR_PTR]]
281+ //  CHECK:  %[[MEMPTR_VIRTUALFN:.*]] = load ptr, ptr %[[V12]], align 8
282+ //  CHECK:  br
276283
277284//  CHECK: %[[MEMPTR_NONVIRTUALFN:.*]] = inttoptr i64 %[[MEMPTR_PTR]] to ptr
278285//  CHECK: br
@@ -286,7 +293,7 @@ void test1(Base0 *a0, MethodTy0 a1) {
286293  (a0->*a1)();
287294}
288295
289- //  CHECK: define void @_Z15testConversion0M5Base0FvvEM8Derived0FvvE([2 x i64] %[[METHOD0_COERCE:.*]], [2 x i64] %[[METHOD1_COERCE:.*]])
296+ //  CHECK: define{{.*}}  void @_Z15testConversion0M5Base0FvvEM8Derived0FvvE([2 x i64] %[[METHOD0_COERCE:.*]], [2 x i64] %[[METHOD1_COERCE:.*]])
290297//  CHECK: %[[METHOD0:.*]] = alloca { i64, i64 }, align 8
291298//  CHECK: %[[METHOD1:.*]] = alloca { i64, i64 }, align 8
292299//  CHECK: %[[METHOD0_ADDR:.*]] = alloca { i64, i64 }, align 8
@@ -326,21 +333,21 @@ void testConversion0(MethodTy0 method0, MethodTy1 method1) {
326333  method1 = method0;
327334}
328335
329- //  CHECK: define void @_Z15testConversion1M5Base0FvvE(
336+ //  CHECK: define{{.*}}  void @_Z15testConversion1M5Base0FvvE(
330337//  CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}, i32 0, i64 [[TYPEDISC0]], i32 0, i64 [[TYPEDISC1]])
331338
332339void  testConversion1 (MethodTy0 method0) {
333340  MethodTy1 method1 = reinterpret_cast <MethodTy1>(method0);
334341}
335342
336- //  CHECK: define void @_Z15testConversion2M8Derived0FvvE(
343+ //  CHECK: define{{.*}}  void @_Z15testConversion2M8Derived0FvvE(
337344//  CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}, i32 0, i64 [[TYPEDISC1]], i32 0, i64 [[TYPEDISC0]])
338345
339346void  testConversion2 (MethodTy1 method1) {
340347  MethodTy0 method0 = static_cast <MethodTy0>(method1);
341348}
342349
343- //  CHECK: define void @_Z15testConversion3M8Derived0FvvE(
350+ //  CHECK: define{{.*}}  void @_Z15testConversion3M8Derived0FvvE(
344351//  CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}, i32 0, i64 [[TYPEDISC1]], i32 0, i64 [[TYPEDISC0]])
345352
346353void  testConversion3 (MethodTy1 method1) {
@@ -350,7 +357,7 @@ void testConversion3(MethodTy1 method1) {
350357//  No need to call @llvm.ptrauth.resign if the source member function
351358//  pointer is a constant.
352359
353- //  CHECK: define void @_Z15testConversion4v(
360+ //  CHECK: define{{.*}}  void @_Z15testConversion4v(
354361//  CHECK: %[[METHOD0:.*]] = alloca { i64, i64 }, align 8
355362//  CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 [[TYPEDISC0]]) to i64), i64 0 }, ptr %[[METHOD0]], align 8
356363//  CHECK: ret void
@@ -396,7 +403,7 @@ MethodTy1 gmethod0 = reinterpret_cast<MethodTy1>(&Base0::nonvirtual0);
396403MethodTy0 gmethod1 = reinterpret_cast <MethodTy0>(&Derived0::nonvirtual5);
397404MethodTy0 gmethod2 = reinterpret_cast <MethodTy0>(&Derived0::virtual1);
398405
399- //  CHECK-LABEL: define void @_Z13testArrayInitv()
406+ //  CHECK-LABEL: define{{.*}}  void @_Z13testArrayInitv()
400407//  CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %p0, ptr align 8 @__const._Z13testArrayInitv.p0, i64 16, i1 false)
401408//  CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %p1, ptr align 8 @__const._Z13testArrayInitv.p1, i64 16, i1 false)
402409//  CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %c0, ptr align 8 @__const._Z13testArrayInitv.c0, i64 16, i1 false)
@@ -424,7 +431,7 @@ void testArrayInit() {
424431//  STACK-PROT-NOT: sspreq
425432//  STACK-PROT-NEXT: attributes
426433
427- //  CHECK: define void @_Z15testConvertNullv(
434+ //  CHECK: define{{.*}}  void @_Z15testConvertNullv(
428435//  CHECK: %[[T:.*]] = alloca { i64, i64 },
429436//  store { i64, i64 } zeroinitializer, { i64, i64 }* %[[T]],
430437
0 commit comments