Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / kcfi-normalize.c
blobb9150e88f6ab5f121a5b8d8e64be1d4335363e44
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)
4 #error Missing kcfi?
5 #endif
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) ]
14 fn(arg);
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) ]
21 fn(arg1, arg2);
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) ]
28 fn(arg1, arg2, arg3);
31 // CHECK: ![[#]] = !{i32 4, !"cfi-normalize-integers", i32 1}
32 // CHECK: ![[TYPE1]] = !{i32 -1143117868}
33 // CHECK: ![[TYPE2]] = !{i32 -460921415}
34 // CHECK: ![[TYPE3]] = !{i32 -333839615}