brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 9fa6f95 Raw
44 lines · c
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 %s2 3// Test that normalized type metadata for functions are emitted for cross-language CFI support with4// other languages that can't represent and encode C/C++ integer types.5 6void foo(void (*fn)(int), int arg) {7    // CHECK-LABEL: define{{.*}}foo8    // 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 13void bar(void (*fn)(int, int), int arg1, int arg2) {14    // CHECK-LABEL: define{{.*}}bar15    // 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 20void baz(void (*fn)(int, int, int), int arg1, int arg2, int arg3) {21    // CHECK-LABEL: define{{.*}}baz22    // 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 27union Union {28  char *c;29  long *n;30} __attribute__((transparent_union));31 32void uni(void (*fn)(union Union), union Union arg1) {33    // CHECK-LABEL: define{{.*}}uni34    // CHECK-SAME: {{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}}35    // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFvPu2i8E.normalized")36    fn(arg1);37}38 39// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvPFvu3i32ES_E.normalized"}40// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvPFvu3i32S_ES_S_E.normalized"}41// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvPFvu3i32S_S_ES_S_S_E.normalized"}42// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvPFv5UnionEPu2i8E.normalized"}43 44