]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/sanitizer_cfi_emit_type_metadata.rs
Rollup merge of #89876 - AlexApps99:const_ops, r=oli-obk
[rust.git] / src / test / codegen / sanitizer_cfi_emit_type_metadata.rs
1 // Verifies that type metadata for functions are emitted.
2 //
3 // ignore-windows
4 // needs-sanitizer-cfi
5 // only-aarch64
6 // only-x86_64
7 // compile-flags: -Clto -Cno-prepopulate-passes -Zsanitizer=cfi
8
9 #![crate_type="lib"]
10
11 pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 {
12     // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}}
13     // CHECK:       %1 = call i1 @llvm.type.test(i8* %0, metadata !"typeid1")
14     f(arg)
15 }
16
17 pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 {
18     // CHECK-LABEL: define{{.*}}bar{{.*}}!type !{{[0-9]+}}
19     // CHECK:       %1 = call i1 @llvm.type.test(i8* %0, metadata !"typeid2")
20     f(arg1, arg2)
21 }
22
23 pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 {
24     // CHECK-LABEL: define{{.*}}baz{{.*}}!type !{{[0-9]+}}
25     // CHECK:       %1 = call i1 @llvm.type.test(i8* %0, metadata !"typeid3")
26     f(arg1, arg2, arg3)
27 }
28
29 // CHECK: !{{[0-9]+}} = !{i64 0, !"typeid2"}
30 // CHECK: !{{[0-9]+}} = !{i64 0, !"typeid3"}
31 // CHECK: !{{[0-9]+}} = !{i64 0, !"typeid4"}