blob: 89a5f80779911b3fc9837b87a8406e10b9ba38fe [file] [log] [blame]
Daniel Berlin65f8cf92017-03-01 01:56:41 +00001; RUN: opt -verify -S < %s | FileCheck %s
Philip Reames8d5d68f2015-01-14 23:05:17 +00002
3; Tests the name mangling performed by the codepath following
4; getMangledTypeStr(). Only tests that code with the various manglings
5; run fine: doesn't actually test the mangling with the type of the
6; arguments. Meant to serve as an example-document on how the user
7; should do name manglings.
8
9; Exercise the most general case, llvm_anyptr_type, using gc.relocate
10; and gc.statepoint. Note that it has nothing to do with gc.*
11; functions specifically: any function that accepts llvm_anyptr_type
12; will serve the purpose.
13
14; function and integer
Philip Reamese1bf2702015-03-27 05:09:33 +000015define i32* @test_iAny(i32* %v) gc "statepoint-example" {
Chen Lid71999e2015-12-26 07:54:32 +000016 %tok = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, i32* %v)
17 %v-new = call i32* @llvm.experimental.gc.relocate.p0i32(token %tok, i32 7, i32 7)
Philip Reames8d5d68f2015-01-14 23:05:17 +000018 ret i32* %v-new
19}
20
21; float
Philip Reamese1bf2702015-03-27 05:09:33 +000022define float* @test_fAny(float* %v) gc "statepoint-example" {
Chen Lid71999e2015-12-26 07:54:32 +000023 %tok = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, float* %v)
24 %v-new = call float* @llvm.experimental.gc.relocate.p0f32(token %tok, i32 7, i32 7)
Philip Reames8d5d68f2015-01-14 23:05:17 +000025 ret float* %v-new
26}
27
28; array of integers
Philip Reamese1bf2702015-03-27 05:09:33 +000029define [3 x i32]* @test_aAny([3 x i32]* %v) gc "statepoint-example" {
Chen Lid71999e2015-12-26 07:54:32 +000030 %tok = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, [3 x i32]* %v)
31 %v-new = call [3 x i32]* @llvm.experimental.gc.relocate.p0a3i32(token %tok, i32 7, i32 7)
Philip Reames8d5d68f2015-01-14 23:05:17 +000032 ret [3 x i32]* %v-new
33}
34
35; vector of integers
Philip Reamese1bf2702015-03-27 05:09:33 +000036define <3 x i32>* @test_vAny(<3 x i32>* %v) gc "statepoint-example" {
Chen Lid71999e2015-12-26 07:54:32 +000037 %tok = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, <3 x i32>* %v)
38 %v-new = call <3 x i32>* @llvm.experimental.gc.relocate.p0v3i32(token %tok, i32 7, i32 7)
Philip Reames8d5d68f2015-01-14 23:05:17 +000039 ret <3 x i32>* %v-new
40}
41
Ramkumar Ramachandraca49c032015-01-27 20:03:08 +000042%struct.test = type { i32, i1 }
43
44; struct
Philip Reamese1bf2702015-03-27 05:09:33 +000045define %struct.test* @test_struct(%struct.test* %v) gc "statepoint-example" {
Chen Lid71999e2015-12-26 07:54:32 +000046 %tok = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, %struct.test* %v)
Daniel Berlin3c1432f2017-02-15 23:16:20 +000047 %v-new = call %struct.test* @llvm.experimental.gc.relocate.p0s_struct.tests(token %tok, i32 7, i32 7)
Ramkumar Ramachandraca49c032015-01-27 20:03:08 +000048 ret %struct.test* %v-new
49}
50
Daniel Berlin3c1432f2017-02-15 23:16:20 +000051; literal struct with nested literal struct
52define {i64, i64, {i64} }* @test_literal_struct({i64, i64, {i64}}* %v) gc "statepoint-example" {
53 %tok = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, {i64, i64, {i64}} *%v)
54 %v-new = call {i64, i64, {i64}}* @llvm.experimental.gc.relocate.p0sl_i64i64sl_i64ss.test(token %tok, i32 7, i32 7)
55 ret {i64, i64, {i64}}* %v-new
56}
57; struct with a horrible name, broken when structs were unprefixed
58%i32 = type { i32 }
59
60define %i32* @test_i32_struct(%i32* %v) gc "statepoint-example" {
61entry:
62 %tok = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, %i32* %v)
63 %v-new = call %i32* @llvm.experimental.gc.relocate.p0s_i32s(token %tok, i32 7, i32 7)
64 ret %i32* %v-new
65}
66; completely broken intrinsic naming due to needing remangling. Just use random naming to test
67
68define %i32* @test_broken_names(%i32* %v) gc "statepoint-example" {
69entry:
Daniel Berlin3f910042017-03-01 01:49:13 +000070 %tok = call fastcc token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.deadbeef(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, %i32* %v)
71; Make sure we do not destroy the calling convention when remangling
72; CHECK: fastcc
Daniel Berlin3c1432f2017-02-15 23:16:20 +000073 %v-new = call %i32* @llvm.experimental.gc.relocate.beefdead(token %tok, i32 7, i32 7)
74 ret %i32* %v-new
75}
Philip Reames8d5d68f2015-01-14 23:05:17 +000076declare zeroext i1 @return_i1()
Chen Lid71999e2015-12-26 07:54:32 +000077declare token @llvm.experimental.gc.statepoint.p0f_i1f(i64, i32, i1 ()*, i32, i32, ...)
78declare i32* @llvm.experimental.gc.relocate.p0i32(token, i32, i32)
79declare float* @llvm.experimental.gc.relocate.p0f32(token, i32, i32)
80declare [3 x i32]* @llvm.experimental.gc.relocate.p0a3i32(token, i32, i32)
81declare <3 x i32>* @llvm.experimental.gc.relocate.p0v3i32(token, i32, i32)
Daniel Berlin3c1432f2017-02-15 23:16:20 +000082declare %struct.test* @llvm.experimental.gc.relocate.p0s_struct.tests(token, i32, i32)
83declare {i64, i64, {i64}}* @llvm.experimental.gc.relocate.p0sl_i64i64sl_i64ss.test(token, i32, i32)
84declare %i32* @llvm.experimental.gc.relocate.p0s_i32s(token, i32, i32)
85declare %i32* @llvm.experimental.gc.relocate.beefdead(token, i32, i32)
86declare token @llvm.experimental.gc.statepoint.deadbeef(i64, i32, i1 ()*, i32, i32, ...)