[PATCH] D122497: [clang][NFC] Add filescope array initialization test
Chris Bowler via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 25 12:07:15 PDT 2022
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122497.418282.patch
Type: text/x-patch
Size: 1322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220325/7375b5b1/attachment.bin>
More information about the cfe-commits
mailing list