2021-10-07 17:33:13 -05:00
|
|
|
// Verifies that pointer type membership tests for indirect calls are emitted.
|
|
|
|
//
|
|
|
|
// needs-sanitizer-cfi
|
2022-12-30 14:11:30 -06:00
|
|
|
// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
|
2021-10-07 17:33:13 -05:00
|
|
|
|
|
|
|
#![crate_type="lib"]
|
|
|
|
|
|
|
|
pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 {
|
2022-12-13 00:42:44 -06:00
|
|
|
// CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
|
2021-10-07 17:33:13 -05:00
|
|
|
// CHECK: start:
|
2023-07-27 16:44:13 -05:00
|
|
|
// CHECK: [[TT:%.+]] = call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"{{[[:print:]]+}}")
|
2022-07-27 08:07:58 -05:00
|
|
|
// CHECK-NEXT: br i1 [[TT]], label %type_test.pass, label %type_test.fail
|
2021-10-07 17:33:13 -05:00
|
|
|
// CHECK: type_test.pass:
|
2022-12-30 14:11:30 -06:00
|
|
|
// CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg)
|
2021-10-07 17:33:13 -05:00
|
|
|
// CHECK: type_test.fail:
|
|
|
|
// CHECK-NEXT: call void @llvm.trap()
|
|
|
|
// CHECK-NEXT: unreachable
|
|
|
|
f(arg)
|
|
|
|
}
|