1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers -x c++ -o - %s | FileCheck %s
3 #if !__has_feature(kcfi)
7 // Test that normalized type metadata for functions are emitted for cross-language KCFI support with
8 // other languages that can't represent and encode C/C++ integer types.
10 void foo(void (*fn
)(int), int arg
) {
11 // CHECK-LABEL: define{{.*}}foo
12 // CHECK-SAME: {{.*}}!kcfi_type ![[TYPE1:[0-9]+]]
13 // CHECK: call void %0(i32 noundef %1){{.*}}[ "kcfi"(i32 1162514891) ]
17 void bar(void (*fn
)(int, int), int arg1
, int arg2
) {
18 // CHECK-LABEL: define{{.*}}bar
19 // CHECK-SAME: {{.*}}!kcfi_type ![[TYPE2:[0-9]+]]
20 // CHECK: call void %0(i32 noundef %1, i32 noundef %2){{.*}}[ "kcfi"(i32 448046469) ]
24 void baz(void (*fn
)(int, int, int), int arg1
, int arg2
, int arg3
) {
25 // CHECK-LABEL: define{{.*}}baz
26 // CHECK-SAME: {{.*}}!kcfi_type ![[TYPE3:[0-9]+]]
27 // CHECK: call void %0(i32 noundef %1, i32 noundef %2, i32 noundef %3){{.*}}[ "kcfi"(i32 -2049681433) ]
31 // CHECK: ![[#]] = !{i32 4, !"cfi-normalize-integers", i32 1}
32 // CHECK: ![[TYPE1]] = !{i32 -1143117868}
33 // CHECK: ![[TYPE2]] = !{i32 -460921415}
34 // CHECK: ![[TYPE3]] = !{i32 -333839615}