| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -fsanitize-cfi-icall-experimental-normalize-integers -emit-llvm -o - %s | FileCheck %s |
| 2 |
|
| 3 |
// Test that normalized type metadata for functions are emitted for cross-language CFI support with |
| 4 |
// other languages that can't represent and encode C/C++ integer types. |
| 5 |
|
| 6 |
void foo(void (*fn)(int), int arg) { |
| 7 |
// CHECK-LABEL: define{{.*}}foo |
| 8 |
// CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} |
| 9 |
// CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFvu3i32E.normalized") |
| 10 |
fn(arg); |
| 11 |
} |
| 12 |
|
| 13 |
void bar(void (*fn)(int, int), int arg1, int arg2) { |
| 14 |
// CHECK-LABEL: define{{.*}}bar |
| 15 |
// CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} |
| 16 |
// CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFvu3i32S_E.normalized") |
| 17 |
fn(arg1, arg2); |
| 18 |
} |
| 19 |
|
| 20 |
void baz(void (*fn)(int, int, int), int arg1, int arg2, int arg3) { |
| 21 |
// CHECK-LABEL: define{{.*}}baz |
| 22 |
// CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} |
| 23 |
// CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFvu3i32S_S_E.normalized") |
| 24 |
fn(arg1, arg2, arg3); |
| 25 |
} |
| 26 |
|
| 27 |
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvPFvu3i32ES_E.normalized"} |
| 28 |
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvPFvu3i32S_ES_S_E.normalized"} |
| 29 |
// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvPFvu3i32S_S_ES_S_S_E.normalized"} |