cebowleratibm created this revision.
cebowleratibm added a reviewer: AaronLiu.
cebowleratibm added a project: clang.
Herald added a project: All.
cebowleratibm requested review of this revision.
Herald added a subscriber: cfe-commits.

This test is based on a customer-reported failure in an XL compiler, added here 
to improve clang regression testing.  The primary purpose of the test is to 
ensure that the array initializations can be evaluated without the need for 
runtime initialization.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122497

Files:
  clang/test/CodeGen/array-init-2.c


Index: clang/test/CodeGen/array-init-2.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/array-init-2.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+typedef enum {
+   a,
+   b,
+   c,
+   d,
+   e,
+   f,
+   g,
+   h
+} E;
+
+typedef struct {
+   E c;
+   int val;
+} Entry;
+
+static const Entry entries[] = {
+   {a,},
+   {b,},
+   {c,},
+   {d,},
+   {e,},
+   {f,},
+   {g,},
+   {h,}
+};
+
+const Entry *list[] = {
+   entries,
+   entries,
+   entries
+};
+
+// CHECK: %struct.Entry = type { [[E:i[0-9]+]], i32 }
+// CHECK: @entries = internal constant [8 x %struct.Entry] [%struct.Entry 
zeroinitializer, %struct.Entry { [[E]] 1, i32 0 }, %struct.Entry { [[E]] 2, i32 
0 }, %struct.Entry { [[E]] 3, i32 0 }, %struct.Entry { [[E]] 4, i32 0 }, 
%struct.Entry { [[E]] 5, i32 0 }, %struct.Entry { [[E]] 6, i32 0 }, 
%struct.Entry { [[E]] 7, i32 0 }], align 4
+// CHECK: @list = global [3 x %struct.Entry*] [%struct.Entry* getelementptr 
inbounds ([8 x %struct.Entry], [8 x %struct.Entry]* @entries, i32 0, i32 0), 
%struct.Entry* getelementptr inbounds ([8 x %struct.Entry], [8 x 
%struct.Entry]* @entries, i32 0, i32 0), %struct.Entry* getelementptr inbounds 
([8 x %struct.Entry], [8 x %struct.Entry]* @entries, i32 0, i32 0)], align 8


Index: clang/test/CodeGen/array-init-2.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/array-init-2.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+typedef enum {
+   a,
+   b,
+   c,
+   d,
+   e,
+   f,
+   g,
+   h
+} E;
+
+typedef struct {
+   E c;
+   int val;
+} Entry;
+
+static const Entry entries[] = {
+   {a,},
+   {b,},
+   {c,},
+   {d,},
+   {e,},
+   {f,},
+   {g,},
+   {h,}
+};
+
+const Entry *list[] = {
+   entries,
+   entries,
+   entries
+};
+
+// CHECK: %struct.Entry = type { [[E:i[0-9]+]], i32 }
+// CHECK: @entries = internal constant [8 x %struct.Entry] [%struct.Entry zeroinitializer, %struct.Entry { [[E]] 1, i32 0 }, %struct.Entry { [[E]] 2, i32 0 }, %struct.Entry { [[E]] 3, i32 0 }, %struct.Entry { [[E]] 4, i32 0 }, %struct.Entry { [[E]] 5, i32 0 }, %struct.Entry { [[E]] 6, i32 0 }, %struct.Entry { [[E]] 7, i32 0 }], align 4
+// CHECK: @list = global [3 x %struct.Entry*] [%struct.Entry* getelementptr inbounds ([8 x %struct.Entry], [8 x %struct.Entry]* @entries, i32 0, i32 0), %struct.Entry* getelementptr inbounds ([8 x %struct.Entry], [8 x %struct.Entry]* @entries, i32 0, i32 0), %struct.Entry* getelementptr inbounds ([8 x %struct.Entry], [8 x %struct.Entry]* @entries, i32 0, i32 0)], align 8
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to