[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CodeGenCXX / wasm-args-returns.cpp
blob090ca9a99756f70125923ad9eebdb76a5e5576c9
1 // RUN: %clang_cc1 -no-enable-noundef-analysis -O1 -triple wasm32-unknown-unknown -emit-llvm -o - %s \
2 // RUN: | FileCheck %s
3 // RUN: %clang_cc1 -no-enable-noundef-analysis -O1 -triple wasm64-unknown-unknown -emit-llvm -o - %s \
4 // RUN: | FileCheck %s
6 #define concat_(x, y) x##y
7 #define concat(x, y) concat_(x, y)
9 #define test(T) \
10 T forward(T x) { return x; } \
11 void use(T x); \
12 T concat(def_, T)(void); \
13 void concat(test_, T)(void) { use(concat(def_, T)()); }
15 struct one_field {
16 double d;
18 test(one_field);
19 // CHECK: define double @_Z7forward9one_field(double returned %{{.*}})
21 // CHECK: define void @_Z14test_one_fieldv()
22 // CHECK: %[[call:.*]] = tail call double @_Z13def_one_fieldv()
23 // CHECK: call void @_Z3use9one_field(double %[[call]])
24 // CHECK: ret void
26 // CHECK: declare void @_Z3use9one_field(double)
27 // CHECK: declare double @_Z13def_one_fieldv()
29 struct two_fields {
30 double d, e;
32 test(two_fields);
33 // CHECK: define void @_Z7forward10two_fields(ptr noalias nocapture writeonly sret(%struct.two_fields) align 8 %{{.*}}, ptr nocapture readonly byval(%struct.two_fields) align 8 %{{.*}})
35 // CHECK: define void @_Z15test_two_fieldsv()
36 // CHECK: %[[tmp:.*]] = alloca %struct.two_fields, align 8
37 // CHECK: call void @_Z14def_two_fieldsv(ptr nonnull sret(%struct.two_fields) align 8 %[[tmp]])
38 // CHECK: call void @_Z3use10two_fields(ptr nonnull byval(%struct.two_fields) align 8 %[[tmp]])
39 // CHECK: ret void
41 // CHECK: declare void @_Z3use10two_fields(ptr byval(%struct.two_fields) align 8)
42 // CHECK: declare void @_Z14def_two_fieldsv(ptr sret(%struct.two_fields) align 8)
44 struct copy_ctor {
45 double d;
46 copy_ctor(copy_ctor const &);
48 test(copy_ctor);
49 // CHECK: define void @_Z7forward9copy_ctor(ptr noalias {{[^,]*}} sret(%struct.copy_ctor) align 8 %{{.*}}, ptr nonnull %{{.*}})
51 // CHECK: declare ptr @_ZN9copy_ctorC1ERKS_(ptr {{[^,]*}} returned {{[^,]*}}, ptr nonnull align 8 dereferenceable(8))
53 // CHECK: define void @_Z14test_copy_ctorv()
54 // CHECK: %[[tmp:.*]] = alloca %struct.copy_ctor, align 8
55 // CHECK: call void @_Z13def_copy_ctorv(ptr nonnull sret(%struct.copy_ctor) align 8 %[[tmp]])
56 // CHECK: call void @_Z3use9copy_ctor(ptr nonnull %[[tmp]])
57 // CHECK: ret void
59 // CHECK: declare void @_Z3use9copy_ctor(ptr)
60 // CHECK: declare void @_Z13def_copy_ctorv(ptr sret(%struct.copy_ctor) align 8)
62 struct __attribute__((aligned(16))) aligned_copy_ctor {
63 double d, e;
64 aligned_copy_ctor(aligned_copy_ctor const &);
66 test(aligned_copy_ctor);
67 // CHECK: define void @_Z7forward17aligned_copy_ctor(ptr noalias {{[^,]*}} sret(%struct.aligned_copy_ctor) align 16 %{{.*}}, ptr nonnull %{{.*}})
69 // CHECK: declare ptr @_ZN17aligned_copy_ctorC1ERKS_(ptr {{[^,]*}} returned {{[^,]*}}, ptr nonnull align 16 dereferenceable(16))
71 // CHECK: define void @_Z22test_aligned_copy_ctorv()
72 // CHECK: %[[tmp:.*]] = alloca %struct.aligned_copy_ctor, align 16
73 // CHECK: call void @_Z21def_aligned_copy_ctorv(ptr nonnull sret(%struct.aligned_copy_ctor) align 16 %[[tmp]])
74 // CHECK: call void @_Z3use17aligned_copy_ctor(ptr nonnull %[[tmp]])
75 // CHECK: ret void
77 // CHECK: declare void @_Z3use17aligned_copy_ctor(ptr)
78 // CHECK: declare void @_Z21def_aligned_copy_ctorv(ptr sret(%struct.aligned_copy_ctor) align 16)
80 struct empty {};
81 test(empty);
82 // CHECK: define void @_Z7forward5empty()
84 // CHECK: define void @_Z10test_emptyv()
85 // CHECK: call void @_Z9def_emptyv()
86 // CHECK: call void @_Z3use5empty()
87 // CHECK: ret void
89 // CHECK: declare void @_Z3use5empty()
90 // CHECK: declare void @_Z9def_emptyv()
92 struct one_bitfield {
93 int d : 3;
95 test(one_bitfield);
96 // CHECK: define i32 @_Z7forward12one_bitfield(i32 returned %{{.*}})
98 // CHECK: define void @_Z17test_one_bitfieldv()
99 // CHECK: %[[call:.*]] = tail call i32 @_Z16def_one_bitfieldv()
100 // CHECK: call void @_Z3use12one_bitfield(i32 %[[call]])
101 // CHECK: ret void
103 // CHECK: declare void @_Z3use12one_bitfield(i32)
104 // CHECK: declare i32 @_Z16def_one_bitfieldv()