aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGen')
-rw-r--r--test/CodeGen/2008-07-17-no-emit-on-error.c4
-rw-r--r--test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c5
-rw-r--r--test/CodeGen/2008-07-29-override-alias-decl.c2
-rw-r--r--test/CodeGen/2009-01-21-invalid-debug-info.m2
-rw-r--r--test/CodeGen/2009-04-23-dbg.c2
-rw-r--r--test/CodeGen/2009-06-01-addrofknr.c12
-rw-r--r--test/CodeGen/2009-07-31-DbgDeclare.c5
-rw-r--r--test/CodeGen/2009-08-14-vararray-crash.c11
-rw-r--r--test/CodeGen/PR3613-static-decl.c2
-rw-r--r--test/CodeGen/PR4611-bitfield-layout.c6
-rw-r--r--test/CodeGen/PR5060-align.c13
-rw-r--r--test/CodeGen/address-space-compound-literal.c5
-rw-r--r--test/CodeGen/address-space-field1.c39
-rw-r--r--test/CodeGen/address-space-field2.c50
-rw-r--r--test/CodeGen/address-space-field3.c46
-rw-r--r--test/CodeGen/address-space-field4.c61
-rw-r--r--test/CodeGen/arm-arguments.c94
-rw-r--r--test/CodeGen/arm_asm_clobber.c21
-rw-r--r--test/CodeGen/array.c4
-rw-r--r--test/CodeGen/asm-inout.c18
-rw-r--r--test/CodeGen/asm.c13
-rw-r--r--test/CodeGen/attr-cleanup.c2
-rw-r--r--test/CodeGen/attributes.c100
-rw-r--r--test/CodeGen/blocks-2.c3
-rw-r--r--test/CodeGen/blocks-aligned-byref-variable.c19
-rw-r--r--test/CodeGen/blocks-seq.c20
-rw-r--r--test/CodeGen/boolassign.c5
-rw-r--r--test/CodeGen/builtin-attributes.c12
-rw-r--r--test/CodeGen/builtins-ffs_parity_popcount.c4
-rw-r--r--test/CodeGen/builtins-powi.c4
-rw-r--r--test/CodeGen/builtins.c2
-rw-r--r--test/CodeGen/cast-to-union.c8
-rw-r--r--test/CodeGen/conditional.c21
-rw-r--r--test/CodeGen/const-init.c61
-rw-r--r--test/CodeGen/darwin-string-literals.c16
-rw-r--r--test/CodeGen/debug-info.c6
-rw-r--r--test/CodeGen/designated-initializers.c5
-rw-r--r--test/CodeGen/exprs.c8
-rw-r--r--test/CodeGen/ext-vector-shuffle.c4
-rw-r--r--test/CodeGen/ext-vector.c19
-rw-r--r--test/CodeGen/function-attributes.c2
-rw-r--r--test/CodeGen/functions.c5
-rw-r--r--test/CodeGen/global-decls.c2
-rw-r--r--test/CodeGen/global-init.c25
-rw-r--r--test/CodeGen/global-with-initialiser.c6
-rw-r--r--test/CodeGen/globalinit.c2
-rw-r--r--test/CodeGen/init-with-member-expr.c2
-rw-r--r--test/CodeGen/inline.c16
-rw-r--r--test/CodeGen/inline2.c62
-rw-r--r--test/CodeGen/packed-union.c16
-rw-r--r--test/CodeGen/parameter-passing.c2
-rw-r--r--test/CodeGen/pragma-pack-1.c7
-rw-r--r--test/CodeGen/pragma-pack-2.c23
-rw-r--r--test/CodeGen/pragma-pack-3.c19
-rw-r--r--test/CodeGen/pragma-weak.c165
-rw-r--r--test/CodeGen/predefined-expr.c45
-rw-r--r--test/CodeGen/regparm.c5
-rw-r--r--test/CodeGen/stack-protector.c3
-rw-r--r--test/CodeGen/statements.c22
-rw-r--r--test/CodeGen/staticinit.c6
-rw-r--r--test/CodeGen/stdcall-fastcall.c2
-rw-r--r--test/CodeGen/string-init.c2
-rw-r--r--test/CodeGen/struct-init.c4
-rw-r--r--test/CodeGen/struct-x86-darwin.c20
-rw-r--r--test/CodeGen/struct.c43
-rw-r--r--test/CodeGen/union-init.c28
-rw-r--r--test/CodeGen/union-init2.c4
-rw-r--r--test/CodeGen/unreachable.c37
-rw-r--r--test/CodeGen/unwind-attr.c1
-rw-r--r--test/CodeGen/vector.c10
-rw-r--r--test/CodeGen/visibility.c2
-rw-r--r--test/CodeGen/volatile.c2
-rw-r--r--test/CodeGen/x86.c2
-rw-r--r--test/CodeGen/x86_32-arguments.c127
-rw-r--r--test/CodeGen/x86_64-arguments.c28
75 files changed, 1195 insertions, 286 deletions
diff --git a/test/CodeGen/2008-07-17-no-emit-on-error.c b/test/CodeGen/2008-07-17-no-emit-on-error.c
index 89aeb18d9d13..51ba2b45d063 100644
--- a/test/CodeGen/2008-07-17-no-emit-on-error.c
+++ b/test/CodeGen/2008-07-17-no-emit-on-error.c
@@ -1,5 +1,5 @@
-// RUN: rm -f %t1.bc
-// RUN: not clang-cc %s -emit-llvm-bc -o %t1.bc
+// RUN: rm -f %t1.bc &&
+// RUN: not clang-cc %s -emit-llvm-bc -o %t1.bc &&
// RUN: not test -f %t1.bc
void f() {
diff --git a/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c b/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
index 19bf9a2b078e..348ea75ea295 100644
--- a/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
+++ b/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
@@ -1,5 +1,4 @@
-// RUN: clang-cc --emit-llvm -o %t %s &&
-// RUN: grep "i8 52" %t | count 1
+// RUN: clang-cc -triple=i686-apple-darwin9 --emit-llvm -o - %s | FileCheck %s
struct et7 {
float lv7[0];
@@ -9,3 +8,5 @@ struct et7 {
52,
};
+// CHECK: @yv7 = global
+// CHECK: i8 52, \ No newline at end of file
diff --git a/test/CodeGen/2008-07-29-override-alias-decl.c b/test/CodeGen/2008-07-29-override-alias-decl.c
index 43f4e3ecedae..4a36e0f13d5c 100644
--- a/test/CodeGen/2008-07-29-override-alias-decl.c
+++ b/test/CodeGen/2008-07-29-override-alias-decl.c
@@ -1,6 +1,6 @@
// RUN: clang-cc -emit-llvm -o - %s | grep -e "^@f" | count 1
-int x() {}
+int x() { return 1; }
int f() __attribute__((weak, alias("x")));
diff --git a/test/CodeGen/2009-01-21-invalid-debug-info.m b/test/CodeGen/2009-01-21-invalid-debug-info.m
index 9a955a1c0d95..2662b922a03c 100644
--- a/test/CodeGen/2009-01-21-invalid-debug-info.m
+++ b/test/CodeGen/2009-01-21-invalid-debug-info.m
@@ -10,7 +10,7 @@
@interface I1 @end
@implementation I1
--im0 {}
+-im0 { return 0; }
@end
I1 *f1(void) { return 0; }
diff --git a/test/CodeGen/2009-04-23-dbg.c b/test/CodeGen/2009-04-23-dbg.c
index 4be6dab7ea2b..c6b179126e03 100644
--- a/test/CodeGen/2009-04-23-dbg.c
+++ b/test/CodeGen/2009-04-23-dbg.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -g -o %t %s -emit-llvm-bc && llc %t -f -o %t.s
+// RUN: clang-cc -g -o %t %s -emit-llvm-bc && llc %t -o %t.s
# 1 "a.c"
# 1 "a.c" 1
# 1 "<built-in>" 1
diff --git a/test/CodeGen/2009-06-01-addrofknr.c b/test/CodeGen/2009-06-01-addrofknr.c
index 16a5bbffc3af..d51a4a47b478 100644
--- a/test/CodeGen/2009-06-01-addrofknr.c
+++ b/test/CodeGen/2009-06-01-addrofknr.c
@@ -2,20 +2,20 @@
// PR4289
struct funcptr {
- int (*func)();
+ int (*func)();
};
static int func(f)
- void *f;
+ void *f;
{
+ return 0;
}
int
main(int argc, char *argv[])
{
- struct funcptr fp;
+ struct funcptr fp;
- fp.func = &func;
- fp.func = func;
+ fp.func = &func;
+ fp.func = func;
}
-
diff --git a/test/CodeGen/2009-07-31-DbgDeclare.c b/test/CodeGen/2009-07-31-DbgDeclare.c
new file mode 100644
index 000000000000..da49afedbc7a
--- /dev/null
+++ b/test/CodeGen/2009-07-31-DbgDeclare.c
@@ -0,0 +1,5 @@
+// RUN: clang-cc -S -g -o %t.s %s
+void foo() {
+ int i = 0;
+ i = 42;
+}
diff --git a/test/CodeGen/2009-08-14-vararray-crash.c b/test/CodeGen/2009-08-14-vararray-crash.c
new file mode 100644
index 000000000000..40e071bd19a0
--- /dev/null
+++ b/test/CodeGen/2009-08-14-vararray-crash.c
@@ -0,0 +1,11 @@
+// RUN: clang-cc -emit-llvm < %s
+
+void sum1(int rb) {
+ typedef unsigned char imgrow[rb];
+ typedef imgrow img[rb];
+
+ const img *br;
+ int y;
+
+ (*br)[y];
+}
diff --git a/test/CodeGen/PR3613-static-decl.c b/test/CodeGen/PR3613-static-decl.c
index 365b9b2be05e..208358130000 100644
--- a/test/CodeGen/PR3613-static-decl.c
+++ b/test/CodeGen/PR3613-static-decl.c
@@ -1,5 +1,5 @@
// RUN: clang-cc -triple i386-unknown-unknown -emit-llvm -o %t %s &&
-// RUN: grep '@g0 = internal global .struct.s0 <{ i32 3 }>' %t | count 1
+// RUN: grep '@g0 = internal global %.truct.s0 { i32 3 }' %t | count 1
struct s0 {
int a;
diff --git a/test/CodeGen/PR4611-bitfield-layout.c b/test/CodeGen/PR4611-bitfield-layout.c
new file mode 100644
index 000000000000..83ce4ffdbd6d
--- /dev/null
+++ b/test/CodeGen/PR4611-bitfield-layout.c
@@ -0,0 +1,6 @@
+// RUN: clang-cc -triple i386-unknown-unknown %s -emit-llvm -o %t &&
+// RUN: grep "struct.object_entry = type { i8, \[2 x i8\], i8 }" %t
+
+struct object_entry {
+ unsigned int type:3, pack_id:16, depth:13;
+} entries;
diff --git a/test/CodeGen/PR5060-align.c b/test/CodeGen/PR5060-align.c
new file mode 100644
index 000000000000..5d864084b012
--- /dev/null
+++ b/test/CodeGen/PR5060-align.c
@@ -0,0 +1,13 @@
+// RUN: clang-cc -emit-llvm %s -o - -verify | FileCheck %s
+
+// CHECK: @foo.p = internal global i8 0, align 32
+char *foo(void) {
+ static char p __attribute__((aligned(32)));
+ return &p;
+}
+
+void bar(long n) {
+ // CHECK: align 32
+ char p[n] __attribute__((aligned(32)));
+}
+
diff --git a/test/CodeGen/address-space-compound-literal.c b/test/CodeGen/address-space-compound-literal.c
new file mode 100644
index 000000000000..79d19ed6b6ba
--- /dev/null
+++ b/test/CodeGen/address-space-compound-literal.c
@@ -0,0 +1,5 @@
+// RUN: clang-cc -emit-llvm < %s | grep "internal addrspace(1) global i32 1"
+
+typedef int a __attribute__((address_space(1)));
+a* x = &(a){1};
+
diff --git a/test/CodeGen/address-space-field1.c b/test/CodeGen/address-space-field1.c
new file mode 100644
index 000000000000..f8ec83ca71cf
--- /dev/null
+++ b/test/CodeGen/address-space-field1.c
@@ -0,0 +1,39 @@
+// RUN: clang-cc -emit-llvm < %s -o - | FileCheck %s
+// CHECK:%struct.S = type { i32, i32 }
+// CHECK:define void @test_addrspace(%struct.S addrspace(1)* %p1, %struct.S addrspace(2)* %p2) nounwind
+// CHECK:entry:
+// CHECK: %p1.addr = alloca %struct.S addrspace(1)* ; <%struct.S addrspace(1)**> [#uses=3]
+// CHECK: %p2.addr = alloca %struct.S addrspace(2)* ; <%struct.S addrspace(2)**> [#uses=3]
+// CHECK: store %struct.S addrspace(1)* %p1, %struct.S addrspace(1)** %p1.addr
+// CHECK: store %struct.S addrspace(2)* %p2, %struct.S addrspace(2)** %p2.addr
+// CHECK: %tmp = load %struct.S addrspace(2)** %p2.addr ; <%struct.S addrspace(2)*> [#uses=1]
+// CHECK: %tmp1 = getelementptr inbounds %struct.S addrspace(2)* %tmp, i32 0, i32 1 ; <i32 addrspace(2)*> [#uses=1]
+// CHECK: %tmp2 = load i32 addrspace(2)* %tmp1 ; <i32> [#uses=1]
+// CHECK: %tmp3 = load %struct.S addrspace(1)** %p1.addr ; <%struct.S addrspace(1)*> [#uses=1]
+// CHECK: %tmp4 = getelementptr inbounds %struct.S addrspace(1)* %tmp3, i32 0, i32 0 ; <i32 addrspace(1)*> [#uses=1]
+// CHECK: store i32 %tmp2, i32 addrspace(1)* %tmp4
+// CHECK: %tmp5 = load %struct.S addrspace(2)** %p2.addr ; <%struct.S addrspace(2)*> [#uses=1]
+// CHECK: %tmp6 = getelementptr inbounds %struct.S addrspace(2)* %tmp5, i32 0, i32 0 ; <i32 addrspace(2)*> [#uses=1]
+// CHECK: %tmp7 = load i32 addrspace(2)* %tmp6 ; <i32> [#uses=1]
+// CHECK: %tmp8 = load %struct.S addrspace(1)** %p1.addr ; <%struct.S addrspace(1)*> [#uses=1]
+// CHECK: %tmp9 = getelementptr inbounds %struct.S addrspace(1)* %tmp8, i32 0, i32 1 ; <i32 addrspace(1)*> [#uses=1]
+// CHECK: store i32 %tmp7, i32 addrspace(1)* %tmp9
+// CHECK: ret void
+// CHECK:}
+
+// Check that we don't lose the address space when accessing a member
+// of a structure.
+
+#define __addr1 __attribute__((address_space(1)))
+#define __addr2 __attribute__((address_space(2)))
+
+typedef struct S {
+ int a;
+ int b;
+} S;
+
+void test_addrspace(__addr1 S* p1, __addr2 S*p2) {
+ // swap
+ p1->a = p2->b;
+ p1->b = p2->a;
+}
diff --git a/test/CodeGen/address-space-field2.c b/test/CodeGen/address-space-field2.c
new file mode 100644
index 000000000000..5576e55b63fa
--- /dev/null
+++ b/test/CodeGen/address-space-field2.c
@@ -0,0 +1,50 @@
+// RUN: clang-cc -emit-llvm %s -o - | FileCheck %s
+// CHECK: addrspace(1)
+// CHECK: addrspace(2)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+
+// Check that we don't lose the address space when accessing an array element
+// inside a structure.
+
+#define __addr1 __attribute__((address_space(1)))
+#define __addr2 __attribute__((address_space(2)))
+
+typedef struct S {
+ int arr[ 3 ];
+} S;
+
+void test_addrspace(__addr1 S* p1, __addr2 S*p2, int* val, int n) {
+ for (int i=0; i < 3; ++i) {
+ int t = val[i];
+ p1->arr[i] = t;
+ for (int j=0; j < n; ++j)
+ p2[j].arr[i] = t;
+ }
+}
diff --git a/test/CodeGen/address-space-field3.c b/test/CodeGen/address-space-field3.c
new file mode 100644
index 000000000000..567757fe6670
--- /dev/null
+++ b/test/CodeGen/address-space-field3.c
@@ -0,0 +1,46 @@
+// RUN: clang-cc -emit-llvm %s -o - | FileCheck %s
+// CHECK: addrspace(1)
+// CHECK: addrspace(2)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+
+// Check that we don't lose the address space when accessing an array element
+// inside a structure.
+
+#define __addr1 __attribute__((address_space(1)))
+#define __addr2 __attribute__((address_space(2)))
+
+typedef struct S {
+ int arr[ 3 ];
+} S;
+
+void test_addrspace(__addr1 S* p1, __addr2 S*p2, int* val, int n) {
+ for (int i=0; i < 3; ++i) {
+ int t = val[i];
+ p1->arr[i] = p2->arr[i];
+ }
+}
diff --git a/test/CodeGen/address-space-field4.c b/test/CodeGen/address-space-field4.c
new file mode 100644
index 000000000000..31df018206b5
--- /dev/null
+++ b/test/CodeGen/address-space-field4.c
@@ -0,0 +1,61 @@
+// RUN: clang-cc -emit-llvm %s -o - | FileCheck %s
+// CHECK: addrspace(2)
+// CHECK: addrspace(3)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(3)
+// CHECK: addrspace(3)
+// CHECK: addrspace(1)
+// CHECK: addrspace(3)
+// CHECK: addrspace(3)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(1)
+// CHECK: addrspace(2)
+// CHECK: addrspace(1)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+// CHECK: addrspace(2)
+
+// Check the load and store are using the correct address space to access
+// the variables.
+
+#define __addr1 __attribute__((address_space(1)))
+#define __addr2 __attribute__((address_space(2)))
+#define __addr3 __attribute__((address_space(3)))
+
+typedef struct Pair {
+ __addr2 int* a;
+ __addr3 int* b;
+} Pair;
+
+typedef struct S {
+ Pair arr[ 3 ];
+} S;
+
+void test_addrspace(__addr1 S* p1, __addr1 S* p2) {
+ *p1->arr[0].a = *p2->arr[1].b;
+}
diff --git a/test/CodeGen/arm-arguments.c b/test/CodeGen/arm-arguments.c
new file mode 100644
index 000000000000..c43ede2ca05e
--- /dev/null
+++ b/test/CodeGen/arm-arguments.c
@@ -0,0 +1,94 @@
+// RUN: clang-cc -triple armv7-apple-darwin9 -target-abi=apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=APCS-GNU %s &&
+// RUN: clang-cc -triple armv7-apple-darwin9 -target-abi=aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=AAPCS %s
+
+// APCS-GNU: define arm_apcscc signext i8 @f0()
+// AAPCS: define arm_aapcscc signext i8 @f0()
+char f0(void) {
+ return 0;
+}
+
+// APCS-GNU: define arm_apcscc i8 @f1()
+// AAPCS: define arm_aapcscc i8 @f1()
+struct s1 { char f0; };
+struct s1 f1(void) {}
+
+// APCS-GNU: define arm_apcscc i16 @f2()
+// AAPCS: define arm_aapcscc i16 @f2()
+struct s2 { short f0; };
+struct s2 f2(void) {}
+
+// APCS-GNU: define arm_apcscc i32 @f3()
+// AAPCS: define arm_aapcscc i32 @f3()
+struct s3 { int f0; };
+struct s3 f3(void) {}
+
+// APCS-GNU: define arm_apcscc i32 @f4()
+// AAPCS: define arm_aapcscc i32 @f4()
+struct s4 { struct s4_0 { int f0; } f0; };
+struct s4 f4(void) {}
+
+// APCS-GNU: define arm_apcscc void @f5(
+// APCS-GNU: struct.s5* noalias sret
+// AAPCS: define arm_aapcscc i32 @f5()
+struct s5 { struct { } f0; int f1; };
+struct s5 f5(void) {}
+
+// APCS-GNU: define arm_apcscc void @f6(
+// APCS-GNU: struct.s6* noalias sret
+// AAPCS: define arm_aapcscc i32 @f6()
+struct s6 { int f0[1]; };
+struct s6 f6(void) {}
+
+// APCS-GNU: define arm_apcscc void @f7()
+// AAPCS: define arm_aapcscc void @f7()
+struct s7 { struct { int : 0; } f0; };
+struct s7 f7(void) {}
+
+// APCS-GNU: define arm_apcscc void @f8(
+// APCS-GNU: struct.s8* noalias sret
+// AAPCS: define arm_aapcscc void @f8()
+struct s8 { struct { int : 0; } f0[1]; };
+struct s8 f8(void) {}
+
+// APCS-GNU: define arm_apcscc i32 @f9()
+// AAPCS: define arm_aapcscc i32 @f9()
+struct s9 { int f0; int : 0; };
+struct s9 f9(void) {}
+
+// APCS-GNU: define arm_apcscc i32 @f10()
+// AAPCS: define arm_aapcscc i32 @f10()
+struct s10 { int f0; int : 0; int : 0; };
+struct s10 f10(void) {}
+
+// APCS-GNU: define arm_apcscc void @f11(
+// APCS-GNU: struct.s10* noalias sret
+// AAPCS: define arm_aapcscc i32 @f11()
+struct s11 { int : 0; int f0; };
+struct s11 f11(void) {}
+
+// APCS-GNU: define arm_apcscc i32 @f12()
+// AAPCS: define arm_aapcscc i32 @f12()
+union u12 { char f0; short f1; int f2; };
+union u12 f12(void) {}
+
+// APCS-GNU: define arm_apcscc void @f13(
+// APCS-GNU: struct.s13* noalias sret
+
+// FIXME: This should return a float.
+// AAPCS-FIXME: define arm_aapcscc float @f13()
+struct s13 { float f0; };
+struct s13 f13(void) {}
+
+// APCS-GNU: define arm_apcscc void @f14(
+// APCS-GNU: struct.s13* noalias sret
+// AAPCS: define arm_aapcscc i32 @f14()
+union u14 { float f0; };
+union u14 f14(void) {}
+
+// APCS-GNU: define arm_apcscc void @f15()
+// AAPCS: define arm_aapcscc void @f15()
+void f15(struct s7 a0) {}
+
+// APCS-GNU: define arm_apcscc void @f16()
+// AAPCS: define arm_aapcscc void @f16()
+void f16(struct s8 a0) {}
diff --git a/test/CodeGen/arm_asm_clobber.c b/test/CodeGen/arm_asm_clobber.c
new file mode 100644
index 000000000000..34e2517aefab
--- /dev/null
+++ b/test/CodeGen/arm_asm_clobber.c
@@ -0,0 +1,21 @@
+// RUN: clang -ccc-host-triple armv6-unknown-unknown -emit-llvm -S -o %t %s
+
+void test0(void) {
+ asm volatile("mov r0, r0" :: );
+}
+void test1(void) {
+ asm volatile("mov r0, r0" :::
+ "cc", "memory" );
+}
+void test2(void) {
+ asm volatile("mov r0, r0" :::
+ "r0", "r1", "r2", "r3");
+ asm volatile("mov r0, r0" :::
+ "r4", "r5", "r6", "r8");
+}
+void test3(void) {
+ asm volatile("mov r0, r0" :::
+ "a1", "a2", "a3", "a4");
+ asm volatile("mov r0, r0" :::
+ "v1", "v2", "v3", "v5");
+}
diff --git a/test/CodeGen/array.c b/test/CodeGen/array.c
index 5bcc26ecf38b..294dabfbbb5d 100644
--- a/test/CodeGen/array.c
+++ b/test/CodeGen/array.c
@@ -1,11 +1,11 @@
// RUN: clang-cc -emit-llvm %s -o %t
-int f() {
+void f() {
int a[2];
a[0] = 0;
}
-int f2() {
+void f2() {
int x = 0;
int y = 1;
int a[10] = { y, x, 2, 3};
diff --git a/test/CodeGen/asm-inout.c b/test/CodeGen/asm-inout.c
new file mode 100644
index 000000000000..0d8dbdfb9d38
--- /dev/null
+++ b/test/CodeGen/asm-inout.c
@@ -0,0 +1,18 @@
+// RUN: clang-cc -triple i386-unknown-unknown -emit-llvm %s -o %t &&
+// RUN: grep "load i8\*\*\* %p.addr" %t | count 1
+// XFAIL
+
+// PR3800
+void f(void **p)
+{
+ __asm__ volatile("" :"+m"(*p));
+}
+
+#if 0
+// FIXME: Once this works again, we must verify that the code below behaves as expected
+// See PR4677.
+void f() {
+ unsigned _data = 42;
+ __asm__("bswap %0":"+r"(_data));
+}
+#endif
diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c
index 58373fc4c96e..52afc9152748 100644
--- a/test/CodeGen/asm.c
+++ b/test/CodeGen/asm.c
@@ -15,7 +15,7 @@ void t4() {
unsigned long long a;
struct reg { unsigned long long a, b; } b;
- __asm__ volatile ("":: "m"(a), "m"(b));
+ __asm__ volatile ("":: "m"(a), "m"(b));
}
// PR3417
@@ -33,7 +33,7 @@ void t7(int a) {
__asm__ volatile("T7 NAMED: %[input]" : "+r"(a): [input] "i" (4));
}
-// RUN: grep "T8 NAMED MODIFIER: \${0:c}" %t
+// RUN: grep "T8 NAMED MODIFIER: \${0:c}" %t &&
void t8() {
__asm__ volatile("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4));
}
@@ -101,3 +101,12 @@ void t14(struct S *P) {
}
+// PR4938
+int t16() {
+ int a,b;
+ asm ( "nop;"
+ :"=%c" (a)
+ : "r" (b)
+ );
+ return 0;
+}
diff --git a/test/CodeGen/attr-cleanup.c b/test/CodeGen/attr-cleanup.c
index 03dde3341e6c..9105ededa20c 100644
--- a/test/CodeGen/attr-cleanup.c
+++ b/test/CodeGen/attr-cleanup.c
@@ -3,6 +3,6 @@
// <rdar://problem/6827047>
void f(void* arg);
void g() {
- __attribute__((cleanup(f))) void *g;
+ __attribute__((cleanup(f))) void *g;
}
diff --git a/test/CodeGen/attributes.c b/test/CodeGen/attributes.c
index 8f157f3d314b..d539e033a7e9 100644
--- a/test/CodeGen/attributes.c
+++ b/test/CodeGen/attributes.c
@@ -1,69 +1,77 @@
-// RUN: clang-cc -emit-llvm -o %t %s &&
-// RUN: grep 't1.*noreturn' %t &&
-// RUN: grep 't2.*nounwind' %t &&
-// RUN: grep 'weak.*t3' %t &&
-// RUN: grep 'hidden.*t4' %t &&
-// RUN: grep 't5.*weak' %t &&
-// RUN: grep 't6.*protected' %t &&
-// RUN: grep 't7.*noreturn' %t &&
-// RUN: grep 't7.*nounwind' %t &&
-// RUN: grep 't9.*alias.*weak.*t8' %t &&
-// RUN: grep '@t10().*section "SECT"' %t &&
-// RUN: grep '@t11().*section "SECT"' %t &&
-// RUN: grep '@t12 =.*section "SECT"' %t &&
-// RUN: grep '@t13 =.*section "SECT"' %t &&
-// RUN: grep '@t14.x =.*section "SECT"' %t
-// RUN: grep 'declare extern_weak i32 @t15()' %t &&
-// RUN: grep '@t16 = extern_weak global i32' %t &&
+// RUN: clang-cc -emit-llvm -triple i386-linux-gnu -o %t %s &&
+// RUN: FileCheck --input-file=%t %s
-void t1() __attribute__((noreturn));
-void t1() {}
+// CHECK: @t5 = weak global i32 2
+int t5 __attribute__((weak)) = 2;
-void t2() __attribute__((nothrow));
-void t2() {}
+// CHECK: @t13 = global %0 zeroinitializer, section "SECT"
+struct s0 { int x; };
+struct s0 t13 __attribute__((section("SECT"))) = { 0 };
-void t3() __attribute__((weak));
-void t3() {}
+// CHECK: @t14.x = internal global i32 0, section "SECT"
+void t14(void) {
+ static int x __attribute__((section("SECT"))) = 0;
+}
-void t4() __attribute__((visibility("hidden")));
-void t4() {}
+// CHECK: @t18 = global i32 1, align 4
+extern int t18 __attribute__((weak_import));
+int t18 = 1;
-int t5 __attribute__((weak)) = 2;
+// CHECK: @t16 = extern_weak global i32
+extern int t16 __attribute__((weak_import));
+// CHECK: @t6 = common protected global i32 0
int t6 __attribute__((visibility("protected")));
-void t7() __attribute__((noreturn, nothrow));
-void t7() {}
+// CHECK: @t12 = global i32 0, section "SECT"
+int t12 __attribute__((section("SECT")));
+// CHECK: @t9 = alias weak bitcast (void ()* @__t8 to void (...)*)
void __t8() {}
void t9() __attribute__((weak, alias("__t8")));
-void t10(void) __attribute__((section("SECT")));
-void t10(void) {}
-void __attribute__((section("SECT"))) t11(void) {}
-
-int t12 __attribute__((section("SECT")));
-struct s0 { int x; };
-struct s0 t13 __attribute__((section("SECT"))) = { 0 };
-
-void t14(void) {
- static int x __attribute__((section("SECT"))) = 0;
-}
-
+// CHECK: declare extern_weak i32 @t15()
int __attribute__((weak_import)) t15(void);
-extern int t16 __attribute__((weak_import));
int t17() {
return t15() + t16;
}
-// RUN: grep '@t18 = global i[0-9]* 1, align .*' %t &&
-extern int t18 __attribute__((weak_import));
-int t18 = 1;
+// CHECK: define void @t1() noreturn nounwind {
+void t1() __attribute__((noreturn));
+void t1() { while (1) {} }
+
+// CHECK: define void @t2() nounwind {
+void t2() __attribute__((nothrow));
+void t2() {}
-// RUN: grep 'define i[0-9]* @t19()' %t &&
+// CHECK: define weak void @t3() nounwind {
+void t3() __attribute__((weak));
+void t3() {}
+
+// CHECK: define hidden void @t4() nounwind {
+void t4() __attribute__((visibility("hidden")));
+void t4() {}
+
+// CHECK: define void @t7() noreturn nounwind {
+void t7() __attribute__((noreturn, nothrow));
+void t7() { while (1) {} }
+
+// CHECK: define void @t10() nounwind section "SECT" {
+void t10(void) __attribute__((section("SECT")));
+void t10(void) {}
+// CHECK: define void @t11() nounwind section "SECT" {
+void __attribute__((section("SECT"))) t11(void) {}
+
+// CHECK: define i32 @t19() nounwind {
extern int t19(void) __attribute__((weak_import));
int t19(void) {
return 10;
}
-// RUN: true
+// CHECK:define void @t20() nounwind {
+// CHECK-NEXT:entry:
+// CHECK-NEXT: call void @abort()
+// CHECK-NEXT: unreachable
+void t20(void) {
+ __builtin_abort();
+}
diff --git a/test/CodeGen/blocks-2.c b/test/CodeGen/blocks-2.c
index 5ee2a73a82c9..bc6c2b916abd 100644
--- a/test/CodeGen/blocks-2.c
+++ b/test/CodeGen/blocks-2.c
@@ -1,6 +1,7 @@
-// RUN: clang-cc -g %s -emit-llvm -o %t -fblocks
+// RUN: clang-cc -g %s -emit-llvm -o %t -fblocks &&
// RUN: grep "func.start" %t | count 4
// 1 declaration, 1 bar, 1 test_block_dbg and 1 for the block.
+// XFAIL
static __inline__ __attribute__((always_inline)) int bar(int va, int vb) { return (va == vb); }
diff --git a/test/CodeGen/blocks-aligned-byref-variable.c b/test/CodeGen/blocks-aligned-byref-variable.c
new file mode 100644
index 000000000000..1ae306254157
--- /dev/null
+++ b/test/CodeGen/blocks-aligned-byref-variable.c
@@ -0,0 +1,19 @@
+// RUN: clang-cc -emit-llvm -o - -triple x86_64-apple-darwin10 &&
+// RUN: clang-cc -emit-llvm -o - -triple i386-apple-darwin10
+typedef int __attribute__((aligned(32))) ai;
+
+void f() {
+ __block ai a = 10;
+
+ ^{
+ a = 20;
+ }();
+}
+
+void g() {
+ __block double a = 10;
+
+ ^{
+ a = 20;
+ }();
+}
diff --git a/test/CodeGen/blocks-seq.c b/test/CodeGen/blocks-seq.c
index f637fbc0782e..3ff241e3f6e3 100644
--- a/test/CodeGen/blocks-seq.c
+++ b/test/CodeGen/blocks-seq.c
@@ -1,13 +1,13 @@
-// RUN: clang-cc -fblocks -triple x86_64-apple-darwin10 -emit-llvm -o %t %s &&
-// RUN: grep '%call = call i32 (...)\* @rhs()' %t | count 1 &&
-// If this fails, see about sliding %4, %5, %6 and %7...
-// RUN: grep '%forwarding1 = getelementptr %0\* %i, i32 0, i32 1' %t | count 1 &&
-// RUN: grep '%4 = bitcast i8\*\* %forwarding1 to %0\*\*' %t | count 1 &&
-// RUN: grep '%5 = load %0\*\* %4' %t | count 1 &&
-// RUN: grep '%call2 = call i32 (...)\* @rhs()' %t | count 1 &&
-// RUN: grep '%forwarding3 = getelementptr %0\* %i, i32 0, i32 1' %t | count 1 &&
-// RUN: grep '%6 = bitcast i8\*\* %forwarding3 to %0\*\*' %t | count 1 &&
-// RUN: grep '%7 = load %0\*\* %6' %t | count 1
+// FIXME: We forcibly strip the names so that the test doesn't vary between
+// builds with and without asserts. We need a better solution for this.
+
+// RUN: clang-cc -fblocks -triple x86_64-apple-darwin10 -emit-llvm-bc -o - %s | opt -strip | llvm-dis > %t &&
+// RUN: grep '%6 = call i32 (...)\* @rhs()' %t | count 1 &&
+// RUN: grep '%7 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1 &&
+// RUN: grep '%8 = load %0\*\* %7' %t | count 1 &&
+// RUN: grep '%10 = call i32 (...)\* @rhs()' %t | count 1 &&
+// RUN: grep '%11 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1 &&
+// RUN: grep '%12 = load %0\*\* %11' %t | count 1
int rhs();
diff --git a/test/CodeGen/boolassign.c b/test/CodeGen/boolassign.c
index 2d14f8c1de19..73aab8db7cb1 100644
--- a/test/CodeGen/boolassign.c
+++ b/test/CodeGen/boolassign.c
@@ -1,6 +1,7 @@
// RUN: clang-cc %s -emit-llvm -o %t
int testBoolAssign(void) {
-int ss;
-if ((ss = ss && ss)) {}
+ int ss;
+ if ((ss = ss && ss)) {}
+ return 1;
}
diff --git a/test/CodeGen/builtin-attributes.c b/test/CodeGen/builtin-attributes.c
new file mode 100644
index 000000000000..184e9676edaa
--- /dev/null
+++ b/test/CodeGen/builtin-attributes.c
@@ -0,0 +1,12 @@
+// RUN: clang-cc -triple arm-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: declare arm_aapcscc i32 @printf(i8*, ...)
+void f0() {
+ printf("a\n");
+}
+
+// CHECK: call arm_aapcscc void @exit
+// CHECK: unreachable
+void f1() {
+ exit(1);
+}
diff --git a/test/CodeGen/builtins-ffs_parity_popcount.c b/test/CodeGen/builtins-ffs_parity_popcount.c
index 47469985eeda..e3fa4d2d8212 100644
--- a/test/CodeGen/builtins-ffs_parity_popcount.c
+++ b/test/CodeGen/builtins-ffs_parity_popcount.c
@@ -1,5 +1,5 @@
-// RUN: clang-cc -emit-llvm -o - %s > %t
-// RUN: ! grep "__builtin" %t
+// RUN: clang-cc -emit-llvm -o - %s > %t &&
+// RUN: not grep "__builtin" %t
#include <stdio.h>
diff --git a/test/CodeGen/builtins-powi.c b/test/CodeGen/builtins-powi.c
index 73f752f5e80e..5b413a889502 100644
--- a/test/CodeGen/builtins-powi.c
+++ b/test/CodeGen/builtins-powi.c
@@ -1,5 +1,5 @@
-// RUN: clang-cc -emit-llvm -o - %s > %t
-// RUN: ! grep "__builtin" %t
+// RUN: clang-cc -emit-llvm -o - %s > %t &&
+// RUN: not grep "__builtin" %t
#include <stdio.h>
#include <stdlib.h>
diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c
index ce5cd74bd4c4..165db9c26753 100644
--- a/test/CodeGen/builtins.c
+++ b/test/CodeGen/builtins.c
@@ -54,6 +54,8 @@ int main() {
P(islessgreater, (1., 2.));
P(isunordered, (1., 2.));
+ P(isnan, (1.));
+
// Bitwise & Numeric Functions
P(abs, (N));
diff --git a/test/CodeGen/cast-to-union.c b/test/CodeGen/cast-to-union.c
index 6098bcc5a07c..674299294928 100644
--- a/test/CodeGen/cast-to-union.c
+++ b/test/CodeGen/cast-to-union.c
@@ -1,7 +1,7 @@
-// RUN: clang-cc -emit-llvm < %s -o %t &&
-// RUN: grep "store i32 351, i32*" %t &&
-// RUN: grep "w = global %0 <{ i32 2, i8 0, i8 0, i8 0, i8 0 }>" %t &&
-// RUN: grep "y = global %1 <{ double 7.300000e+01 }>" %t
+// RUN: clang-cc -emit-llvm %s -o - | FileCheck %s
+// CHECK: w = global %0 { i32 2, [4 x i8] zeroinitializer }
+// CHECK: y = global %union.u { double 7.300000e+0{{[0]*}}1 }
+// CHECK: store i32 351, i32
union u { int i; double d; };
diff --git a/test/CodeGen/conditional.c b/test/CodeGen/conditional.c
index 22286705c89c..8a30463cb7e4 100644
--- a/test/CodeGen/conditional.c
+++ b/test/CodeGen/conditional.c
@@ -1,11 +1,10 @@
// RUN: clang-cc -emit-llvm %s -o %t
-float test1(int cond, float a, float b)
-{
+float test1(int cond, float a, float b) {
return cond ? a : b;
}
-double test2(int cond, float a, double b)
-{
+
+double test2(int cond, float a, double b) {
return cond ? a : b;
}
@@ -16,8 +15,8 @@ void test3(){
}
void test4() {
-int i; short j;
-float* k = 1 ? &i : &j;
+ int i; short j;
+ float* k = 1 ? &i : &j;
}
void test5() {
@@ -33,12 +32,10 @@ void* test8() {return 1 ? test6 : test7;}
void _efree(void *ptr);
-void _php_stream_free3()
-{
- (1 ? free(0) : _efree(0));
+void _php_stream_free3() {
+ (1 ? free(0) : _efree(0));
}
-void _php_stream_free4()
-{
- 1 ? _efree(0) : free(0);
+void _php_stream_free4() {
+ 1 ? _efree(0) : free(0);
}
diff --git a/test/CodeGen/const-init.c b/test/CodeGen/const-init.c
index 0364cc153ff8..29e9c5561527 100644
--- a/test/CodeGen/const-init.c
+++ b/test/CodeGen/const-init.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -triple i386-pc-linux-gnu -verify -emit-llvm -o %t %s &&
+// RUN: clang-cc -triple i386-pc-linux-gnu -verify -emit-llvm -o - %s | FileCheck %s
#include <stdint.h>
@@ -22,44 +22,57 @@ union s2 {
int g0 = (int)(&(((union s2 *) 0)->f0.f0) - 0);
-// RUN: grep '@g1x = global %. { double 1.000000e+00, double 0.000000e+00 }' %t &&
+// CHECK: @g1x = global {{%.}} { double 1.000000e+00{{[0]*}}, double 0.000000e+00{{[0]*}} }
_Complex double g1x = 1.0f;
-// RUN: grep '@g1y = global %. { double 0.000000e+00, double 1.000000e+00 }' %t &&
+// CHECK: @g1y = global {{%.}} { double 0.000000e+00{{[0]*}}, double 1.000000e+00{{[0]*}} }
_Complex double g1y = 1.0fi;
-// RUN: grep '@g1 = global %. { i8 1, i8 10 }' %t &&
+// CHECK: @g1 = global {{%.}} { i8 1, i8 10 }
_Complex char g1 = (char) 1 + (char) 10 * 1i;
-// RUN: grep '@g2 = global %2 { i32 1, i32 10 }' %t &&
+// CHECK: @g2 = global %2 { i32 1, i32 10 }
_Complex int g2 = 1 + 10i;
-// RUN: grep '@g3 = global %. { float 1.000000e+00, float 1.000000e+01 }' %t &&
+// CHECK: @g3 = global {{%.}} { float 1.000000e+00{{[0]*}}, float 1.000000e+0{{[0]*}}1 }
_Complex float g3 = 1.0 + 10.0i;
-// RUN: grep '@g4 = global %. { double 1.000000e+00, double 1.000000e+01 }' %t &&
+// CHECK: @g4 = global {{%.}} { double 1.000000e+00{{[0]*}}, double 1.000000e+0{{[0]*}}1 }
_Complex double g4 = 1.0 + 10.0i;
-// RUN: grep '@g5 = global %2 zeroinitializer' %t &&
+// CHECK: @g5 = global %2 zeroinitializer
_Complex int g5 = (2 + 3i) == (5 + 7i);
-// RUN: grep '@g6 = global %. { double -1.100000e+01, double 2.900000e+01 }' %t &&
+// CHECK: @g6 = global {{%.}} { double -1.100000e+0{{[0]*}}1, double 2.900000e+0{{[0]*}}1 }
_Complex double g6 = (2.0 + 3.0i) * (5.0 + 7.0i);
-// RUN: grep '@g7 = global i32 1' %t &&
+// CHECK: @g7 = global i32 1
int g7 = (2 + 3i) * (5 + 7i) == (-11 + 29i);
-// RUN: grep '@g8 = global i32 1' %t &&
+// CHECK: @g8 = global i32 1
int g8 = (2.0 + 3.0i) * (5.0 + 7.0i) == (-11.0 + 29.0i);
-// RUN: grep '@g9 = global i32 0' %t &&
+// CHECK: @g9 = global i32 0
int g9 = (2 + 3i) * (5 + 7i) != (-11 + 29i);
-// RUN: grep '@g10 = global i32 0' %t &&
+// CHECK: @g10 = global i32 0
int g10 = (2.0 + 3.0i) * (5.0 + 7.0i) != (-11.0 + 29.0i);
+// PR5108
+// CHECK: @gv1 = global %4 <{ i32 0, i8 7 }>, align 1
+struct {
+ unsigned long a;
+ unsigned long b:3;
+} __attribute__((__packed__)) gv1 = { .a = 0x0, .b = 7, };
+
+// PR5118
+// CHECK: @gv2 = global %5 <{ i8 1, i8* null }>, align 1
+struct {
+ unsigned char a;
+ char *b;
+} __attribute__((__packed__)) gv2 = { 1, (void*)0 };
// Global references
-// RUN: grep '@g11.l0 = internal global i32 ptrtoint (i32 ()\* @g11 to i32)' %t &&
+// CHECK: @g11.l0 = internal global i32 ptrtoint (i32 ()* @g11 to i32)
long g11() {
static long l0 = (long) g11;
return l0;
}
-// RUN: grep '@g12 = global i32 ptrtoint (i8\* @g12_tmp to i32)' %t &&
+// CHECK: @g12 = global i32 ptrtoint (i8* @g12_tmp to i32)
static char g12_tmp;
long g12 = (long) &g12_tmp;
-// RUN: grep '@g13 = global \[1 x .struct.g13_s0\] \[.struct.g13_s0 <{ i32 ptrtoint (i8\* @g12_tmp to i32) }>\]' %t &&
+// CHECK: @g13 = global [1 x %struct.g13_s0] [%struct.g13_s0 { i32 ptrtoint (i8* @g12_tmp to i32) }]
struct g13_s0 {
long a;
};
@@ -67,26 +80,25 @@ struct g13_s0 g13[] = {
{ (long) &g12_tmp }
};
-// RUN: grep '@g14 = global i8\* inttoptr (i64 100 to i8\*)' %t &&
+// CHECK: @g14 = global i8* inttoptr (i64 100 to i8*)
void *g14 = (void*) 100;
-// RUN: grep '@g15 = global i32 -1' %t &&
+// CHECK: @g15 = global i32 -1
int g15 = (int) (char) ((void*) 0 + 255);
-// RUN: grep '@g16 = global i64 4294967295' %t &&
+// CHECK: @g16 = global i64 4294967295
long long g16 = (long long) ((void*) 0xFFFFFFFF);
-// RUN: grep '@g17 = global i32\* @g15' %t &&
+// CHECK: @g17 = global i32* @g15
int *g17 = (int *) ((long) &g15);
-// RUN: grep '@g18.p = internal global \[1 x i32\*\] \[i32\* @g19\]' %t &&
+// CHECK: @g18.p = internal global [1 x i32*] [i32* @g19]
void g18(void) {
extern int g19;
static int *p[] = { &g19 };
}
-// RUN: grep '@g20.l0 = internal global .struct.g20_s1 <{ .struct.g20_s0\* null, .struct.g20_s0\*\* getelementptr (.struct.g20_s1\* @g20.l0, i32 0, i32 0) }>' %t &&
-
+// CHECK: @g20.l0 = internal global %struct.g20_s1 { %struct.g20_s0* null, %struct.g20_s0** getelementptr inbounds (%struct.g20_s1* @g20.l0, i32 0, i32 0) }
struct g20_s0;
struct g20_s1 {
struct g20_s0 *f0, **f1;
@@ -99,6 +111,3 @@ void *g20(void) {
// PR4108
struct g21 {int g21;};
const struct g21 g21 = (struct g21){1};
-
-// RUN: true
-
diff --git a/test/CodeGen/darwin-string-literals.c b/test/CodeGen/darwin-string-literals.c
index ff245fcc7a5c..04e43a234d19 100644
--- a/test/CodeGen/darwin-string-literals.c
+++ b/test/CodeGen/darwin-string-literals.c
@@ -1,10 +1,16 @@
-// RUN: clang-cc -triple i386-apple-darwin9 -emit-llvm %s -o %t &&
+// RUN: clang-cc -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix LSB %s &&
-// RUN: grep -F '@"\01LC" = internal constant [8 x i8] c"string0\00"' %t &&
-// RUN: grep -F '@"\01LC1" = internal constant [8 x i8] c"string1\00", section "__TEXT,__cstring,cstring_literals"' %t &&
-// RUN: grep -F '@__utf16_string_ = internal global [35 x i8] c"h\00e\00l\00l\00o\00 \00\92! \00\03& \00\90! \00w\00o\00r\00l\00d\00\00", section "__TEXT,__ustring", align 2' %t &&
-// RUN: true
+// CHECK-LSB: @.str = private constant [8 x i8] c"string0\00"
+// CHECK-LSB: @.str1 = private constant [8 x i8] c"string1\00"
+// CHECK-LSB: @.str2 = internal constant [36 x i8] c"h\00e\00l\00l\00o\00 \00\92! \00\03& \00\90! \00w\00o\00r\00l\00d\00\00\00", section "__TEXT,__ustring", align 2
+
+// RUN: clang-cc -triple powerpc-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix MSB %s
+
+// CHECK-MSB: @.str = private constant [8 x i8] c"string0\00"
+// CHECK-MSB: @.str1 = private constant [8 x i8] c"string1\00"
+// CHECK-MSB: @.str2 = internal constant [36 x i8] c"\00h\00e\00l\00l\00o\00 !\92\00 &\03\00 !\90\00 \00w\00o\00r\00l\00d\00\00", section "__TEXT,__ustring", align 2
const char *g0 = "string0";
const void *g1 = __builtin___CFStringMakeConstantString("string1");
const void *g2 = __builtin___CFStringMakeConstantString("hello \u2192 \u2603 \u2190 world");
+const void *g3 = __builtin___CFStringMakeConstantString("testâ„¢");
diff --git a/test/CodeGen/debug-info.c b/test/CodeGen/debug-info.c
index e0ec2c9027cf..beee7ac9b61a 100644
--- a/test/CodeGen/debug-info.c
+++ b/test/CodeGen/debug-info.c
@@ -24,14 +24,14 @@ char xpto[];
// PR3427
struct foo {
- int a;
- void *ptrs[];
+ int a;
+ void *ptrs[];
};
struct foo bar;
// PR4143
struct foo2 {
- enum bar *bar;
+ enum bar *bar;
};
struct foo2 foo2;
diff --git a/test/CodeGen/designated-initializers.c b/test/CodeGen/designated-initializers.c
index 466933928665..f20bc782b6ac 100644
--- a/test/CodeGen/designated-initializers.c
+++ b/test/CodeGen/designated-initializers.c
@@ -1,5 +1,6 @@
-// RUN: clang-cc -triple i386-unknown-unknown %s -emit-llvm -o - | grep "<{ i8\* null, i32 1024 }>" &&
-// RUN: clang-cc -triple i386-unknown-unknown %s -emit-llvm -o - | grep "i32 0, i32 22"
+// RUN: clang-cc -triple i386-unknown-unknown %s -emit-llvm -o %t &&
+// RUN: grep "{ i8\* null, i32 1024 }" %t &&
+// RUN: grep "i32 0, i32 22" %t
struct foo {
void *a;
diff --git a/test/CodeGen/exprs.c b/test/CodeGen/exprs.c
index 36cfff9e8a69..a0e5b7644aeb 100644
--- a/test/CodeGen/exprs.c
+++ b/test/CodeGen/exprs.c
@@ -15,7 +15,7 @@ void *test(int *i) {
}
_Bool test2b;
-int test2() {if (test2b);}
+int test2() { if (test2b); return 0; }
// PR1921
int test3() {
@@ -48,9 +48,9 @@ int ola() {
// this one shouldn't fold as well
void eMaisUma() {
- double t[1];
- if (*t)
- return;
+ double t[1];
+ if (*t)
+ return;
}
// rdar://6520707
diff --git a/test/CodeGen/ext-vector-shuffle.c b/test/CodeGen/ext-vector-shuffle.c
index 37d3ed42d060..f53db945da03 100644
--- a/test/CodeGen/ext-vector-shuffle.c
+++ b/test/CodeGen/ext-vector-shuffle.c
@@ -1,5 +1,5 @@
-// RUN: clang-cc %s -emit-llvm -o - | not grep 'extractelement'
-// RUN: clang-cc %s -emit-llvm -o - | not grep 'insertelement'
+// RUN: clang-cc %s -emit-llvm -o - | not grep 'extractelement' &&
+// RUN: clang-cc %s -emit-llvm -o - | not grep 'insertelement' &&
// RUN: clang-cc %s -emit-llvm -o - | grep 'shufflevector'
typedef __attribute__(( ext_vector_type(2) )) float float2;
diff --git a/test/CodeGen/ext-vector.c b/test/CodeGen/ext-vector.c
index e3b6211ee991..6a246db63515 100644
--- a/test/CodeGen/ext-vector.c
+++ b/test/CodeGen/ext-vector.c
@@ -115,9 +115,21 @@ void test7(int4 *ap, int4 *bp, int c) {
a /= c;
a %= c;
- // Vector comparisons can sometimes crash the x86 backend: rdar://6326239,
- // reject them until the implementation is stable.
-#if 0
+ // Vector comparisons.
+ int4 cmp;
+ cmp = a < b;
+ cmp = a <= b;
+ cmp = a < b;
+ cmp = a >= b;
+ cmp = a == b;
+ cmp = a != b;
+}
+
+void test8(float4 *ap, float4 *bp, int c) {
+ float4 a = *ap;
+ float4 b = *bp;
+
+ // Vector comparisons.
int4 cmp;
cmp = a < b;
cmp = a <= b;
@@ -125,5 +137,4 @@ void test7(int4 *ap, int4 *bp, int c) {
cmp = a >= b;
cmp = a == b;
cmp = a != b;
-#endif
}
diff --git a/test/CodeGen/function-attributes.c b/test/CodeGen/function-attributes.c
index ba2e4e4d564d..d2d3b031a83b 100644
--- a/test/CodeGen/function-attributes.c
+++ b/test/CodeGen/function-attributes.c
@@ -56,7 +56,7 @@ int ai_1() { return 4; }
static __inline__ __attribute__((always_inline))
struct {
int a, b, c, d, e;
-} ai_2() { }
+} ai_2() { while (1) {} }
int foo() {
diff --git a/test/CodeGen/functions.c b/test/CodeGen/functions.c
index 12dff1b72cbc..dba29316e1a3 100644
--- a/test/CodeGen/functions.c
+++ b/test/CodeGen/functions.c
@@ -3,11 +3,11 @@
int g();
int foo(int i) {
- return g(i);
+ return g(i);
}
int g(int i) {
- return g(i);
+ return g(i);
}
// rdar://6110827
@@ -32,6 +32,7 @@ void f1() {}
// RUN: grep 'define .* @f3' %t | not grep -F '...'
struct foo { int X, Y, Z; } f3() {
+ while (1) {}
}
// PR4423 - This shouldn't crash in codegen
diff --git a/test/CodeGen/global-decls.c b/test/CodeGen/global-decls.c
index 80222ea85ef1..decb6a981c7f 100644
--- a/test/CodeGen/global-decls.c
+++ b/test/CodeGen/global-decls.c
@@ -11,7 +11,7 @@ int g0_common __attribute__((weak));
// RUN: grep '@g0_def = weak global i32' %t &&
int g0_def __attribute__((weak)) = 52;
// RUN: grep 'define weak i32 @g1_def()' %t &&
-int __attribute__((weak)) g1_def (void) {}
+int __attribute__((weak)) g1_def (void) { return 0; }
// Force _ext references
void f0() {
diff --git a/test/CodeGen/global-init.c b/test/CodeGen/global-init.c
index 4b769f8ccbb0..2368422f3ab7 100644
--- a/test/CodeGen/global-init.c
+++ b/test/CodeGen/global-init.c
@@ -1,7 +1,30 @@
-// RUN: clang-cc -emit-llvm -o - %s | not grep "common"
+// RUN: clang-cc -emit-llvm -o - -triple i386-linux-gnu %s | FileCheck %s
// This checks that the global won't be marked as common.
// (It shouldn't because it's being initialized).
int a;
int a = 242;
+// CHECK: @a = global i32 242
+
+// This should get normal weak linkage.
+int c __attribute__((weak))= 0;
+// CHECK: @c = weak global i32 0
+
+
+
+// Since this is marked const, it should get weak_odr linkage, since all
+// definitions have to be the same.
+// CHECK: @d = weak_odr constant i32 0
+const int d __attribute__((weak))= 0;
+
+
+
+// NOTE: tentative definitions are processed at the end of the translation unit.
+
+// This shouldn't be emitted as common because it has an explicit section.
+// rdar://7119244
+int b __attribute__((section("foo")));
+
+// CHECK: @b = global i32 0, section "foo"
+
diff --git a/test/CodeGen/global-with-initialiser.c b/test/CodeGen/global-with-initialiser.c
index 29b4e21b9129..d253782f66e1 100644
--- a/test/CodeGen/global-with-initialiser.c
+++ b/test/CodeGen/global-with-initialiser.c
@@ -17,9 +17,9 @@ long double globalLongDouble = 1;
long double globalLongDoubleArray[5] = { 1.0, 2.0 };
struct Struct {
- int member1;
- float member2;
- char *member3;
+ int member1;
+ float member2;
+ char *member3;
};
struct Struct globalStruct = { 1, 2.0f, "foobar"};
diff --git a/test/CodeGen/globalinit.c b/test/CodeGen/globalinit.c
index 2798cae712a2..b3d0cb54d15c 100644
--- a/test/CodeGen/globalinit.c
+++ b/test/CodeGen/globalinit.c
@@ -37,7 +37,7 @@ static int a = { 1 };
// References to enums.
enum {
- EnumA, EnumB
+ EnumA, EnumB
};
int c[] = { EnumA, EnumB };
diff --git a/test/CodeGen/init-with-member-expr.c b/test/CodeGen/init-with-member-expr.c
index 7750dbf9869d..197a9ab4e3b8 100644
--- a/test/CodeGen/init-with-member-expr.c
+++ b/test/CodeGen/init-with-member-expr.c
@@ -14,7 +14,7 @@ typedef struct mark_header_tag {
} mark_header_t;
int is_rar_archive(int fd) {
const mark_header_t rar_hdr[2] = {{0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}, {'U', 'n', 'i', 'q', 'u', 'E', '!'}};
- foo(rar_hdr);
+ foo(rar_hdr);
return 0;
}
diff --git a/test/CodeGen/inline.c b/test/CodeGen/inline.c
index 234f1f8d93a8..bf17fd7c22ba 100644
--- a/test/CodeGen/inline.c
+++ b/test/CodeGen/inline.c
@@ -1,5 +1,5 @@
-// RUN: echo "C89 tests:" &&
-// RUN: clang %s -emit-llvm -S -o %t -std=c89 &&
+// RUN: echo "GNU89 tests:" &&
+// RUN: clang %s -emit-llvm -S -o %t -std=gnu89 &&
// RUN: grep "define available_externally i32 @ei()" %t &&
// RUN: grep "define i32 @foo()" %t &&
// RUN: grep "define i32 @bar()" %t &&
@@ -24,9 +24,9 @@
// RUN: grep "define available_externally void @gnu_ei_inline()" %t &&
// RUN: grep "define i32 @test1" %t &&
// RUN: grep "define i32 @test2" %t &&
-// RUN: grep "define available_externally void @test3" %t &&
+// RUN: grep "define void @test3" %t &&
// RUN: grep "define available_externally i32 @test4" %t &&
-// RUN: grep "define i32 @test5" %t &&
+// RUN: grep "define available_externally i32 @test5" %t &&
// RUN: echo "\nC++ tests:" &&
// RUN: clang %s -emit-llvm -S -o %t -std=c++98 &&
@@ -67,20 +67,20 @@ void test_test2() { test2(); }
// PR3989
extern __inline void test3() __attribute__((gnu_inline));
-__inline void test3() {}
-
-void test_test3() { test3(); }
+__inline void __attribute__((gnu_inline)) test3() {}
extern int test4(void);
extern __inline __attribute__ ((__gnu_inline__)) int test4(void)
{
+ return 0;
}
void test_test4() { test4(); }
-extern __inline int test5(void);
+extern __inline int test5(void) __attribute__ ((__gnu_inline__));
extern __inline int __attribute__ ((__gnu_inline__)) test5(void)
{
+ return 0;
}
void test_test5() { test5(); }
diff --git a/test/CodeGen/inline2.c b/test/CodeGen/inline2.c
new file mode 100644
index 000000000000..6f165f50f8b7
--- /dev/null
+++ b/test/CodeGen/inline2.c
@@ -0,0 +1,62 @@
+// RUN: clang-cc -std=gnu89 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix GNU89 %s &&
+// RUN: clang-cc -std=c99 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix C99 %s
+
+// CHECK-GNU89: define i32 @f0()
+// CHECK-C99: define i32 @f0()
+int f0(void);
+int f0(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f1()
+// CHECK-C99: define i32 @f1()
+inline int f1(void);
+int f1(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f2()
+// CHECK-C99: define i32 @f2()
+int f2(void);
+inline int f2(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f3()
+// CHECK-C99: define i32 @f3()
+extern inline int f3(void);
+int f3(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f5()
+// CHECK-C99: define i32 @f5()
+extern inline int f5(void);
+inline int f5(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f6()
+// CHECK-C99: define i32 @f6()
+inline int f6(void);
+extern inline int f6(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f7()
+// CHECK-C99: define i32 @f7()
+extern inline int f7(void);
+extern int f7(void) { return 0; }
+
+// CHECK-GNU89: define i32 @fA()
+inline int fA(void) { return 0; }
+
+// CHECK-GNU89: define available_externally i32 @f4()
+// CHECK-C99: define i32 @f4()
+int f4(void);
+extern inline int f4(void) { return 0; }
+
+// CHECK-GNU89: define available_externally i32 @f8()
+// CHECK-C99: define i32 @f8()
+extern int f8(void);
+extern inline int f8(void) { return 0; }
+
+// CHECK-GNU89: define available_externally i32 @f9()
+// CHECK-C99: define i32 @f9()
+extern inline int f9(void);
+extern inline int f9(void) { return 0; }
+
+// CHECK-C99: define available_externally i32 @fA()
+
+int test_all() {
+ return f0() + f1() + f2() + f3() + f4() + f5() + f6() + f7() + f8() + f9()
+ + fA();
+}
diff --git a/test/CodeGen/packed-union.c b/test/CodeGen/packed-union.c
new file mode 100644
index 000000000000..d11d3a490234
--- /dev/null
+++ b/test/CodeGen/packed-union.c
@@ -0,0 +1,16 @@
+// RUN: clang-cc -triple x86_64-apple-darwin10 -emit-llvm %s -o %t &&
+
+// RUN: grep "struct._attrs = type <{ i32, i8 }>" %t &&
+typedef struct _attrs {
+ unsigned file_attributes;
+ unsigned char filename_length;
+} __attribute__((__packed__)) attrs;
+
+// RUN: grep "union._attr_union = type <{ i32, i8 }>" %t
+typedef union _attr_union {
+ attrs file_attrs;
+ unsigned owner_id;
+} __attribute__((__packed__)) attr_union;
+
+attr_union u;
+
diff --git a/test/CodeGen/parameter-passing.c b/test/CodeGen/parameter-passing.c
index 2ace299ef770..dce0ff80cdc4 100644
--- a/test/CodeGen/parameter-passing.c
+++ b/test/CodeGen/parameter-passing.c
@@ -11,7 +11,7 @@
// RUN: clang-cc %s -triple x86_64-unknown-unknown -O3 -emit-llvm -o %t &&
// RUN: not grep '@g0' %t &&
-// RUN: clang-cc %s -triple ppc-unknown-unknown -O3 -emit-llvm -o %t &&
+// RUN: clang-cc %s -triple powerpc-unknown-unknown -O3 -emit-llvm -o %t &&
// RUN: not grep '@g0' %t &&
// RUN: true
diff --git a/test/CodeGen/pragma-pack-1.c b/test/CodeGen/pragma-pack-1.c
new file mode 100644
index 000000000000..bcfcd5ac3ab9
--- /dev/null
+++ b/test/CodeGen/pragma-pack-1.c
@@ -0,0 +1,7 @@
+// RUN: clang-cc -emit-llvm -o -
+
+// PR4610
+#pragma pack(4)
+struct ref {
+ struct ref *next;
+} refs;
diff --git a/test/CodeGen/pragma-pack-2.c b/test/CodeGen/pragma-pack-2.c
new file mode 100644
index 000000000000..306f02dd8cfe
--- /dev/null
+++ b/test/CodeGen/pragma-pack-2.c
@@ -0,0 +1,23 @@
+// RUN: clang-cc -triple i386-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X32 %s &&
+// CHECK-X32: %struct.s0 = type { i64, i64, i32, [12 x i32] }
+// CHECK-X32: %struct.s1 = type { [15 x i32], %struct.s0 }
+
+// RUN: clang-cc -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X64 %s
+// CHECK-X64: %struct.s0 = type <{ i64, i64, i32, [12 x i32] }>
+// CHECK-X64: %struct.s1 = type <{ [15 x i32], %struct.s0 }>
+
+// rdar://problem/7095436
+#pragma pack(4)
+
+struct s0 {
+ long long a __attribute__((aligned(8)));
+ long long b __attribute__((aligned(8)));
+ unsigned int c __attribute__((aligned(8)));
+ int d[12];
+} a;
+
+struct s1 {
+ int a[15];
+ struct s0 b;
+} b;
+
diff --git a/test/CodeGen/pragma-pack-3.c b/test/CodeGen/pragma-pack-3.c
new file mode 100644
index 000000000000..b9166ae5d390
--- /dev/null
+++ b/test/CodeGen/pragma-pack-3.c
@@ -0,0 +1,19 @@
+// RUN: clang-cc -triple i386-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X32 %s &&
+// CHECK-X32: %struct.menu = type <{ i8*, i8, i8 }>
+// CHECK-X32: %union.command = type <{ i8*, [2 x i8] }>
+
+// RUN: clang-cc -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X64 %s
+// CHECK-X64: %struct.menu = type <{ i8*, i8, i8 }>
+// CHECK-X64: %union.command = type <{ i8*, [2 x i8] }>
+
+// <rdar://problem/7184250>
+#pragma pack(push, 2)
+typedef union command {
+ void *windowRef;
+ struct menu {
+ void *menuRef;
+ unsigned char menuItemIndex;
+ } menu;
+} command;
+
+command c;
diff --git a/test/CodeGen/pragma-weak.c b/test/CodeGen/pragma-weak.c
new file mode 100644
index 000000000000..497039a8f42c
--- /dev/null
+++ b/test/CodeGen/pragma-weak.c
@@ -0,0 +1,165 @@
+// RUN: clang-cc -emit-llvm %s -o - -verify | FileCheck %s
+
+// CHECK: @weakvar = weak global
+// CHECK: @__weakvar_alias = common global
+// CHECK: @correct_linkage = weak global
+
+
+// CHECK: @both = alias void ()* @__both
+// CHECK: @both2 = alias void ()* @__both2
+// CHECK: @both3 = alias weak void ()* @__both3
+// CHECK: @a3 = alias weak void ()* @__a3
+// CHECK: @weakvar_alias = alias weak i32* @__weakvar_alias
+// CHECK: @foo = alias weak void ()* @__foo
+// CHECK: @foo2 = alias weak void ()* @__foo2
+// CHECK: @stutter = alias weak void ()* @__stutter
+// CHECK: @stutter2 = alias weak void ()* @__stutter2
+// CHECK: @declfirst = alias weak void ()* @__declfirst
+// CHECK: @declfirstattr = alias weak void ()* @__declfirstattr
+// CHECK: @mix2 = alias weak void ()* @__mix2
+// CHECK: @a1 = alias weak void ()* @__a1
+// CHECK: @xxx = alias weak void ()* @__xxx
+
+
+
+// CHECK: define weak void @weakdef()
+
+
+#pragma weak weakvar
+int weakvar;
+
+#pragma weak weakdef
+void weakdef(void) {}
+
+#pragma weak param // expected-warning {{weak identifier 'param' never declared}}
+#pragma weak correct_linkage
+void f(int param) {
+ int correct_linkage;
+}
+
+#pragma weak weakvar_alias = __weakvar_alias
+int __weakvar_alias;
+
+#pragma weak foo = __foo
+void __foo(void) {}
+// CHECK: define void @__foo()
+
+
+void __foo2(void) {}
+#pragma weak foo2 = __foo2
+// CHECK: define void @__foo2()
+
+
+///// test errors
+
+#pragma weak unused // expected-warning {{weak identifier 'unused' never declared}}
+#pragma weak unused_alias = __unused_alias // expected-warning {{weak identifier '__unused_alias' never declared}}
+
+#pragma weak td // expected-warning {{weak identifier 'td' never declared}}
+typedef int td;
+
+#pragma weak td2 = __td2 // expected-warning {{weak identifier '__td2' never declared}}
+typedef int __td2;
+
+
+///// test weird cases
+
+// test repeats
+
+#pragma weak stutter = __stutter
+#pragma weak stutter = __stutter
+void __stutter(void) {}
+// CHECK: define void @__stutter()
+
+void __stutter2(void) {}
+#pragma weak stutter2 = __stutter2
+#pragma weak stutter2 = __stutter2
+// CHECK: define void @__stutter2()
+
+
+// test decl/pragma weak order
+
+void __declfirst(void);
+#pragma weak declfirst = __declfirst
+void __declfirst(void) {}
+// CHECK: define void @__declfirst()
+
+void __declfirstattr(void) __attribute((noinline));
+#pragma weak declfirstattr = __declfirstattr
+void __declfirstattr(void) {}
+// CHECK: define void @__declfirstattr()
+
+//// test that other attributes are preserved
+
+//// ensure that pragma weak/__attribute((weak)) play nice
+
+void mix(void);
+#pragma weak mix
+__attribute((weak)) void mix(void) { }
+// CHECK: define weak void @mix()
+
+// ensure following __attributes are preserved and that only a single
+// alias is generated
+#pragma weak mix2 = __mix2
+void __mix2(void) __attribute((noinline));
+void __mix2(void) __attribute((noinline));
+void __mix2(void) {}
+// CHECK: define void @__mix2()
+
+////////////// test #pragma weak/__attribute combinations
+
+// if the SAME ALIAS is already declared then it overrides #pragma weak
+// resulting in a non-weak alias in this case
+void both(void) __attribute((alias("__both")));
+#pragma weak both = __both
+void __both(void) {}
+// CHECK: define void @__both()
+
+// if the TARGET is previously declared then whichever aliasing method
+// comes first applies and subsequent aliases are discarded.
+// TODO: warn about this
+
+void __both2(void);
+void both2(void) __attribute((alias("__both2"))); // first, wins
+#pragma weak both2 = __both2
+void __both2(void) {}
+// CHECK: define void @__both2()
+
+void __both3(void);
+#pragma weak both3 = __both3 // first, wins
+void both3(void) __attribute((alias("__both3")));
+void __both3(void) {}
+// CHECK: define void @__both3()
+
+///////////// ensure that #pragma weak does not alter existing __attributes()
+
+void __a1(void) __attribute((noinline));
+#pragma weak a1 = __a1
+void __a1(void) {}
+// CHECK: define void @__a1()
+
+// attributes introduced BEFORE a combination of #pragma weak and alias()
+// hold...
+void __a3(void) __attribute((noinline));
+#pragma weak a3 = __a3
+void a3(void) __attribute((alias("__a3")));
+void __a3(void) {}
+// CHECK: define void @__a3()
+
+#pragma weak xxx = __xxx
+__attribute((pure,noinline,const,fastcall)) void __xxx(void) { }
+// CHECK: void @__xxx()
+
+/// TODO: stuff that still doesn't work
+
+// due to the fact that disparate TopLevelDecls cannot affect each other
+// (due to clang's Parser and ASTConsumer behavior, and quite reasonable)
+// #pragma weak must appear before or within the same TopLevelDecl as it
+// references.
+void yyy(void){}
+void zzz(void){}
+#pragma weak yyy
+// NOTE: weak doesn't apply, not before or in same TopLevelDec(!)
+// CHECK: define void @yyy()
+
+int correct_linkage;
diff --git a/test/CodeGen/predefined-expr.c b/test/CodeGen/predefined-expr.c
new file mode 100644
index 000000000000..9b645931a4a7
--- /dev/null
+++ b/test/CodeGen/predefined-expr.c
@@ -0,0 +1,45 @@
+// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @__func__.plainFunction = private constant [14 x i8] c"plainFunction\00"
+// CHECK: @__PRETTY_FUNCTION__.plainFunction = private constant [21 x i8] c"void plainFunction()\00"
+// CHECK: @__func__.externFunction = private constant [15 x i8] c"externFunction\00"
+// CHECK: @__PRETTY_FUNCTION__.externFunction = private constant [22 x i8] c"void externFunction()\00"
+// CHECK: @__func__.privateExternFunction = private constant [22 x i8] c"privateExternFunction\00"
+// CHECK: @__PRETTY_FUNCTION__.privateExternFunction = private constant [29 x i8] c"void privateExternFunction()\00"
+// CHECK: @__func__.staticFunction = private constant [15 x i8] c"staticFunction\00"
+// CHECK: @__PRETTY_FUNCTION__.staticFunction = private constant [22 x i8] c"void staticFunction()\00"
+
+#include <stdio.h>
+
+void plainFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+extern void externFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+__private_extern__ void privateExternFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+static void staticFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+int main() {
+ plainFunction();
+ externFunction();
+ privateExternFunction();
+ staticFunction();
+
+ return 0;
+}
diff --git a/test/CodeGen/regparm.c b/test/CodeGen/regparm.c
index fdf07ead6de7..28dfae7f628b 100644
--- a/test/CodeGen/regparm.c
+++ b/test/CodeGen/regparm.c
@@ -9,11 +9,10 @@ typedef struct {
} foo;
static void FASTCALL
-reduced(char b, double c, foo* d, double e, int f)
-{
+reduced(char b, double c, foo* d, double e, int f) {
}
int
main(void) {
- reduced(0, 0.0, 0, 0.0, 0);
+ reduced(0, 0.0, 0, 0.0, 0);
}
diff --git a/test/CodeGen/stack-protector.c b/test/CodeGen/stack-protector.c
index bdac853aed62..0b5924d81112 100644
--- a/test/CodeGen/stack-protector.c
+++ b/test/CodeGen/stack-protector.c
@@ -12,8 +12,7 @@
// RUN: not grep 'ssp' %t &&
// RUN: true
-#include <stdio.h>
-#include <string.h>
+int printf(const char * _Format, ...);
void test1(const char *msg) {
char a[strlen(msg) + 1];
diff --git a/test/CodeGen/statements.c b/test/CodeGen/statements.c
index 1ff7601adf68..45bbd9ac024f 100644
--- a/test/CodeGen/statements.c
+++ b/test/CodeGen/statements.c
@@ -11,3 +11,25 @@ bar();
int test2() { return; }
void test3() { return 4; }
+
+void test4() {
+bar:
+baz:
+blong:
+bing:
+ ;
+
+// PR5131
+static long x = &&bar - &&baz;
+static long y = &&baz;
+ &&bing;
+ &&blong;
+ if (y)
+ goto *y;
+
+ goto *x;
+}
+
+// PR3869
+int test5(long long b) { goto *b; }
+
diff --git a/test/CodeGen/staticinit.c b/test/CodeGen/staticinit.c
index 91fcdcf69f00..c68366f2ea77 100644
--- a/test/CodeGen/staticinit.c
+++ b/test/CodeGen/staticinit.c
@@ -2,9 +2,9 @@
// RUN: grep "g.b = internal global i8. getelementptr" %t &&
struct AStruct {
- int i;
- char *s;
- double d;
+ int i;
+ char *s;
+ double d;
};
void f() {
diff --git a/test/CodeGen/stdcall-fastcall.c b/test/CodeGen/stdcall-fastcall.c
index 11b652178ca8..89ed8c9ef672 100644
--- a/test/CodeGen/stdcall-fastcall.c
+++ b/test/CodeGen/stdcall-fastcall.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -emit-llvm < %s | grep 'fastcallcc' | count 4
+// RUN: clang-cc -emit-llvm < %s | grep 'fastcallcc' | count 4 &&
// RUN: clang-cc -emit-llvm < %s | grep 'stdcallcc' | count 4
void __attribute__((fastcall)) f1(void);
diff --git a/test/CodeGen/string-init.c b/test/CodeGen/string-init.c
index 38c7ec057597..4a808512601e 100644
--- a/test/CodeGen/string-init.c
+++ b/test/CodeGen/string-init.c
@@ -1,5 +1,5 @@
// RUN: clang-cc -emit-llvm %s -o %t &&
-// RUN: grep 'internal constant \[10 x i8\]' %t &&
+// RUN: grep 'private constant \[10 x i8\]' %t &&
// RUN: not grep -F "[5 x i8]" %t &&
// RUN: not grep "store " %t
diff --git a/test/CodeGen/struct-init.c b/test/CodeGen/struct-init.c
index a38442b1a88f..cb84fef4d1c1 100644
--- a/test/CodeGen/struct-init.c
+++ b/test/CodeGen/struct-init.c
@@ -2,11 +2,11 @@
typedef struct _zend_ini_entry zend_ini_entry;
struct _zend_ini_entry {
- void *mh_arg1;
+ void *mh_arg1;
};
char a;
const zend_ini_entry ini_entries[] = {
- { ((char*)&((zend_ini_entry*)0)->mh_arg1 - (char*)(void*)0)},
+ { ((char*)&((zend_ini_entry*)0)->mh_arg1 - (char*)(void*)0)},
};
diff --git a/test/CodeGen/struct-x86-darwin.c b/test/CodeGen/struct-x86-darwin.c
index 050e26dcab9e..c61005f1bebd 100644
--- a/test/CodeGen/struct-x86-darwin.c
+++ b/test/CodeGen/struct-x86-darwin.c
@@ -1,13 +1,13 @@
-// RUN: clang-cc < %s -emit-llvm > %t1 -triple=i686-apple-darwin9
-// Run grep "STest1 = type <{ i32, \[4 x i16\], double }>" %t1 &&
-// RUN: grep "STest2 = type <{ i16, i16, i32, i32 }>" %t1 &&
-// RUN: grep "STest3 = type <{ i8, i8, i16, i32 }>" %t1 &&
-// RUN: grep "STestB1 = type <{ i8, i8 }>" %t1 &&
-// RUN: grep "STestB2 = type <{ i8, i8, i8 }>" %t1 &&
-// RUN: grep "STestB3 = type <{ i8, i8 }>" %t1 &&
-// RUN: grep "STestB4 = type <{ i8, i8, i8, i8 }>" %t1 &&
-// RUN: grep "STestB5 = type <{ i8, i8, i8, i8, i8, i8 }>" %t1 &&
-// RUN: grep "STestB6 = type <{ i8, i8, i8, i8 }>" %t1
+// RUN: clang-cc < %s -emit-llvm > %t1 -triple=i686-apple-darwin9 &&
+// RUN: grep "STest1 = type { i32, \[4 x i16\], double }" %t1 &&
+// RUN: grep "STest2 = type { i16, i16, i32, i32 }" %t1 &&
+// RUN: grep "STest3 = type { i8, i16, i32 }" %t1 &&
+// RUN: grep "STestB1 = type { i8, i8 }" %t1 &&
+// RUN: grep "STestB2 = type { i8, i8, i8 }" %t1 &&
+// RUN: grep "STestB3 = type { i8, i8 }" %t1 &&
+// RUN: grep "STestB4 = type { i8, i8, i8, i8 }" %t1 &&
+// RUN: grep "STestB5 = type { i8, i8, \[2 x i8\], i8, i8 }" %t1 &&
+// RUN: grep "STestB6 = type { i8, i8, \[2 x i8\] }" %t1
// Test struct layout for x86-darwin target
struct STest1 {int x; short y[4]; double z; } st1;
diff --git a/test/CodeGen/struct.c b/test/CodeGen/struct.c
index ed3684280e88..d1e58a244561 100644
--- a/test/CodeGen/struct.c
+++ b/test/CodeGen/struct.c
@@ -70,8 +70,7 @@ typedef struct {
int length;
} range;
extern range f6();
-void f7()
-{
+void f7() {
range r = f6();
}
@@ -81,27 +80,23 @@ typedef struct {
range range2;
} rangepair;
-void f8()
-{
+void f8() {
rangepair p;
range r = p.range1;
}
-void f9(range *p)
-{
+void f9(range *p) {
range r = *p;
}
-void f10(range *p)
-{
+void f10(range *p) {
range r = p[0];
}
/* _Bool types */
-struct _w
-{
+struct _w {
short a,b;
short c,d;
short e,f;
@@ -113,27 +108,24 @@ struct _w
} ws;
/* Implicit casts (due to typedefs) */
-typedef struct _a
-{
+typedef struct _a {
int a;
} a;
-void f11()
-{
- struct _a a1;
- a a2;
+void f11() {
+ struct _a a1;
+ a a2;
- a1 = a2;
- a2 = a1;
+ a1 = a2;
+ a2 = a1;
}
/* Implicit casts (due to const) */
-void f12()
-{
- struct _a a1;
- const struct _a a2;
-
- a1 = a2;
+void f12() {
+ struct _a a1;
+ const struct _a a2;
+
+ a1 = a2;
}
/* struct initialization */
@@ -147,8 +139,7 @@ struct a15 {char a; int b[];} c15;
int a16(void) {c15.a = 1;}
/* compound literals */
-void f13()
-{
+void f13() {
a13 x; x = (a13){1,2};
}
diff --git a/test/CodeGen/union-init.c b/test/CodeGen/union-init.c
index c882d3180c72..f4e9e9a08f4d 100644
--- a/test/CodeGen/union-init.c
+++ b/test/CodeGen/union-init.c
@@ -4,19 +4,19 @@
typedef int Py_ssize_t;
typedef union _gc_head {
- struct {
- union _gc_head *gc_next;
- union _gc_head *gc_prev;
- Py_ssize_t gc_refs;
- } gc;
- long double dummy; /* force worst-case alignment */
+ struct {
+ union _gc_head *gc_next;
+ union _gc_head *gc_prev;
+ Py_ssize_t gc_refs;
+ } gc;
+ long double dummy; /* force worst-case alignment */
} PyGC_Head;
struct gc_generation {
- PyGC_Head head;
- int threshold; /* collection threshold */
- int count; /* count of allocations or collections of younger
- generations */
+ PyGC_Head head;
+ int threshold; /* collection threshold */
+ int count; /* count of allocations or collections of younger
+ generations */
};
#define NUM_GENERATIONS 3
@@ -24,8 +24,8 @@ struct gc_generation {
/* linked lists of container objects */
struct gc_generation generations[NUM_GENERATIONS] = {
- /* PyGC_Head, threshold, count */
- {{{GEN_HEAD(0), GEN_HEAD(0), 0}}, 700, 0},
- {{{GEN_HEAD(1), GEN_HEAD(1), 0}}, 10, 0},
- {{{GEN_HEAD(2), GEN_HEAD(2), 0}}, 10, 0},
+ /* PyGC_Head, threshold, count */
+ {{{GEN_HEAD(0), GEN_HEAD(0), 0}}, 700, 0},
+ {{{GEN_HEAD(1), GEN_HEAD(1), 0}}, 10, 0},
+ {{{GEN_HEAD(2), GEN_HEAD(2), 0}}, 10, 0},
};
diff --git a/test/CodeGen/union-init2.c b/test/CodeGen/union-init2.c
new file mode 100644
index 000000000000..184d75f47156
--- /dev/null
+++ b/test/CodeGen/union-init2.c
@@ -0,0 +1,4 @@
+// RUN: clang-cc -emit-llvm %s -o - -triple i686-pc-linux-gnu | grep "bitcast (%0\* @r to %union.x\*), \[4 x i8\] zeroinitializer"
+
+// Make sure we generate something sane instead of a ptrtoint
+union x {long long b;union x* a;} r = {.a = &r};
diff --git a/test/CodeGen/unreachable.c b/test/CodeGen/unreachable.c
new file mode 100644
index 000000000000..ea4f0478bbd4
--- /dev/null
+++ b/test/CodeGen/unreachable.c
@@ -0,0 +1,37 @@
+// RUN: clang-cc -emit-llvm -o %t %s &&
+// RUN: grep '@unreachable' %t | count 0
+
+extern void abort() __attribute__((noreturn));
+extern int unreachable();
+
+int f0() {
+ return 0;
+ unreachable();
+}
+
+int f1(int i) {
+ goto L0;
+ int a = unreachable();
+ L0:
+ return 0;
+}
+
+int f2(int i) {
+ goto L0;
+ unreachable();
+ int a;
+ unreachable();
+ L0:
+ a = i + 1;
+ return a;
+}
+
+int f3(int i) {
+ if (i) {
+ return 0;
+ } else {
+ abort();
+ }
+ unreachable();
+ return 3;
+}
diff --git a/test/CodeGen/unwind-attr.c b/test/CodeGen/unwind-attr.c
index 4954a0b59ce4..86036f94b981 100644
--- a/test/CodeGen/unwind-attr.c
+++ b/test/CodeGen/unwind-attr.c
@@ -2,4 +2,5 @@
// RUN: clang-cc -emit-llvm -o - %s | grep "@foo()" | grep nounwind
int foo(void) {
+ return 0;
}
diff --git a/test/CodeGen/vector.c b/test/CodeGen/vector.c
index 1084f6d20b9b..5e48fd42b1d0 100644
--- a/test/CodeGen/vector.c
+++ b/test/CodeGen/vector.c
@@ -1,9 +1,8 @@
// RUN: clang-cc -emit-llvm %s -o -
typedef short __v4hi __attribute__ ((__vector_size__ (8)));
-void f()
-{
- __v4hi A = (__v4hi)0LL;
+void f() {
+ __v4hi A = (__v4hi)0LL;
}
__v4hi x = {1,2,3};
@@ -15,7 +14,6 @@ int a() { vty b; return b[2LL]; }
// PR4339
typedef float vec4 __attribute__((vector_size(16)));
-void vac ( vec4* a, char b, float c )
-{
- (*a)[b] = c;
+void vac ( vec4* a, char b, float c ) {
+ (*a)[b] = c;
}
diff --git a/test/CodeGen/visibility.c b/test/CodeGen/visibility.c
index bb9b6e0d50ce..958eb618ee70 100644
--- a/test/CodeGen/visibility.c
+++ b/test/CodeGen/visibility.c
@@ -15,7 +15,7 @@
// RUN: grep 'define internal void @f_deferred()' %t &&
// RUN: grep 'define protected i32 @f_def()' %t &&
// RUN: clang-cc -triple i386-unknown-unknown -fvisibility=hidden -emit-llvm -o %t %s &&
-// RUN: grep '@g_com = common hidden global i32 0' %t &&a
+// RUN: grep '@g_com = common hidden global i32 0' %t &&
// RUN: grep '@g_def = hidden global i32 0' %t &&
// RUN: grep '@g_ext = external global i32' %t &&
// RUN: grep '@g_deferred = internal global' %t &&
diff --git a/test/CodeGen/volatile.c b/test/CodeGen/volatile.c
index 212a0aeb1e35..87cb5ff4eb4f 100644
--- a/test/CodeGen/volatile.c
+++ b/test/CodeGen/volatile.c
@@ -38,7 +38,7 @@ volatile extv4 vVE;
volatile struct {int x;} aggFct(void);
-void main() {
+int main() {
int i;
// load
diff --git a/test/CodeGen/x86.c b/test/CodeGen/x86.c
index 66d82513795b..be0930237c82 100644
--- a/test/CodeGen/x86.c
+++ b/test/CodeGen/x86.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc %s -triple=i686-pc-linux-gnu -emit-llvm -o - > %t1
+// RUN: clang-cc %s -triple=i686-pc-linux-gnu -emit-llvm -o - > %t1 &&
// RUN: grep "ax" %t1 &&
// RUN: grep "bx" %t1 &&
// RUN: grep "cx" %t1 &&
diff --git a/test/CodeGen/x86_32-arguments.c b/test/CodeGen/x86_32-arguments.c
index 43a3ab246c71..78fb8342eebd 100644
--- a/test/CodeGen/x86_32-arguments.c
+++ b/test/CodeGen/x86_32-arguments.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -triple i386-apple-darwin9 -emit-llvm -o %t %s &&
+// RUN: clang-cc -fblocks -triple i386-apple-darwin9 -emit-llvm -o %t %s &&
// RUN: grep 'define signext i8 @f0()' %t &&
// RUN: grep 'define signext i16 @f1()' %t &&
// RUN: grep 'define i32 @f2()' %t &&
@@ -11,39 +11,41 @@
// RUN: grep 'define void @f8_2(i32 %a0.0, i32 %a0.1)' %t &&
char f0(void) {
+ return 0;
}
short f1(void) {
+ return 0;
}
int f2(void) {
+ return 0;
}
float f3(void) {
+ return 0;
}
double f4(void) {
+ return 0;
}
long double f5(void) {
+ return 0;
}
-void f6(char a0, short a1, int a2, long long a3, void *a4) {
-}
+void f6(char a0, short a1, int a2, long long a3, void *a4) {}
typedef enum { A, B, C } E;
-void f7(E a0) {
-}
+void f7(E a0) {}
struct s8 {
int a;
int b;
};
-struct s8 f8_1(void) {
-}
-void f8_2(struct s8 a0) {
-}
+struct s8 f8_1(void) { while (1) {} }
+void f8_2(struct s8 a0) {}
// This should be passed just as s8.
@@ -56,10 +58,8 @@ struct s9 {
int a : 17;
int b;
};
-struct s9 f9_1(void) {
-}
-void f9_2(struct s9 a0) {
-}
+struct s9 f9_1(void) { while (1) {} }
+void f9_2(struct s9 a0) {}
// Return of small structures and unions
@@ -67,7 +67,7 @@ void f9_2(struct s9 a0) {
struct s10 {
union { };
float f;
-} f10(void) {}
+} f10(void) { while (1) {} }
// Small vectors and 1 x {i64,double} are returned in registers
@@ -78,17 +78,17 @@ struct s10 {
// RUN: grep '<2 x i64> @f15()' %t &&
// RUN: grep '<2 x i64> @f16()' %t &&
typedef short T11 __attribute__ ((vector_size (4)));
-T11 f11(void) {}
+T11 f11(void) { while (1) {} }
typedef int T12 __attribute__ ((vector_size (8)));
-T12 f12(void) {}
+T12 f12(void) { while (1) {} }
typedef long long T13 __attribute__ ((vector_size (8)));
-T13 f13(void) {}
+T13 f13(void) { while (1) {} }
typedef double T14 __attribute__ ((vector_size (8)));
-T14 f14(void) {}
+T14 f14(void) { while (1) {} }
typedef long long T15 __attribute__ ((vector_size (16)));
-T15 f15(void) {}
+T15 f15(void) { while (1) {} }
typedef double T16 __attribute__ ((vector_size (16)));
-T16 f16(void) {}
+T16 f16(void) { while (1) {} }
// And when the single element in a struct (but not for 64 and
// 128-bits).
@@ -99,64 +99,107 @@ T16 f16(void) {}
// RUN: grep -F 'void @f20(%4* noalias sret %agg.result)' %t &&
// RUN: grep -F 'void @f21(%5* noalias sret %agg.result)' %t &&
// RUN: grep -F 'void @f22(%6* noalias sret %agg.result)' %t &&
-struct { T11 a; } f17(void) {}
-struct { T12 a; } f18(void) {}
-struct { T13 a; } f19(void) {}
-struct { T14 a; } f20(void) {}
-struct { T15 a; } f21(void) {}
-struct { T16 a; } f22(void) {}
+struct { T11 a; } f17(void) { while (1) {} }
+struct { T12 a; } f18(void) { while (1) {} }
+struct { T13 a; } f19(void) { while (1) {} }
+struct { T14 a; } f20(void) { while (1) {} }
+struct { T15 a; } f21(void) { while (1) {} }
+struct { T16 a; } f22(void) { while (1) {} }
// Single element structures are handled specially
// RUN: grep -F 'float @f23()' %t &&
// RUN: grep -F 'float @f24()' %t &&
// RUN: grep -F 'float @f25()' %t &&
-struct { float a; } f23(void) {}
-struct { float a[1]; } f24(void) {}
-struct { struct {} a; struct { float a[1]; } b; } f25(void) {}
+struct { float a; } f23(void) { while (1) {} }
+struct { float a[1]; } f24(void) { while (1) {} }
+struct { struct {} a; struct { float a[1]; } b; } f25(void) { while (1) {} }
// Small structures are handled recursively
// RUN: grep -F 'i32 @f26()' %t &&
// RUN: grep 'void @f27(%.truct.s27\* noalias sret %agg.result)' %t &&
-struct s26 { struct { char a, b; } a; struct { char a, b; } b; } f26(void) {}
-struct s27 { struct { char a, b, c; } a; struct { char a; } b; } f27(void) {}
+struct s26 { struct { char a, b; } a; struct { char a, b; } b; } f26(void) { while (1) {} }
+struct s27 { struct { char a, b, c; } a; struct { char a; } b; } f27(void) { while (1) {} }
// RUN: grep 'void @f28(%.truct.s28\* noalias sret %agg.result)' %t &&
-struct s28 { int a; int b[]; } f28(void) {}
+struct s28 { int a; int b[]; } f28(void) { while (1) {} }
// RUN: grep 'define i16 @f29()' %t &&
-struct s29 { struct { } a[1]; char b; char c; } f29(void) {}
+struct s29 { struct { } a[1]; char b; char c; } f29(void) { while (1) {} }
// RUN: grep 'define i16 @f30()' %t &&
-struct s30 { char a; char b : 4; } f30(void) {}
+struct s30 { char a; char b : 4; } f30(void) { while (1) {} }
// RUN: grep 'define float @f31()' %t &&
-struct s31 { char : 0; float b; char : 0; } f31(void) {}
+struct s31 { char : 0; float b; char : 0; } f31(void) { while (1) {} }
// RUN: grep 'define i32 @f32()' %t &&
-struct s32 { char a; unsigned : 0; } f32(void) {}
+struct s32 { char a; unsigned : 0; } f32(void) { while (1) {} }
// RUN: grep 'define float @f33()' %t &&
-struct s33 { float a; long long : 0; } f33(void) {}
+struct s33 { float a; long long : 0; } f33(void) { while (1) {} }
// RUN: grep 'define float @f34()' %t &&
-struct s34 { struct { int : 0; } a; float b; } f34(void) {}
+struct s34 { struct { int : 0; } a; float b; } f34(void) { while (1) {} }
// RUN: grep 'define i16 @f35()' %t &&
-struct s35 { struct { int : 0; } a; char b; char c; } f35(void) {}
+struct s35 { struct { int : 0; } a; char b; char c; } f35(void) { while (1) {} }
// RUN: grep 'define i16 @f36()' %t &&
-struct s36 { struct { int : 0; } a[2][10]; char b; char c; } f36(void) {}
+struct s36 { struct { int : 0; } a[2][10]; char b; char c; } f36(void) { while (1) {} }
// RUN: grep 'define float @f37()' %t &&
-struct s37 { float c[1][1]; } f37(void) {}
+struct s37 { float c[1][1]; } f37(void) { while (1) {} }
// RUN: grep 'define void @f38(.struct.s38. noalias sret .agg.result)' %t &&
-struct s38 { char a[3]; short b; } f38(void) {}
+struct s38 { char a[3]; short b; } f38(void) { while (1) {} }
// RUN: grep 'define void @f39(.struct.s39. byval align 16 .x)' %t &&
typedef int v39 __attribute((vector_size(16)));
struct s39 { v39 x; };
void f39(struct s39 x) {}
+// <rdar://problem/7247671>
+// RUN: grep 'define i32 @f40()' %t &&
+enum e40 { ec0 = 0 };
+enum e40 f40(void) { }
+
+// RUN: grep 'define void ()\* @f41()' %t &&
+typedef void (^vvbp)(void);
+vvbp f41(void) { }
+
+// RUN: grep 'define i32 @f42()' %t &&
+struct s42 { enum e40 f0; } f42(void) { }
+
+// RUN: grep 'define i64 @f43()' %t &&
+struct s43 { enum e40 f0; int f1; } f43(void) { }
+
+// RUN: grep 'define i32 @f44()' %t &&
+struct s44 { vvbp f0; } f44(void) { }
+
+// RUN: grep 'define i64 @f45()' %t &&
+struct s45 { vvbp f0; int f1; } f45(void) { }
+
+// RUN: grep 'define void @f46(i32 %a0)' %t &&
+void f46(enum e40 a0) { }
+
+// RUN: grep 'define void @f47(void ()\* %a1)' %t &&
+void f47(vvbp a1) { }
+
+// RUN: grep 'define void @f48(i32 %a0.0)' %t &&
+struct s48 { enum e40 f0; };
+void f48(struct s48 a0) { }
+
+// RUN: grep 'define void @f49(i32 %a0.0, i32 %a0.1)' %t &&
+struct s49 { enum e40 f0; int f1; };
+void f49(struct s49 a0) { }
+
+// RUN: grep 'define void @f50(void ()\* %a0.0)' %t &&
+struct s50 { vvbp f0; };
+void f50(struct s50 a0) { }
+
+// RUN: grep 'define void @f51(void ()\* %a0.0, i32 %a0.1)' %t &&
+struct s51 { vvbp f0; int f1; };
+void f51(struct s51 a0) { }
+
// RUN: true
diff --git a/test/CodeGen/x86_64-arguments.c b/test/CodeGen/x86_64-arguments.c
index 0b68afdb4edd..19f9cdaa2918 100644
--- a/test/CodeGen/x86_64-arguments.c
+++ b/test/CodeGen/x86_64-arguments.c
@@ -7,26 +7,32 @@
// RUN: grep 'define x86_fp80 @f5()' %t &&
// RUN: grep 'define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8\* %a4)' %t &&
// RUN: grep 'define void @f7(i32 %a0)' %t &&
-// RUN: grep 'type { i64, double }.*type .0' %t &&
+// RUN: grep '.0 = type { i64, double }' %t &&
// RUN: grep 'define .0 @f8_1()' %t &&
// RUN: grep 'define void @f8_2(.0)' %t &&
char f0(void) {
+ return 0;
}
short f1(void) {
+ return 0;
}
int f2(void) {
+ return 0;
}
float f3(void) {
+ return 0;
}
double f4(void) {
+ return 0;
}
long double f5(void) {
+ return 0;
}
void f6(char a0, short a1, int a2, long long a3, void *a4) {
@@ -42,23 +48,23 @@ union u8 {
long double a;
int b;
};
-union u8 f8_1() {}
+union u8 f8_1() { while (1) {} }
void f8_2(union u8 a0) {}
// RUN: grep 'define i64 @f9()' %t &&
-struct s9 { int a; int b; int : 0; } f9(void) {}
+struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} }
// RUN: grep 'define void @f10(i64)' %t &&
struct s10 { int a; int b; int : 0; };
void f10(struct s10 a0) {}
// RUN: grep 'define void @f11(.union.anon. noalias sret .agg.result)' %t &&
-union { long double a; float b; } f11() {}
+union { long double a; float b; } f11() { while (1) {} }
// RUN: grep 'define i64 @f12_0()' %t &&
// RUN: grep 'define void @f12_1(i64)' %t &&
struct s12 { int a __attribute__((aligned(16))); };
-struct s12 f12_0(void) {}
+struct s12 f12_0(void) { while (1) {} }
void f12_1(struct s12 a0) {}
// Check that sret parameter is accounted for when checking available integer
@@ -66,8 +72,9 @@ void f12_1(struct s12 a0) {}
// RUN: grep 'define void @f13(.struct.s13_0. noalias sret .agg.result, i32 .a, i32 .b, i32 .c, i32 .d, .struct.s13_1. byval .e, i32 .f)' %t &&
struct s13_0 { long long f0[3]; };
+struct s13_1 { long long f0[2]; };
struct s13_0 f13(int a, int b, int c, int d,
- struct s13_1 { long long f0[2]; } e, int f) {}
+ struct s13_1 e, int f) { while (1) {} }
// RUN: grep 'define void @f14(.*, i8 signext .X)' %t &&
void f14(int a, int b, int c, int d, int e, int f,
@@ -83,9 +90,10 @@ void f17(float a, float b, float c, float d, float e, float f, float g, float h,
long double X) {}
// Check for valid coercion.
-// RUN: grep '.1 = bitcast i64. .tmp to .struct.f18_s0.' %t &&
-// RUN: grep '.2 = load .struct.f18_s0. .1, align 1' %t &&
-// RUN: grep 'store .struct.f18_s0 .2, .struct.f18_s0. .f18_arg1' %t &&
-void f18(int a, struct f18_s0 { int f0; } f18_arg1) {}
+// RUN: grep '.. = bitcast i64. .* to .struct.f18_s0.' %t &&
+// RUN: grep '.. = load .struct.f18_s0. .., align 1' %t &&
+// RUN: grep 'store .struct.f18_s0 .., .struct.f18_s0. .f18_arg1' %t &&
+struct f18_s0 { int f0; };
+void f18(int a, struct f18_s0 f18_arg1) { while (1) {} }
// RUN: true