1 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
5 // Extremely basic VLA test
14 return sizeof(int[n
]);
34 // Make sure we emit sizes correctly in some obscure cases
40 // CHECK: define void @f_8403108
41 void f_8403108(unsigned x
) {
42 // CHECK: call i8* @llvm.stacksave()
45 // CHECK: call i8* @llvm.stacksave()
49 // CHECK: call void @llvm.stackrestore(i8*
51 // CHECK: call void @llvm.stackrestore(i8*
55 void function(short width
, int data
[][width
]) {} // expected-note {{passing argument to parameter 'data' here}}
59 // CHECK: call void @function(i16 signext 1, i32* null)
61 // CHECK: call void @function(i16 signext 1, i32* inttoptr
62 function(1, 0xbadbeef); // expected-warning {{incompatible integer to pointer conversion passing}}
63 // CHECK: call void @function(i16 signext 1, i32* {{.*}})
67 void function1(short width
, int data
[][width
][width
]) {}
70 // CHECK: call void @function1(i16 signext 1, i32* {{.*}})
72 // CHECK: call void @function(i16 signext 1, i32* {{.*}})
81 char b
[1][n
+3]; /* Variable length array. */
82 // CHECK: [[tmp_1:%.*]] = load i32* @GLOB, align 4
83 // CHECK-NEXT: add nsw i32 [[tmp_1]], 1
84 __typeof__(b
[GLOB
++]) c
;
88 // http://llvm.org/PR8567
89 // CHECK: define double @test_PR8567
90 double test_PR8567(int n
, double (*p
)[n
][5]) {
91 // CHECK: store [[vla_type:.*]] %p,
93 // CHECK-NEXT: mul i32 40
94 // CHECK-NEXT: [[byte_idx:%.*]] = mul i32 1
95 // CHECK-NEXT: [[tmp_1:%.*]] = load [[vla_type]]*
96 // CHECK-NEXT: [[tmp_2:%.*]] = bitcast [[vla_type]] [[tmp_1]] to i8*
97 // CHECK-NEXT: [[idx:%.*]] = getelementptr inbounds i8* [[tmp_2]], i32 [[byte_idx]]
98 // CHECK-NEXT: bitcast i8* [[idx]] to [[vla_type]]