diff options
Diffstat (limited to 'test/CodeGen')
-rw-r--r-- | test/CodeGen/emscripten-arguments.c | 61 | ||||
-rw-r--r-- | test/CodeGen/emscripten-regparm.c | 4 |
2 files changed, 65 insertions, 0 deletions
diff --git a/test/CodeGen/emscripten-arguments.c b/test/CodeGen/emscripten-arguments.c new file mode 100644 index 0000000000..afa0d9c57b --- /dev/null +++ b/test/CodeGen/emscripten-arguments.c @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -triple asmjs-unknown-emscripten %s -emit-llvm -o - | FileCheck %s + +// Basic argument/attribute tests for asmjs/Emscripten + +// CHECK: define void @f0(i32 %i, i32 %j, double %k) +void f0(int i, long j, double k) {} + +typedef struct { + int aa; + int bb; +} s1; +// Structs should be passed byval and not split up +// CHECK: define void @f1(%struct.s1* byval %i) +void f1(s1 i) {} + +typedef struct { + int cc; +} s2; +// Structs should be returned sret and not simplified by the frontend +// CHECK: define void @f2(%struct.s2* noalias sret %agg.result) +s2 f2() { + s2 foo; + return foo; +} + +// CHECK: define void @f3(i64 %i) +void f3(long long i) {} + +// i8/i16 should be signext, i32 and higher should not +// CHECK: define void @f4(i8 signext %a, i16 signext %b) +void f4(char a, short b) {} + +// CHECK: define void @f5(i8 zeroext %a, i16 zeroext %b) +void f5(unsigned char a, unsigned short b) {} + + +enum my_enum { + ENUM1, + ENUM2, + ENUM3, +}; +// Enums should be treated as the underlying i32 +// CHECK: define void @f6(i32 %a) +void f6(enum my_enum a) {} + +union simple_union { + int a; + char b; +}; +// Unions should be passed as byval structs +// CHECK: define void @f7(%union.simple_union* byval %s) +void f7(union simple_union s) {} + +typedef struct { + int b4 : 4; + int b3 : 3; + int b8 : 8; +} bitfield1; +// Bitfields should be passed as byval structs +// CHECK: define void @f8(%struct.bitfield1* byval %bf1) +void f8(bitfield1 bf1) {} diff --git a/test/CodeGen/emscripten-regparm.c b/test/CodeGen/emscripten-regparm.c new file mode 100644 index 0000000000..20ffc9dec0 --- /dev/null +++ b/test/CodeGen/emscripten-regparm.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple asmjs-unknown-emscripten %s -fsyntax-only -verify + +void __attribute__((regparm(2))) fc_f1(int i, int j, int k) {} // expected-error{{'regparm' is not valid on this platform}} + |