Peter Collingbourne | 2c7f7e3 | 2015-09-10 02:17:40 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s |
| 2 | // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s |
| 3 | |
| 4 | // Tests that we assign unnamed metadata nodes to functions whose types have |
| 5 | // internal linkage. |
| 6 | |
| 7 | namespace { |
| 8 | |
| 9 | struct S {}; |
| 10 | |
Vlad Tsyrklevich | 634c601 | 2017-10-31 22:39:44 +0000 | [diff] [blame] | 11 | void f(S s) { |
Peter Collingbourne | 2c7f7e3 | 2015-09-10 02:17:40 +0000 | [diff] [blame] | 12 | } |
| 13 | |
| 14 | } |
| 15 | |
| 16 | void g() { |
Vlad Tsyrklevich | 634c601 | 2017-10-31 22:39:44 +0000 | [diff] [blame] | 17 | struct S s; |
| 18 | void (*fp)(S) = f; |
| 19 | // CHECK: call i1 @llvm.type.test(i8* {{.*}}, metadata [[VOIDS1:![0-9]+]]) |
| 20 | fp(s); |
Peter Collingbourne | 2c7f7e3 | 2015-09-10 02:17:40 +0000 | [diff] [blame] | 21 | } |
| 22 | |
Vlad Tsyrklevich | 634c601 | 2017-10-31 22:39:44 +0000 | [diff] [blame] | 23 | // ITANIUM: define internal void @_ZN12_GLOBAL__N_11fENS_1SE({{.*}} !type [[TS1:![0-9]+]] !type [[TS2:![0-9]+]] |
Reid Kleckner | df8dd61 | 2018-08-17 20:59:27 +0000 | [diff] [blame] | 24 | // MS: define internal void @"?f@?A0x{{[^@]*}}@@YAXUS@?A0x{{[^@]*}}@@@Z"({{.*}} !type [[TS1:![0-9]+]] !type [[TS2:![0-9]+]] |
Peter Collingbourne | 8dd14da | 2016-06-24 21:21:46 +0000 | [diff] [blame] | 25 | |
Vlad Tsyrklevich | 634c601 | 2017-10-31 22:39:44 +0000 | [diff] [blame] | 26 | // CHECK: [[VOIDS1]] = distinct !{} |
| 27 | // CHECK: [[TS1]] = !{i64 0, [[VOIDS1]]} |
| 28 | // CHECK: [[TS2]] = !{i64 0, [[VOIDS2:![0-9]+]]} |
| 29 | // CHECK: [[VOIDS2]] = distinct !{} |