new file mode 100644
@@ -0,0 +1,18 @@
+struct s {
+ void *b;
+ long c;
+};
+
+long d(void);
+static long f(void)
+{
+ struct s s;
+ s.c = d();
+ if (s.c)
+ s.c = 2;
+ return s.c;
+}
+
+/*
+ * check-name: crash-select
+ */
similarity index 100%
rename from validation/alias-distinct.c
rename to validation/mem2reg/alias-distinct.c
similarity index 100%
rename from validation/alias-mixed.c
rename to validation/mem2reg/alias-mixed.c
similarity index 100%
rename from validation/alias-same.c
rename to validation/mem2reg/alias-same.c
@@ -10,4 +10,5 @@ int foo(int a, int b, int c)
* check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
* check-output-ignore
* check-output-pattern(2): phi\\.
+ * check-output-pattern(3): phisrc\\.
*/
@@ -11,8 +11,12 @@ int foo(int p, int q, int a)
/*
* check-name: cond-expr5
* check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-known-to-fail
+ *
* check-output-ignore
* check-output-excludes: load\\.
* check-output-excludes: store\\.
- * check-output-pattern(2): phi\\.
+ * check-output-excludes: phi\\..*, .*, .*
+ * check-output-pattern(3): phi\\.
+ * check-output-pattern(5): phisrc\\.
*/
@@ -1,8 +1,11 @@
-struct {
+struct s {
int a[2];
-} s;
+};
-int sarray(void)
+
+static struct s s;
+
+static int sarray(void)
{
s.a[1] = 1;
return s.a[1];
@@ -10,8 +13,9 @@ int sarray(void)
/*
* check-name: init global array
- * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-command: test-linearize $file
* check-output-ignore
* check-output-excludes: load\\.
* check-output-pattern(1): store\\.
+ * check-output-pattern(1): ret.32 *\\$1
*/
@@ -1,25 +1,28 @@
-int array(void)
+static int array(void)
{
int a[2];
a[1] = 1;
+ a[0] = 0;
return a[1];
}
-int sarray(void)
+static int sarray(void)
{
struct {
int a[2];
} s;
s.a[1] = 1;
+ s.a[0] = 0;
return s.a[1];
}
/*
* check-name: init local array
- * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-command: test-linearize $file
* check-output-ignore
- * check-output-excludes: load\\.
- * check-output-excludes: store\\.
+ * check-output-excludes: load
+ * check-output-excludes: store
+ * check-output-pattern(2): ret.32 *\\$1
*/
similarity index 100%
rename from validation/kill-casts.c
rename to validation/mem2reg/kill-casts.c
@@ -16,7 +16,7 @@ int foo(void)
/*
* check-name: loop02 global
- * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-command: test-linearize -Wno-decl $file
* check-output-ignore
* check-output-excludes: load\\.
*/
new file mode 100644
@@ -0,0 +1,34 @@
+int f1(void)
+{
+ if (1)
+ return 1;
+}
+
+int f0(void)
+{
+ if (0)
+ return 0;
+}
+
+int fx(int p)
+{
+ if (p)
+ return 0;
+}
+
+int bar(int p)
+{
+ if (p)
+ return 0;
+ p++;
+}
+
+/*
+ * check-name: missing-return
+ * check-command: test-linearize -m32 -fdump-ir=mem2reg -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): ret.32 *\\$1
+ * check-output-pattern(3): ret.32 *UNDEF
+ */
similarity index 100%
rename from validation/reload-aliasing.c
rename to validation/mem2reg/reload-aliasing.c
new file mode 100644
@@ -0,0 +1,9 @@
+static void foo(int a)
+{
+ return;
+ a = 0;
+}
+
+/*
+ * check-name: store-deadborn
+ */
similarity index 100%
rename from validation/linear/stray-phisrc.c
rename to validation/mem2reg/stray-phisrc.c
new file mode 100644
@@ -0,0 +1,32 @@
+struct s {
+ int a;
+ int b;
+};
+
+int f0(void)
+{
+ struct s s;
+
+ s.a = 0;
+ s.b = 1;
+
+ return s.a;
+}
+
+int f1(void)
+{
+ struct s s;
+
+ s.a = 1;
+ s.b = 0;
+
+ return s.b;
+}
+
+/*
+ * check-name: struct
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-pattern(2): ret.32 *\\$0
+ */
new file mode 100644
@@ -0,0 +1,23 @@
+int foo(int a)
+{
+ switch (a) {
+ int u = 1;
+
+ default:
+ return a;
+ }
+}
+
+/*
+ * check-name: unused-var
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-start
+foo:
+.L0:
+ <entry-point>
+ ret.32 %arg1
+
+
+ * check-output-end
+ */
similarity index 53%
rename from validation/mem2reg/killed-insn.c
rename to validation/optim/killed-insn.c
@@ -1,14 +1,13 @@
-static int g;
-static void foo(void)
+static void foo(int v)
{
int a[2] = { };
a;
- a[1] = g;
+ a[1] = v;
}
/*
* check-name: killed-insn
- * check-command: test-linearize -fdump-ir=mem2reg $file
+ * check-command: test-linearize $file
*
* check-output-ignore
* check-output-excludes: store\\.
new file mode 100644
@@ -0,0 +1,9 @@
+static int foo(void)
+{
+ if (0)
+ return 0;
+}
+
+/*
+ * check-name: null-phi
+ */
A few tests are added, some have been renamed to better refect their purposes. Finally, some checks have been added or tweaked. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- validation/crash-select.c | 18 ++++++++++++++ validation/{ => mem2reg}/alias-distinct.c | 0 validation/{ => mem2reg}/alias-mixed.c | 0 validation/{ => mem2reg}/alias-same.c | 0 validation/mem2reg/cond-expr.c | 1 + validation/mem2reg/cond-expr5.c | 6 ++++- validation/mem2reg/init-global-array.c | 12 ++++++---- validation/mem2reg/init-local-array.c | 13 ++++++---- validation/{ => mem2reg}/kill-casts.c | 0 validation/mem2reg/loop02-global.c | 2 +- validation/mem2reg/missing-return.c | 34 +++++++++++++++++++++++++++ validation/{ => mem2reg}/reload-aliasing.c | 0 validation/mem2reg/store-deadborn.c | 9 +++++++ validation/{linear => mem2reg}/stray-phisrc.c | 0 validation/mem2reg/struct.c | 32 +++++++++++++++++++++++++ validation/mem2reg/unused-var.c | 23 ++++++++++++++++++ validation/{mem2reg => optim}/killed-insn.c | 7 +++--- validation/optim/null-phi.c | 9 +++++++ 18 files changed, 151 insertions(+), 15 deletions(-) create mode 100644 validation/crash-select.c rename validation/{ => mem2reg}/alias-distinct.c (100%) rename validation/{ => mem2reg}/alias-mixed.c (100%) rename validation/{ => mem2reg}/alias-same.c (100%) rename validation/{ => mem2reg}/kill-casts.c (100%) create mode 100644 validation/mem2reg/missing-return.c rename validation/{ => mem2reg}/reload-aliasing.c (100%) create mode 100644 validation/mem2reg/store-deadborn.c rename validation/{linear => mem2reg}/stray-phisrc.c (100%) create mode 100644 validation/mem2reg/struct.c create mode 100644 validation/mem2reg/unused-var.c rename validation/{mem2reg => optim}/killed-insn.c (53%) create mode 100644 validation/optim/null-phi.c