diff options
Diffstat (limited to 'test/CodeGen')
46 files changed, 535 insertions, 101 deletions
diff --git a/test/CodeGen/annotate.c b/test/CodeGen/annotate.c index ffaeebb..9ed187d 100644 --- a/test/CodeGen/annotate.c +++ b/test/CodeGen/annotate.c @@ -7,4 +7,4 @@ void a(char *a) { // CHECK: private unnamed_addr global // CHECK: private unnamed_addr global -// CHECK: @llvm.global.annotations = appending global [2 x %0] +// CHECK: @llvm.global.annotations = appending global [2 x { i8*, i8*, i8*, i32 }] diff --git a/test/CodeGen/arm-arguments.c b/test/CodeGen/arm-arguments.c index 73bc03d..081bc89 100644 --- a/test/CodeGen/arm-arguments.c +++ b/test/CodeGen/arm-arguments.c @@ -61,7 +61,7 @@ struct s10 { int f0; int : 0; int : 0; }; struct s10 f10(void) {} // APCS-GNU: define void @f11( -// APCS-GNU: struct.s10* sret +// APCS-GNU: struct.s11* sret // AAPCS: define arm_aapcscc i32 @f11() struct s11 { int : 0; int f0; }; struct s11 f11(void) {} @@ -80,7 +80,7 @@ struct s13 { float f0; }; struct s13 f13(void) {} // APCS-GNU: define void @f14( -// APCS-GNU: struct.s13* sret +// APCS-GNU: union.u14* sret // AAPCS: define arm_aapcscc i32 @f14() union u14 { float f0; }; union u14 f14(void) {} diff --git a/test/CodeGen/arm-asm-variable.c b/test/CodeGen/arm-asm-variable.c new file mode 100644 index 0000000..865d197 --- /dev/null +++ b/test/CodeGen/arm-asm-variable.c @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s + +typedef long long int64_t; +typedef unsigned int uint32_t; + +int64_t foo(int64_t v, volatile int64_t *p) +{ + register uint32_t rl asm("r1"); + register uint32_t rh asm("r2"); + + int64_t r; + uint32_t t; + + __asm__ __volatile__( \ + "ldrexd%[_rl], %[_rh], [%[_p]]" \ + : [_rl] "=&r" (rl), [_rh] "=&r" (rh) \ + : [_p] "p" (p) : "memory"); + + // CHECK: call { i32, i32 } asm sideeffect "ldrexd$0, $1, [$2]", "={r1},={r2},r,~{memory}"(i64* + + return r; +} + +// Make sure we translate register names properly. +void bar (void) { + register unsigned int rn asm("r14"); + register unsigned int d asm("r2"); + + // CHECK: call i32 asm sideeffect "sub $1, $1, #32", "={r2},{lr}" + asm volatile ("sub %1, %1, #32" : "=r"(d) : "r"(rn)); +} diff --git a/test/CodeGen/asm-errors.c b/test/CodeGen/asm-errors.c index cd4d1ff..438c82b 100644 --- a/test/CodeGen/asm-errors.c +++ b/test/CodeGen/asm-errors.c @@ -1,6 +1,8 @@ // REQUIRES: x86-registered-target -// RUN: not %clang_cc1 -triple i386-apple-darwin10 -emit-obj %s -o /dev/null > %t 2>&1 -// RUN: FileCheck %s < %t + +// RUN: true +// UN: not %clang_cc1 -triple i386-apple-darwin10 -emit-obj %s -o /dev/null > %t 2>&1 +// UN: FileCheck %s < %t int test1(int X) { // CHECK: error: invalid instruction mnemonic 'abc' diff --git a/test/CodeGen/asm-inout.c b/test/CodeGen/asm-inout.c index 29142f7..ce524fe 100644 --- a/test/CodeGen/asm-inout.c +++ b/test/CodeGen/asm-inout.c @@ -21,7 +21,7 @@ void test2() { // PR7338 void test3(int *vout, int vin) { - // CHECK: call void asm "opr $0,$1", "=*r|m|r,r|m|r,~{di},~{dirflag},~{fpsr},~{flags}" + // CHECK: call void asm "opr $0,$1", "=*r|m|r,r|m|r,~{edi},~{dirflag},~{fpsr},~{flags}" asm( "opr %[vout],%[vin]" : [vout] "=r,=m,=r" (*vout) @@ -37,4 +37,3 @@ int test4(volatile int *addr) { return (int)oldval; // CHECK: call i8 asm "frob $0", "=r,0{{.*}}"(i8 -1) } - diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c index eb11285..7199f09 100644 --- a/test/CodeGen/asm.c +++ b/test/CodeGen/asm.c @@ -49,10 +49,10 @@ unsigned t9(unsigned int a) { // PR3908 void t10(int r) { __asm__("PR3908 %[lf] %[xx] %[li] %[r]" : [r] "+r" (r) : [lf] "mx" (0), [li] "mr" (0), [xx] "x" ((double)(0))); - + // CHECK: @t10( // CHECK:PR3908 $1 $3 $2 $0 -} +} // PR3373 @@ -119,7 +119,7 @@ int t16() { void t17() { int i; __asm__ ( "nop": "=m"(i)); - + // CHECK: @t17() // CHECK: call void asm "nop", "=*m, } @@ -127,7 +127,7 @@ void t17() { // <rdar://problem/6841383> int t18(unsigned data) { int a, b; - + asm("xyz" :"=a"(a), "=d"(b) : "a"(data)); return a + b; // CHECK: t18(i32 @@ -140,7 +140,7 @@ int t18(unsigned data) { // PR6780 int t19(unsigned data) { int a, b; - + asm("x{abc|def|ghi}z" :"=r"(a): "r"(data)); return a + b; // CHECK: t19(i32 @@ -153,7 +153,7 @@ double t20(double x) { register long double result; __asm __volatile ("frndint" : "=t" (result) : "0" (x)); return result; - + // CHECK: @t20 // CHECK: fpext double {{.*}} to x86_fp80 // CHECK-NEXT: call x86_fp80 asm sideeffect "frndint" @@ -190,3 +190,17 @@ unsigned char t23(unsigned char a, unsigned char b) { "edx", "cc"); return res; } + + +// PR10299 - fpsr, fpcr +void test(void) +{ + __asm__ __volatile__( \ + "finit" \ + : \ + : \ + :"st","st(1)","st(2)","st(3)", \ + "st(4)","st(5)","st(6)","st(7)", \ + "fpsr","fpcr" \ + ); +} diff --git a/test/CodeGen/attr-weak-import.c b/test/CodeGen/attr-weak-import.c new file mode 100644 index 0000000..0707f59 --- /dev/null +++ b/test/CodeGen/attr-weak-import.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -triple x86_64-darwin-apple -emit-llvm -o - %s | FileCheck %s +// rdar://9538608 + +extern int A __attribute__((weak_import)); +int A; + +extern int B __attribute__((weak_import)); +extern int B; + +int C; +extern int C __attribute__((weak_import)); + +extern int D __attribute__((weak_import)); +extern int D __attribute__((weak_import)); +int D; + +extern int E __attribute__((weak_import)); +int E; +extern int E __attribute__((weak_import)); + +// CHECK: @A = global i32 +// CHECK-NOT: @B = +// CHECK: @C = common global i32 +// CHECK: @D = global i32 +// CHECK: @E = global i32 + diff --git a/test/CodeGen/attributes.c b/test/CodeGen/attributes.c index 770ce76..4e73af6 100644 --- a/test/CodeGen/attributes.c +++ b/test/CodeGen/attributes.c @@ -4,7 +4,7 @@ // CHECK: @t5 = weak global i32 2 int t5 __attribute__((weak)) = 2; -// CHECK: @t13 = global %0 zeroinitializer, section "SECT" +// CHECK: @t13 = global %struct.s0 zeroinitializer, section "SECT" struct s0 { int x; }; struct s0 t13 __attribute__((section("SECT"))) = { 0 }; diff --git a/test/CodeGen/bitfield-2.c b/test/CodeGen/bitfield-2.c index 8de432f..69ed5b1 100644 --- a/test/CodeGen/bitfield-2.c +++ b/test/CodeGen/bitfield-2.c @@ -11,7 +11,7 @@ // CHECK-RECORD: *** Dumping IRgen Record Layout // CHECK-RECORD: Record: struct s0 // CHECK-RECORD: Layout: <CGRecordLayout -// CHECK-RECORD: LLVMType:<{ [3 x i8] }> +// CHECK-RECORD: LLVMType:%struct.s0 = type <{ [3 x i8] }> // CHECK-RECORD: IsZeroInitializable:1 // CHECK-RECORD: BitFields:[ // CHECK-RECORD: <CGBitFieldInfo Size:24 IsSigned:1 @@ -56,7 +56,7 @@ unsigned long long test_0() { // CHECK-RECORD: *** Dumping IRgen Record Layout // CHECK-RECORD: Record: struct s1 // CHECK-RECORD: Layout: <CGRecordLayout -// CHECK-RECORD: LLVMType:<{ [2 x i8], i8 }> +// CHECK-RECORD: LLVMType:%struct.s1 = type <{ [2 x i8], i8 }> // CHECK-RECORD: IsZeroInitializable:1 // CHECK-RECORD: BitFields:[ // CHECK-RECORD: <CGBitFieldInfo Size:10 IsSigned:1 @@ -113,7 +113,7 @@ unsigned long long test_1() { // CHECK-RECORD: *** Dumping IRgen Record Layout // CHECK-RECORD: Record: union u2 // CHECK-RECORD: Layout: <CGRecordLayout -// CHECK-RECORD: LLVMType:<{ i8 }> +// CHECK-RECORD: LLVMType:%union.u2 = type <{ i8 }> // CHECK-RECORD: IsZeroInitializable:1 // CHECK-RECORD: BitFields:[ // CHECK-RECORD: <CGBitFieldInfo Size:3 IsSigned:0 @@ -288,7 +288,7 @@ _Bool test_6() { // CHECK-RECORD: *** Dumping IRgen Record Layout // CHECK-RECORD: Record: struct s7 // CHECK-RECORD: Layout: <CGRecordLayout -// CHECK-RECORD: LLVMType:{ i32, i32, i32, i8, [3 x i8], [4 x i8], [12 x i8] } +// CHECK-RECORD: LLVMType:%struct.s7 = type { i32, i32, i32, i8, [3 x i8], [4 x i8], [12 x i8] } // CHECK-RECORD: IsZeroInitializable:1 // CHECK-RECORD: BitFields:[ // CHECK-RECORD: <CGBitFieldInfo Size:5 IsSigned:1 diff --git a/test/CodeGen/blocksignature.c b/test/CodeGen/blocksignature.c index 7526f19..63fe124 100644 --- a/test/CodeGen/blocksignature.c +++ b/test/CodeGen/blocksignature.c @@ -2,13 +2,13 @@ // RUN: %clang_cc1 -fblocks -triple i686-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X32 // X64: @.str = private unnamed_addr constant [6 x i8] c"v8@?0\00" -// X64: @__block_literal_global = internal constant %1 { i8** @_NSConcreteGlobalBlock, i32 1342177280, +// X64: @__block_literal_global = internal constant {{.*}} { i8** @_NSConcreteGlobalBlock, i32 1342177280, // X64: @.str1 = private unnamed_addr constant [12 x i8] c"i16@?0c8f12\00" // X64: store i32 1073741824, i32* // X32: [[STR1:@.*]] = private unnamed_addr constant [6 x i8] c"v4@?0\00" -// X32: @__block_descriptor_tmp = internal constant [[FULL_DESCRIPTOR_T:%.*]] { i32 0, i32 20, i8* getelementptr inbounds ([6 x i8]* [[STR1]], i32 0, i32 0), i8* null } -// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:%.*]] { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (void (i8*)* @__block_global_{{.*}} to i8*), [[DESCRIPTOR_T:%.*]]* bitcast ([[FULL_DESCRIPTOR_T]]* @__block_descriptor_tmp to {{%.*}}*) } +// X32: @__block_descriptor_tmp = internal constant [[FULL_DESCRIPTOR_T:.*]] { i32 0, i32 20, i8* getelementptr inbounds ([6 x i8]* [[STR1]], i32 0, i32 0), i8* null } +// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:.*]] { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (void (i8*)* @__block_global_{{.*}} to i8*), [[DESCRIPTOR_T:%.*]]* bitcast ([[FULL_DESCRIPTOR_T]]* @__block_descriptor_tmp to {{%.*}}*) } // X32: [[STR2:@.*]] = private unnamed_addr constant [11 x i8] c"i12@?0c4f8\00" // X32: @__block_descriptor_tmp{{.*}} = internal constant [[FULL_DESCRIPTOR_T]] { i32 0, i32 24, i8* getelementptr inbounds ([11 x i8]* [[STR2]], i32 0, i32 0), i8* null } // X32: store i32 1073741824, i32* diff --git a/test/CodeGen/blockstret.c b/test/CodeGen/blockstret.c index e49b52a..d5dae6f 100644 --- a/test/CodeGen/blockstret.c +++ b/test/CodeGen/blockstret.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X64 // RUN: %clang_cc1 -fblocks -triple i686-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X32 -// X64: internal constant {{%.*}} { i8** @_NSConcreteGlobalBlock, i32 1879048192 +// X64: internal constant {{.*}} { i8** @_NSConcreteGlobalBlock, i32 1879048192 // X64: store i32 1610612736, i32* %want // X32: @_NSConcreteGlobalBlock, i32 1879048192, i32 0, diff --git a/test/CodeGen/builtin-expect.c b/test/CodeGen/builtin-expect.c index 88479d9..664c6b6 100644 --- a/test/CodeGen/builtin-expect.c +++ b/test/CodeGen/builtin-expect.c @@ -19,3 +19,29 @@ int main() { // CHECK: call void @isigprocmask() // CHECK: [[C:%.*]] = call i64 (...)* @bar() + + +// CHECK: @test1 +int test1(int x) { +// CHECK: @llvm.expect + if (__builtin_expect (x, 1)) + return 0; + return x; +} + +// CHECK: @test2 +int test2(int x) { +// CHECK: @llvm.expect + switch(__builtin_expect(x, 5)) { + default: + return 0; + case 0: + case 1: + case 2: + return 1; + case 5: + return 5; + }; + + return 0; +} diff --git a/test/CodeGen/byval-memcpy-elim.c b/test/CodeGen/byval-memcpy-elim.c index 8aa08fb..76cdafb 100644 --- a/test/CodeGen/byval-memcpy-elim.c +++ b/test/CodeGen/byval-memcpy-elim.c @@ -18,3 +18,36 @@ void test1a(struct Test1S, struct Test2S); void test1(struct Test1S *A, struct Test2S *B) { test1a(*A, *B); } + +// The above gets tricker when the byval argument requires higher alignment +// than the natural alignment of the type in question. +// rdar://9483886 + +// Make sure we do generate a memcpy when we cannot guarantee alignment. +struct Test3S { + int a,b,c,d,e,f,g,h,i,j,k,l; +}; +void test2a(struct Test3S q); +// CHECK: define void @test2( +// CHECK: alloca %struct.Test3S, align 8 +// CHECK: memcpy +// CHECK: call void @test2a +void test2(struct Test3S *q) { + test2a(*q); +} + +// But make sure we don't generate a memcpy when we can guarantee alignment. +void fooey(void); +// CHECK: define void @test3( +// CHECK: alloca %struct.Test3S, align 8 +// CHECK: call void @fooey +// CHECK-NOT: memcpy +// CHECK: call void @test2a +// CHECK-NOT: memcpy +// CHECK: call void @test2a +void test3(struct Test3S a) { + struct Test3S b = a; + fooey(); + test2a(a); + test2a(b); +} diff --git a/test/CodeGen/call-knr-indirect.c b/test/CodeGen/call-knr-indirect.c deleted file mode 100644 index 2e923b3..0000000 --- a/test/CodeGen/call-knr-indirect.c +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang %s -O0 -emit-llvm -S -o - | grep 'call.*rb_define_global_function' -// This should call rb_define_global_function, not rb_f_chop. - -void rb_define_global_function (const char*,void(*)(),int); -static void rb_f_chop(); -void Init_String() { - rb_define_global_function("chop", rb_f_chop, 0); -} -static void rb_f_chop() { -} - diff --git a/test/CodeGen/call.c b/test/CodeGen/call.c new file mode 100644 index 0000000..ef32775 --- /dev/null +++ b/test/CodeGen/call.c @@ -0,0 +1,39 @@ +// RUN: %clang %s -O0 -emit-llvm -S -o - | FileCheck %s + +// This should call rb_define_global_function, not rb_f_chop. +void rb_define_global_function (const char*,void(*)(),int); +static void rb_f_chop(); +void Init_String() { + rb_define_global_function("chop", rb_f_chop, 0); +} +static void rb_f_chop() { +} + +// CHECK: call{{.*}}rb_define_global_function + +// PR10335 +typedef void (* JSErrorCallback)(void); +void js_GetErrorMessage(void); +void JS_ReportErrorNumber(JSErrorCallback errorCallback, ...); +void Interpret() { + JS_ReportErrorNumber(js_GetErrorMessage, 0); + + // CHECK: call void ({{.*}}, ...)* @JS_ReportErrorNumber({{.*}}@js_GetErrorMessage +} + + + + +// PR10337 +struct sigaction { int (*_sa_handler)(int); }; +typedef int SigHandler (); +typedef struct sigaction sighandler_cxt; +SigHandler *rl_set_sighandler(ohandler) +sighandler_cxt *ohandler; { + return 0; +} + +void rl_set_signals() { + SigHandler *oh; + oh = rl_set_sighandler(0); +} diff --git a/test/CodeGen/complex-indirect.c b/test/CodeGen/complex-indirect.c new file mode 100644 index 0000000..45eb195 --- /dev/null +++ b/test/CodeGen/complex-indirect.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s + +// Make sure this doesn't crash, and that we don't generate a byval alloca +// with insufficient alignment. + +void a(int,int,int,int,int,int,__complex__ char); +void b(__complex__ char *y) { a(0,0,0,0,0,0,*y); } +// CHECK: define void @b +// CHECK: alloca { i8, i8 }*, align 8 +// CHECK: call void @a(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { i8, i8 }* byval align 8 diff --git a/test/CodeGen/complex.c b/test/CodeGen/complex.c index 055383e..1212660 100644 --- a/test/CodeGen/complex.c +++ b/test/CodeGen/complex.c @@ -93,3 +93,7 @@ void t6() { double t7(double _Complex c) { return __builtin_fabs(__real__(c)); } + +void t8() { + __complex__ int *x = &(__complex__ int){1}; +} diff --git a/test/CodeGen/compound-literal.c b/test/CodeGen/compound-literal.c index 4b995db..0164c2b 100644 --- a/test/CodeGen/compound-literal.c +++ b/test/CodeGen/compound-literal.c @@ -1,12 +1,33 @@ -// RUN: %clang_cc1 < %s -emit-llvm +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s int* a = &(int){1}; struct s {int a, b, c;} * b = &(struct s) {1, 2, 3}; // Not working; complex constants are broken // _Complex double * x = &(_Complex double){1.0f}; -int xxx() { +void xxx() { int* a = &(int){1}; struct s {int a, b, c;} * b = &(struct s) {1, 2, 3}; _Complex double * x = &(_Complex double){1.0f}; } + +// CHECK: define void @f() +void f() { + typedef struct S { int x,y; } S; + // CHECK: [[S:%[a-zA-Z0-9.]+]] = alloca [[STRUCT:%[a-zA-Z0-9.]+]], + struct S s; + // CHECK-NEXT: [[COMPOUNDLIT:%[a-zA-Z0-9.]+]] = alloca [[STRUCT]] + // CHECK-NEXT: [[CX:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[COMPOUNDLIT]], i32 0, i32 0 + // CHECK-NEXT: [[SY:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[S]], i32 0, i32 1 + // CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i32* [[SY]] + // CHECK-NEXT: store i32 [[TMP]], i32* [[CX]] + // CHECK-NEXT: [[CY:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[COMPOUNDLIT]], i32 0, i32 1 + // CHECK-NEXT: [[SX:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[S]], i32 0, i32 0 + // CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i32* [[SX]] + // CHECK-NEXT: store i32 [[TMP]], i32* [[CY]] + // CHECK-NEXT: [[SI8:%[a-zA-Z0-9.]+]] = bitcast [[STRUCT]]* [[S]] to i8* + // CHECK-NEXT: [[COMPOUNDLITI8:%[a-zA-Z0-9.]+]] = bitcast [[STRUCT]]* [[COMPOUNDLIT]] to i8* + // CHECK-NEXT: call void @llvm.memcpy{{.*}}(i8* [[SI8]], i8* [[COMPOUNDLITI8]] + s = (S){s.y,s.x}; + // CHECK-NEXT: ret void +} diff --git a/test/CodeGen/const-init.c b/test/CodeGen/const-init.c index c677863..9bc3bba 100644 --- a/test/CodeGen/const-init.c +++ b/test/CodeGen/const-init.c @@ -26,21 +26,21 @@ union s2 { int g0 = (int)(&(((union s2 *) 0)->f0.f0) - 0); -// CHECK: @g1x = global {{%.}} { double 1.000000e+00{{[0]*}}, double 0.000000e+00{{[0]*}} } +// CHECK: @g1x = global { double, double } { double 1.000000e+00{{[0]*}}, double 0.000000e+00{{[0]*}} } _Complex double g1x = 1.0f; -// CHECK: @g1y = global {{%.}} { double 0.000000e+00{{[0]*}}, double 1.000000e+00{{[0]*}} } +// CHECK: @g1y = global { double, double } { double 0.000000e+00{{[0]*}}, double 1.000000e+00{{[0]*}} } _Complex double g1y = 1.0fi; -// CHECK: @g1 = global {{%.}} { i8 1, i8 10 } +// CHECK: @g1 = global { i8, i8 } { i8 1, i8 10 } _Complex char g1 = (char) 1 + (char) 10 * 1i; -// CHECK: @g2 = global %2 { i32 1, i32 10 } +// CHECK: @g2 = global { i32, i32 } { i32 1, i32 10 } _Complex int g2 = 1 + 10i; -// CHECK: @g3 = global {{%.}} { float 1.000000e+00{{[0]*}}, float 1.000000e+0{{[0]*}}1 } +// CHECK: @g3 = global { float, float } { float 1.000000e+00{{[0]*}}, float 1.000000e+0{{[0]*}}1 } _Complex float g3 = 1.0 + 10.0i; -// CHECK: @g4 = global {{%.}} { double 1.000000e+00{{[0]*}}, double 1.000000e+0{{[0]*}}1 } +// CHECK: @g4 = global { double, double } { double 1.000000e+00{{[0]*}}, double 1.000000e+0{{[0]*}}1 } _Complex double g4 = 1.0 + 10.0i; -// CHECK: @g5 = global %2 zeroinitializer +// CHECK: @g5 = global { i32, i32 } zeroinitializer _Complex int g5 = (2 + 3i) == (5 + 7i); -// CHECK: @g6 = global {{%.}} { double -1.100000e+0{{[0]*}}1, double 2.900000e+0{{[0]*}}1 } +// CHECK: @g6 = global { double, double } { double -1.100000e+0{{[0]*}}1, double 2.900000e+0{{[0]*}}1 } _Complex double g6 = (2.0 + 3.0i) * (5.0 + 7.0i); // CHECK: @g7 = global i32 1 int g7 = (2 + 3i) * (5 + 7i) == (-11 + 29i); @@ -52,14 +52,14 @@ int g9 = (2 + 3i) * (5 + 7i) != (-11 + 29i); 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 +// CHECK: @gv1 = global %struct.anon <{ 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 +// CHECK: @gv2 = global %struct.anon.0 <{ i8 1, i8* null }>, align 1 struct { unsigned char a; char *b; diff --git a/test/CodeGen/darwin-thread-specifier.c b/test/CodeGen/darwin-thread-specifier.c new file mode 100644 index 0000000..605d461 --- /dev/null +++ b/test/CodeGen/darwin-thread-specifier.c @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s +// CHECK: @b = thread_local global i32 5, align 4 +__thread int b = 5; diff --git a/test/CodeGen/debug-info-iv.c b/test/CodeGen/debug-info-iv.c new file mode 100644 index 0000000..9265473 --- /dev/null +++ b/test/CodeGen/debug-info-iv.c @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -triple x86_64-darwin-apple -Os -S -g -o - %s | FileCheck %s + +int calculate(int); +static void test_indvars(int *Array1, int Array2[100][200]) { + unsigned i, j; + Array1[1] = Array2[3][6] = 12345; + + for (i = 0; i < 100; i+=2) + Array1[i] = i; /* Step by non unit amount */ + + for (i = 3; i < 103; i++) + Array1[i] = i+4; /* Step with an offset */ + + for (i = 13; i < 100; i++) + for (j = 0; j < 100; j+=3) /* 2d array access */ + Array2[i][j/3] = Array2[i][i]; +} + + +int main() { + int Array[100][200], i, j; + double sum = 0.0; + + for (i=0; i < 100; i+=2) + for (j=0; j < 200; j++) + Array[i][j] = 0; + test_indvars(Array[0], Array); + +//CHECK: .loc 2 30 3 + for (i=0; i < 100; i+=2) + for (j=0; j < 200; j++) + sum += Array[i][j]; + + return calculate(sum); +} diff --git a/test/CodeGen/debug-info-member.c b/test/CodeGen/debug-info-member.c new file mode 100644 index 0000000..54066fa --- /dev/null +++ b/test/CodeGen/debug-info-member.c @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 -emit-llvm -g < %s | grep DW_TAG_member | grep \!3 + +struct A { int x; } a; diff --git a/test/CodeGen/debug-info.c b/test/CodeGen/debug-info.c index 876c6c2..af2ce96 100644 --- a/test/CodeGen/debug-info.c +++ b/test/CodeGen/debug-info.c @@ -54,3 +54,8 @@ __uint128_t foo128 () __uint128_t int128 = 44; return int128; } + +// CHECK: uint64x2_t +typedef unsigned long long uint64_t; +typedef uint64_t uint64x2_t __attribute__((ext_vector_type(2))); +uint64x2_t extvectbar[4]; diff --git a/test/CodeGen/decl.c b/test/CodeGen/decl.c index 29520d7..21b7579 100644 --- a/test/CodeGen/decl.c +++ b/test/CodeGen/decl.c @@ -2,8 +2,8 @@ // CHECK: @test1.x = internal constant [12 x i32] [i32 1 // CHECK: @test2.x = internal unnamed_addr constant [13 x i32] [i32 1, -// CHECK: @test5w = global %0 { i32 2, [4 x i8] undef } -// CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 } +// CHECK: @test5w = global { i32, [4 x i8] } { i32 2, [4 x i8] undef } +// CHECK: @test5y = global { double } { double 7.300000e+0{{[0]*}}1 } // CHECK: @test6.x = internal unnamed_addr constant %struct.SelectDest { i8 1, i8 2, i32 3, i32 0 } diff --git a/test/CodeGen/designated-initializers.c b/test/CodeGen/designated-initializers.c index d928296..6561ce5 100644 --- a/test/CodeGen/designated-initializers.c +++ b/test/CodeGen/designated-initializers.c @@ -8,10 +8,10 @@ struct foo { // CHECK: @u = global %union.anon zeroinitializer union { int i; float f; } u = { }; -// CHECK: @u2 = global %1 { i32 0, [4 x i8] undef } +// CHECK: @u2 = global { i32, [4 x i8] } { i32 0, [4 x i8] undef } union { int i; double f; } u2 = { }; -// CHECK: @u3 = global %2 zeroinitializer +// CHECK: @u3 = global %union.anon.1 zeroinitializer union { double f; int i; } u3 = { }; // CHECK: @b = global [2 x i32] [i32 0, i32 22] @@ -39,11 +39,11 @@ struct ds ds0 = { { { .a = 0 } } }; struct ds ds1 = { { .a = 1 } }; struct ds ds2 = { { .b = 1 } }; struct ds ds3 = { .a = 0 }; -// CHECK: @ds4 = global %3 { %4 { %struct.anon zeroinitializer, i16 0, %struct.anon { i16 1 } } } +// CHECK: @ds4 = global %struct.ds { %struct.anon.3 { %struct.anon zeroinitializer, i16 0, %struct.anon.2 { i16 1 } } } struct ds ds4 = { .c = 1 }; struct ds ds5 = { { { .a = 0 } }, .b = 1 }; struct ds ds6 = { { .a = 0, .b = 1 } }; -// CHECK: @ds7 = global %3 { %4 { %struct.anon { i16 2 }, i16 3, %struct.anon zeroinitializer } } +// CHECK: @ds7 = global %struct.ds { %struct.anon.3 { %struct.anon { i16 2 }, i16 3, %struct.anon.2 zeroinitializer } } struct ds ds7 = { { { .a = 1 @@ -59,7 +59,7 @@ void test1(int argc, char **argv) .b = 1024, }; - // CHECK: bitcast %union.anon* %u2 + // CHECK: bitcast %union.anon.4* %u2 // CHECK: call void @llvm.memset union { int i; float f; } u2 = { }; diff --git a/test/CodeGen/flexible-array-init.c b/test/CodeGen/flexible-array-init.c index 3632350..d3079dc 100644 --- a/test/CodeGen/flexible-array-init.c +++ b/test/CodeGen/flexible-array-init.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s struct { int x; int y[]; } a = { 1, 7, 11 }; -// CHECK: @a = global %0 { i32 1, [2 x i32] [i32 7, i32 11] } +// CHECK: @a = global { i32, [2 x i32] } { i32 1, [2 x i32] [i32 7, i32 11] } struct { int x; int y[]; } b = { 1, { 13, 15 } }; -// CHECK: @b = global %0 { i32 1, [2 x i32] [i32 13, i32 15] } +// CHECK: @b = global { i32, [2 x i32] } { i32 1, [2 x i32] [i32 13, i32 15] } diff --git a/test/CodeGen/functions.c b/test/CodeGen/functions.c index a2c692d..e51f93e 100644 --- a/test/CodeGen/functions.c +++ b/test/CodeGen/functions.c @@ -59,3 +59,9 @@ void f8_test() { // CHECK: declare void @f8_user({{.*}}*) // CHECK: declare void @f8_callback() } + +// PR10204: don't crash +static void test9_helper(void) {} +void test9() { + (void) test9_helper; +} diff --git a/test/CodeGen/global-init.c b/test/CodeGen/global-init.c index 351ca9e..074c2a0 100644 --- a/test/CodeGen/global-init.c +++ b/test/CodeGen/global-init.c @@ -27,12 +27,12 @@ struct ManyFields { int f; }; -// CHECK: global %0 { i32 1, i32 2, i32 0, i8 0, i32 0, i32 0 } +// CHECK: global %struct.ManyFields { i32 1, i32 2, i32 0, i8 0, i32 0, i32 0 } struct ManyFields FewInits = {1, 2}; // PR6766 -// CHECK: @l = global %1 { [24 x i8] c"f\00\00\00o\00\00\00o\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", i32 1 } +// CHECK: @l = global { [24 x i8], i32 } { [24 x i8] c"f\00\00\00o\00\00\00o\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", i32 1 } typedef __WCHAR_TYPE__ wchar_t; struct K { wchar_t L[6]; diff --git a/test/CodeGen/init.c b/test/CodeGen/init.c index 0f94729..599b4f2 100644 --- a/test/CodeGen/init.c +++ b/test/CodeGen/init.c @@ -115,3 +115,11 @@ void test11(struct test11S *P) { // CHECK: store i32 4 // CHECK: ret void } + + +// Verify that we can convert a recursive struct with a memory that returns +// an instance of the struct we're converting. +struct test12 { + struct test12 (*p)(void); +} test12g; + diff --git a/test/CodeGen/libcalls.c b/test/CodeGen/libcalls.c index 828d7de..5ff684f 100644 --- a/test/CodeGen/libcalls.c +++ b/test/CodeGen/libcalls.c @@ -50,3 +50,26 @@ void test_pow(float a0, double a1, long double a2) { // CHECK-NO: declare float @llvm.pow.f32(float, float) nounwind readonly // CHECK-NO: declare double @llvm.pow.f64(double, double) nounwind readonly // CHECK-NO: declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80) nounwind readonly + +// CHECK-YES: define void @test_fma +// CHECK-NO: define void @test_fma +void test_fma(float a0, double a1, long double a2) { + // CHECK-YES: call float @llvm.fma.f32 + // CHECK-NO: call float @llvm.fma.f32 + float l0 = fmaf(a0, a0, a0); + + // CHECK-YES: call double @llvm.fma.f64 + // CHECK-NO: call double @llvm.fma.f64 + double l1 = fma(a1, a1, a1); + + // CHECK-YES: call x86_fp80 @llvm.fma.f80 + // CHECK-NO: call x86_fp80 @llvm.fma.f80 + long double l2 = fmal(a2, a2, a2); +} + +// CHECK-YES: declare float @llvm.fma.f32(float, float, float) nounwind readnone +// CHECK-YES: declare double @llvm.fma.f64(double, double, double) nounwind readnone +// CHECK-YES: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone +// CHECK-NO: declare float @llvm.fma.f32(float, float, float) nounwind readnone +// CHECK-NO: declare double @llvm.fma.f64(double, double, double) nounwind readnone +// CHECK-NO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone diff --git a/test/CodeGen/mmx-inline-asm.c b/test/CodeGen/mmx-inline-asm.c index c473a93..5d1371e 100644 --- a/test/CodeGen/mmx-inline-asm.c +++ b/test/CodeGen/mmx-inline-asm.c @@ -2,7 +2,7 @@ // <rdar://problem/9091220> #include <mmintrin.h> -// CHECK: type { x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx } +// CHECK: { x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx } void foo(long long fill) { __m64 vfill = _mm_cvtsi64_m64(fill); diff --git a/test/CodeGen/ms-anonymous-struct.c b/test/CodeGen/ms-anonymous-struct.c index 3afe440..b41caab 100644 --- a/test/CodeGen/ms-anonymous-struct.c +++ b/test/CodeGen/ms-anonymous-struct.c @@ -1,19 +1,19 @@ // RUN: %clang_cc1 -fms-extensions -emit-llvm -o - %s | FileCheck %s +// CHECK: %struct.test = type { i32, %struct.nested2, i32 } +// CHECK: %struct.nested2 = type { i32, %struct.nested1, i32 } // CHECK: %struct.nested1 = type { i32, i32 } typedef struct nested1 { int a1; int b1; } NESTED1; -// CHECK: %struct.nested2 = type { i32, %struct.nested1, i32 } struct nested2 { int a; NESTED1; int b; }; -// CHECK: %struct.test = type { i32, %struct.nested2, i32 } struct test { int x; struct nested2; diff --git a/test/CodeGen/packed-union.c b/test/CodeGen/packed-union.c index 0aeed00..31ce614 100644 --- a/test/CodeGen/packed-union.c +++ b/test/CodeGen/packed-union.c @@ -1,6 +1,5 @@ // RUN: %clang_cc1 -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; diff --git a/test/CodeGen/pragma-pack-3.c b/test/CodeGen/pragma-pack-3.c index 676f0d7..04b636e 100644 --- a/test/CodeGen/pragma-pack-3.c +++ b/test/CodeGen/pragma-pack-3.c @@ -1,9 +1,7 @@ // RUN: %clang_cc1 -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_cc1 -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> diff --git a/test/CodeGen/private-extern-redef.c b/test/CodeGen/private-extern-redef.c new file mode 100644 index 0000000..580ce9b --- /dev/null +++ b/test/CodeGen/private-extern-redef.c @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -triple x86_64-darwin-apple -emit-llvm -o - %s | FileCheck %s +// rdar://9609649 + +__private_extern__ const int I; +__private_extern__ const int J = 927; + +__private_extern__ const int K; +const int K = 37; + +const int L = 10; +__private_extern__ const int L; + +__private_extern__ int M; +int M = 20; + +__private_extern__ int N; +int N; + +__private_extern__ int O; +int O=1; + +__private_extern__ int P; +extern int P; + +void bar(int); + +void foo() { + bar(I); +} + +// CHECK: @J = hidden constant +// CHECK: @K = hidden constant +// CHECK: @L = constant +// CHECK: @M = hidden global +// CHECK: @O = hidden global +// CHECK: @I = external hidden +// CHECK: @N = common hidden global +// CHECK-NOT: @P + diff --git a/test/CodeGen/struct-init.c b/test/CodeGen/struct-init.c index 861c41e..8a605c1 100644 --- a/test/CodeGen/struct-init.c +++ b/test/CodeGen/struct-init.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm-only +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s typedef struct _zend_ini_entry zend_ini_entry; struct _zend_ini_entry { @@ -29,3 +29,11 @@ typedef struct __simd64_uint32_t { void foo() { const uint32x2_t signBit = { (uint2) 0x80000000 }; } + +// CHECK: %struct.fp_struct_foo = type { void (i32)* } +struct fp_struct_bar { int a; }; + +struct fp_struct_foo { + void (*FP)(struct fp_struct_bar); +} G; + diff --git a/test/CodeGen/struct.c b/test/CodeGen/struct.c index 25477a0..e173931 100644 --- a/test/CodeGen/struct.c +++ b/test/CodeGen/struct.c @@ -181,3 +181,16 @@ range f18() { rangepair rp; return (rp = f18_ext()).range1; } + + + +// Complex forward reference of struct. +struct f19S; +extern struct f19T { + struct f19S (*p)(void); +} t; +struct f19S { int i; }; +void f19(void) { + t.p(); +} + diff --git a/test/CodeGen/trapv.c b/test/CodeGen/trapv.c index 7f192c6..f52dad5 100644 --- a/test/CodeGen/trapv.c +++ b/test/CodeGen/trapv.c @@ -1,7 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ftrapv %s -emit-llvm -o - | FileCheck %s -// CHECK: [[I32O:%.*]] = type { i32, i1 } - unsigned int ui, uj, uk; int i, j, k; @@ -16,9 +14,9 @@ void test0() { // CHECK: [[T1:%.*]] = load i32* @j // CHECK-NEXT: [[T2:%.*]] = load i32* @k - // CHECK-NEXT: [[T3:%.*]] = call [[I32O]] @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 [[T2]]) - // CHECK-NEXT: [[T4:%.*]] = extractvalue [[I32O]] [[T3]], 0 - // CHECK-NEXT: [[T5:%.*]] = extractvalue [[I32O]] [[T3]], 1 + // CHECK-NEXT: [[T3:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 [[T2]]) + // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T3]], 0 + // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T3]], 1 // CHECK-NEXT: br i1 [[T5]] // CHECK: call void @llvm.trap() i = j + k; @@ -30,9 +28,9 @@ void test1() { opaque(i++); // CHECK: [[T1:%.*]] = load i32* @i - // CHECK-NEXT: [[T2:%.*]] = call [[I32O]] @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) - // CHECK-NEXT: [[T3:%.*]] = extractvalue [[I32O]] [[T2]], 0 - // CHECK-NEXT: [[T4:%.*]] = extractvalue [[I32O]] [[T2]], 1 + // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) + // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0 + // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1 // CHECK-NEXT: br i1 [[T4]] // CHECK: call void @llvm.trap() } @@ -43,9 +41,9 @@ void test2() { opaque(++i); // CHECK: [[T1:%.*]] = load i32* @i - // CHECK-NEXT: [[T2:%.*]] = call [[I32O]] @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) - // CHECK-NEXT: [[T3:%.*]] = extractvalue [[I32O]] [[T2]], 0 - // CHECK-NEXT: [[T4:%.*]] = extractvalue [[I32O]] [[T2]], 1 + // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) + // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0 + // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1 // CHECK-NEXT: br i1 [[T4]] // CHECK: call void @llvm.trap() } diff --git a/test/CodeGen/union-init2.c b/test/CodeGen/union-init2.c index 1386c27..bf20696 100644 --- a/test/CodeGen/union-init2.c +++ b/test/CodeGen/union-init2.c @@ -1,11 +1,11 @@ // RUN: %clang_cc1 -emit-llvm %s -o - -triple i686-pc-linux-gnu | FileCheck %s // Make sure we generate something sane instead of a ptrtoint -// CHECK: bitcast (%0* @r to %union.x*), [4 x i8] undef +// CHECK: bitcast ({ %union.x*, [4 x i8] }* @r to %union.x*), [4 x i8] undef union x {long long b;union x* a;} r = {.a = &r}; -// CHECK: global %1 { [3 x i8] zeroinitializer, [5 x i8] undef } +// CHECK: global { [3 x i8], [5 x i8] } { [3 x i8] zeroinitializer, [5 x i8] undef } union z { char a[3]; long long b; diff --git a/test/CodeGen/vla.c b/test/CodeGen/vla.c index e5114a5..c9612bc 100644 --- a/test/CodeGen/vla.c +++ b/test/CodeGen/vla.c @@ -88,13 +88,60 @@ int test2(int n) // http://llvm.org/PR8567 // CHECK: define double @test_PR8567 double test_PR8567(int n, double (*p)[n][5]) { - // CHECK: store [[vla_type:.*]] %p, - // CHECK: load i32* - // CHECK-NEXT: mul i32 40 - // CHECK-NEXT: [[byte_idx:%.*]] = mul i32 1 - // CHECK-NEXT: [[tmp_1:%.*]] = load [[vla_type]]* - // CHECK-NEXT: [[tmp_2:%.*]] = bitcast [[vla_type]] [[tmp_1]] to i8* - // CHECK-NEXT: [[idx:%.*]] = getelementptr inbounds i8* [[tmp_2]], i32 [[byte_idx]] - // CHECK-NEXT: bitcast i8* [[idx]] to [[vla_type]] + // CHECK: [[NV:%.*]] = alloca i32, align 4 + // CHECK-NEXT: [[PV:%.*]] = alloca [5 x double]*, align 4 + // CHECK-NEXT: store + // CHECK-NEXT: store + // CHECK-NEXT: [[N:%.*]] = load i32* [[NV]], align 4 + // CHECK-NEXT: [[P:%.*]] = load [5 x double]** [[PV]], align 4 + // CHECK-NEXT: [[T0:%.*]] = mul nsw i32 1, [[N]] + // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [5 x double]* [[P]], i32 [[T0]] + // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [5 x double]* [[T1]], i32 2 + // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [5 x double]* [[T2]], i32 0, i32 3 + // CHECK-NEXT: [[T4:%.*]] = load double* [[T3]] + // CHECK-NEXT: ret double [[T4]] return p[1][2][3]; } + +int test4(unsigned n, char (*p)[n][n+1][6]) { + // CHECK: define i32 @test4( + // CHECK: [[N:%.*]] = alloca i32, align 4 + // CHECK-NEXT: [[P:%.*]] = alloca [6 x i8]*, align 4 + // CHECK-NEXT: [[P2:%.*]] = alloca [6 x i8]*, align 4 + // CHECK-NEXT: store i32 + // CHECK-NEXT: store [6 x i8]* + + // VLA captures. + // CHECK-NEXT: [[DIM0:%.*]] = load i32* [[N]], align 4 + // CHECK-NEXT: [[T0:%.*]] = load i32* [[N]], align 4 + // CHECK-NEXT: [[DIM1:%.*]] = add i32 [[T0]], 1 + + // __typeof. FIXME: does this really need to be loaded? + // CHECK-NEXT: load [6 x i8]** [[P]] + + // CHECK-NEXT: [[T0:%.*]] = load [6 x i8]** [[P]], align 4 + // CHECK-NEXT: [[T1:%.*]] = load i32* [[N]], align 4 + // CHECK-NEXT: [[T2:%.*]] = udiv i32 [[T1]], 2 + // CHECK-NEXT: [[T3:%.*]] = mul nuw i32 [[DIM0]], [[DIM1]] + // CHECK-NEXT: [[T4:%.*]] = mul nsw i32 [[T2]], [[T3]] + // CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [6 x i8]* [[T0]], i32 [[T4]] + // CHECK-NEXT: [[T6:%.*]] = load i32* [[N]], align 4 + // CHECK-NEXT: [[T7:%.*]] = udiv i32 [[T6]], 4 + // CHECK-NEXT: [[T8:%.*]] = sub i32 0, [[T7]] + // CHECK-NEXT: [[T9:%.*]] = mul nuw i32 [[DIM0]], [[DIM1]] + // CHECK-NEXT: [[T10:%.*]] = mul nsw i32 [[T8]], [[T9]] + // CHECK-NEXT: [[T11:%.*]] = getelementptr inbounds [6 x i8]* [[T5]], i32 [[T10]] + // CHECK-NEXT: store [6 x i8]* [[T11]], [6 x i8]** [[P2]], align 4 + __typeof(p) p2 = (p + n/2) - n/4; + + // CHECK-NEXT: [[T0:%.*]] = load [6 x i8]** [[P2]], align 4 + // CHECK-NEXT: [[T1:%.*]] = load [6 x i8]** [[P]], align 4 + // CHECK-NEXT: [[T2:%.*]] = ptrtoint [6 x i8]* [[T0]] to i32 + // CHECK-NEXT: [[T3:%.*]] = ptrtoint [6 x i8]* [[T1]] to i32 + // CHECK-NEXT: [[T4:%.*]] = sub i32 [[T2]], [[T3]] + // CHECK-NEXT: [[T5:%.*]] = mul nuw i32 [[DIM0]], [[DIM1]] + // CHECK-NEXT: [[T6:%.*]] = mul nuw i32 6, [[T5]] + // CHECK-NEXT: [[T7:%.*]] = sdiv exact i32 [[T4]], [[T6]] + // CHECK-NEXT: ret i32 [[T7]] + return p2 - p; +} diff --git a/test/CodeGen/volatile-1.c b/test/CodeGen/volatile-1.c index f54afff..7c7a822 100644 --- a/test/CodeGen/volatile-1.c +++ b/test/CodeGen/volatile-1.c @@ -4,7 +4,7 @@ volatile int i, j, k; volatile int ar[5]; volatile char c; -// CHECK: @ci = common global [[CINT:%.*]] zeroinitializer +// CHECK: @ci = common global [[CINT:.*]] zeroinitializer volatile _Complex int ci; volatile struct S { #ifdef __cplusplus diff --git a/test/CodeGen/volatile-2.c b/test/CodeGen/volatile-2.c index 1ceaf17..490b7d7 100644 --- a/test/CodeGen/volatile-2.c +++ b/test/CodeGen/volatile-2.c @@ -3,8 +3,8 @@ void test0() { // CHECK: define void @test0() // CHECK: [[F:%.*]] = alloca float - // CHECK-NEXT: [[REAL:%.*]] = volatile load float* getelementptr inbounds ({{%.*}} @test0_v, i32 0, i32 0) - // CHECK-NEXT: volatile load float* getelementptr inbounds ({{%.*}} @test0_v, i32 0, i32 1) + // CHECK-NEXT: [[REAL:%.*]] = volatile load float* getelementptr inbounds ({ float, float }* @test0_v, i32 0, i32 0) + // CHECK-NEXT: volatile load float* getelementptr inbounds ({{.*}} @test0_v, i32 0, i32 1) // CHECK-NEXT: store float [[REAL]], float* [[F]], align 4 // CHECK-NEXT: ret void extern volatile _Complex float test0_v; @@ -13,10 +13,10 @@ void test0() { void test1() { // CHECK: define void @test1() - // CHECK: [[REAL:%.*]] = volatile load float* getelementptr inbounds ({{%.*}} @test1_v, i32 0, i32 0) - // CHECK-NEXT: [[IMAG:%.*]] = volatile load float* getelementptr inbounds ({{%.*}} @test1_v, i32 0, i32 1) - // CHECK-NEXT: volatile store float [[REAL]], float* getelementptr inbounds ({{%.*}} @test1_v, i32 0, i32 0) - // CHECK-NEXT: volatile store float [[IMAG]], float* getelementptr inbounds ({{%.*}} @test1_v, i32 0, i32 1) + // CHECK: [[REAL:%.*]] = volatile load float* getelementptr inbounds ({{.*}} @test1_v, i32 0, i32 0) + // CHECK-NEXT: [[IMAG:%.*]] = volatile load float* getelementptr inbounds ({{.*}} @test1_v, i32 0, i32 1) + // CHECK-NEXT: volatile store float [[REAL]], float* getelementptr inbounds ({{.*}} @test1_v, i32 0, i32 0) + // CHECK-NEXT: volatile store float [[IMAG]], float* getelementptr inbounds ({{.*}} @test1_v, i32 0, i32 1) // CHECK-NEXT: ret void extern volatile _Complex float test1_v; test1_v = test1_v; diff --git a/test/CodeGen/x86_32-arguments-darwin.c b/test/CodeGen/x86_32-arguments-darwin.c index f7e2a53..731d4f6 100644 --- a/test/CodeGen/x86_32-arguments-darwin.c +++ b/test/CodeGen/x86_32-arguments-darwin.c @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -w -fblocks -triple i386-apple-darwin9 -emit-llvm -o %t %s -// RUN: FileCheck < %t %s +// RUN: %clang_cc1 -w -fblocks -triple i386-apple-darwin9 -target-cpu yonah -emit-llvm -o - %s | FileCheck %s // CHECK: define signext i8 @f0() char f0(void) { @@ -232,7 +231,7 @@ v4i32 f55(v4i32 arg) { return arg+arg; } // CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1, // CHECK: x86_mmx %a2.coerce, %struct.s56_1* byval align 4, // CHECK: i64 %a4.coerce, %struct.s56_2* byval align 4, -// CHECK: <4 x i32> %a6, %struct.s39* byval align 16 %a7, +// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 16 %a7, // CHECK: <2 x double> %a8, %struct.s56_4* byval align 16 %a9, // CHECK: <8 x i32> %a10, %struct.s56_5* byval align 4, // CHECK: <4 x double> %a12, %struct.s56_6* byval align 4) @@ -241,7 +240,7 @@ v4i32 f55(v4i32 arg) { return arg+arg; } // CHECK: i32 %{{[^ ]*}}, %struct.s56_0* byval align 4 %{{[^ ]*}}, // CHECK: x86_mmx %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}}, // CHECK: i64 %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}}, -// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s39* byval align 16 %{{[^ ]*}}, +// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 16 %{{[^ ]*}}, // CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 16 %{{[^ ]*}}, // CHECK: <8 x i32> {{[^ ]*}}, %struct.s56_5* byval align 4 %{{[^ ]*}}, // CHECK: <4 x double> {{[^ ]*}}, %struct.s56_6* byval align 4 %{{[^ ]*}}) diff --git a/test/CodeGen/x86_32-arguments-linux.c b/test/CodeGen/x86_32-arguments-linux.c index 2f246f8..81dcaf6 100644 --- a/test/CodeGen/x86_32-arguments-linux.c +++ b/test/CodeGen/x86_32-arguments-linux.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -w -fblocks -triple i386-pc-linux-gnu -emit-llvm -o %t %s +// RUN: %clang_cc1 -w -fblocks -triple i386-pc-linux-gnu -target-cpu pentium4 -emit-llvm -o %t %s // RUN: FileCheck < %t %s // CHECK: define void @f56( diff --git a/test/CodeGen/x86_32-arguments-nommx.c b/test/CodeGen/x86_32-arguments-nommx.c new file mode 100644 index 0000000..40362f7 --- /dev/null +++ b/test/CodeGen/x86_32-arguments-nommx.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -target-feature -mmx -target-feature +sse2 -triple i686-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s + +// no-mmx should put mmx into memory +typedef int __attribute__((vector_size (8))) i32v2; +int a(i32v2 x) { return x[0]; } +// CHECK: define i32 @a(i64 %x.coerce) + +// but SSE2 vectors should still go into an SSE2 register +typedef int __attribute__((vector_size (16))) i32v4; +int b(i32v4 x) { return x[0]; } +// CHECK: define i32 @b(<4 x i32> %x) diff --git a/test/CodeGen/x86_64-arguments.c b/test/CodeGen/x86_64-arguments.c index 75c4788..221c7d3 100644 --- a/test/CodeGen/x86_64-arguments.c +++ b/test/CodeGen/x86_64-arguments.c @@ -42,8 +42,8 @@ void f7(e7 a0) { // Test merging/passing of upper eightbyte with X87 class. // -// CHECK: define void @f8_1(%struct.s19* sret %agg.result) -// CHECK: define void @f8_2(%struct.s19* byval align 16 %a0) +// CHECK: define void @f8_1(%union.u8* sret %agg.result) +// CHECK: define void @f8_2(%union.u8* byval align 16 %a0) union u8 { long double a; int b; @@ -58,7 +58,7 @@ struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} } struct s10 { int a; int b; int : 0; }; void f10(struct s10 a0) {} -// CHECK: define void @f11(%struct.s19* sret %agg.result) +// CHECK: define void @f11(%union.anon* sret %agg.result) union { long double a; float b; } f11() { while (1) {} } // CHECK: define i32 @f12_0() @@ -147,7 +147,7 @@ struct f24s { long a; int b; }; struct f23S f24(struct f23S *X, struct f24s *P2) { return *X; - // CHECK: define %struct.f24s @f24(%struct.f23S* %X, %struct.f24s* %P2) + // CHECK: define { i64, i32 } @f24(%struct.f23S* %X, %struct.f24s* %P2) } // rdar://8248065 @@ -169,7 +169,7 @@ struct foo26 { }; struct foo26 f26(struct foo26 *P) { - // CHECK: define %struct.foo26 @f26(%struct.foo26* %P) + // CHECK: define { i32*, float* } @f26(%struct.foo26* %P) return *P; } @@ -259,3 +259,48 @@ void f9122143() func(ss); } +// CHECK: define double @f36(double %arg.coerce) +typedef unsigned v2i32 __attribute((__vector_size__(8))); +v2i32 f36(v2i32 arg) { return arg; } + +// CHECK: declare void @f38(<8 x float>) +// CHECK: declare void @f37(<8 x float>) +typedef float __m256 __attribute__ ((__vector_size__ (32))); +typedef struct { + __m256 m; +} s256; + +s256 x38; +__m256 x37; + +void f38(s256 x); +void f37(__m256 x); +void f39() { f38(x38); f37(x37); } + +// The two next tests make sure that the struct below is passed +// in the same way regardless of avx being used + +// CHECK: declare void @func40(%struct.t128* byval align 16) +typedef float __m128 __attribute__ ((__vector_size__ (16))); +typedef struct t128 { + __m128 m; + __m128 n; +} two128; + +extern void func40(two128 s); +void func41(two128 s) { + func40(s); +} + +// CHECK: declare void @func42(%struct.t128_2* byval align 16) +typedef struct xxx { + __m128 array[2]; +} Atwo128; +typedef struct t128_2 { + Atwo128 x; +} SA; + +extern void func42(SA s); +void func43(SA s) { + func42(s); +} |