2021-10-07 17:33:13 -05:00
|
|
|
// Verifies that pointer type membership tests for indirect calls are emitted.
|
|
|
|
//
|
|
|
|
// needs-sanitizer-cfi
|
2022-04-01 00:50:41 -05:00
|
|
|
// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi
|
2021-10-07 17:33:13 -05:00
|
|
|
|
|
|
|
#![crate_type="lib"]
|
|
|
|
|
|
|
|
pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 {
|
|
|
|
// CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}}
|
|
|
|
// CHECK: start:
|
2022-07-27 08:07:58 -05:00
|
|
|
// CHECK: [[TT:%.+]] = call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"{{[[:print:]]+}}")
|
|
|
|
// 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-07-27 08:07:58 -05:00
|
|
|
// CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg)
|
2021-10-07 17:33:13 -05:00
|
|
|
// CHECK-NEXT: br label %bb1
|
|
|
|
// CHECK: type_test.fail:
|
|
|
|
// CHECK-NEXT: call void @llvm.trap()
|
|
|
|
// CHECK-NEXT: unreachable
|
|
|
|
f(arg)
|
|
|
|
}
|