[PATCH 3/4] testsuite: improve mem2reg testcases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

diff --git a/validation/crash-select.c b/validation/crash-select.c
new file mode 100644
index 000000000..cec00baf8
--- /dev/null
+++ b/validation/crash-select.c
@@ -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
+ */
diff --git a/validation/alias-distinct.c b/validation/mem2reg/alias-distinct.c
similarity index 100%
rename from validation/alias-distinct.c
rename to validation/mem2reg/alias-distinct.c
diff --git a/validation/alias-mixed.c b/validation/mem2reg/alias-mixed.c
similarity index 100%
rename from validation/alias-mixed.c
rename to validation/mem2reg/alias-mixed.c
diff --git a/validation/alias-same.c b/validation/mem2reg/alias-same.c
similarity index 100%
rename from validation/alias-same.c
rename to validation/mem2reg/alias-same.c
diff --git a/validation/mem2reg/cond-expr.c b/validation/mem2reg/cond-expr.c
index f38564ef8..8acb00ac9 100644
--- a/validation/mem2reg/cond-expr.c
+++ b/validation/mem2reg/cond-expr.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\\.
  */
diff --git a/validation/mem2reg/cond-expr5.c b/validation/mem2reg/cond-expr5.c
index 6c1e1c34d..62ac6c15d 100644
--- a/validation/mem2reg/cond-expr5.c
+++ b/validation/mem2reg/cond-expr5.c
@@ -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\\.
  */
diff --git a/validation/mem2reg/init-global-array.c b/validation/mem2reg/init-global-array.c
index aea4135ae..51ca50e35 100644
--- a/validation/mem2reg/init-global-array.c
+++ b/validation/mem2reg/init-global-array.c
@@ -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
  */
diff --git a/validation/mem2reg/init-local-array.c b/validation/mem2reg/init-local-array.c
index 2ac53bc77..639a74f10 100644
--- a/validation/mem2reg/init-local-array.c
+++ b/validation/mem2reg/init-local-array.c
@@ -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
  */
diff --git a/validation/kill-casts.c b/validation/mem2reg/kill-casts.c
similarity index 100%
rename from validation/kill-casts.c
rename to validation/mem2reg/kill-casts.c
diff --git a/validation/mem2reg/loop02-global.c b/validation/mem2reg/loop02-global.c
index a0a8b42b0..b627b33d1 100644
--- a/validation/mem2reg/loop02-global.c
+++ b/validation/mem2reg/loop02-global.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\\.
  */
diff --git a/validation/mem2reg/missing-return.c b/validation/mem2reg/missing-return.c
new file mode 100644
index 000000000..06f6e4d52
--- /dev/null
+++ b/validation/mem2reg/missing-return.c
@@ -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
+ */
diff --git a/validation/reload-aliasing.c b/validation/mem2reg/reload-aliasing.c
similarity index 100%
rename from validation/reload-aliasing.c
rename to validation/mem2reg/reload-aliasing.c
diff --git a/validation/mem2reg/store-deadborn.c b/validation/mem2reg/store-deadborn.c
new file mode 100644
index 000000000..cca34d592
--- /dev/null
+++ b/validation/mem2reg/store-deadborn.c
@@ -0,0 +1,9 @@
+static void foo(int a)
+{
+	return;
+	a = 0;
+}
+
+/*
+ * check-name: store-deadborn
+ */
diff --git a/validation/linear/stray-phisrc.c b/validation/mem2reg/stray-phisrc.c
similarity index 100%
rename from validation/linear/stray-phisrc.c
rename to validation/mem2reg/stray-phisrc.c
diff --git a/validation/mem2reg/struct.c b/validation/mem2reg/struct.c
new file mode 100644
index 000000000..13962a8e6
--- /dev/null
+++ b/validation/mem2reg/struct.c
@@ -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
+ */
diff --git a/validation/mem2reg/unused-var.c b/validation/mem2reg/unused-var.c
new file mode 100644
index 000000000..ac3945820
--- /dev/null
+++ b/validation/mem2reg/unused-var.c
@@ -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
+ */
diff --git a/validation/mem2reg/killed-insn.c b/validation/optim/killed-insn.c
similarity index 53%
rename from validation/mem2reg/killed-insn.c
rename to validation/optim/killed-insn.c
index adbef9805..d1cdd02ee 100644
--- a/validation/mem2reg/killed-insn.c
+++ b/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\\.
diff --git a/validation/optim/null-phi.c b/validation/optim/null-phi.c
new file mode 100644
index 000000000..1f9de4d5b
--- /dev/null
+++ b/validation/optim/null-phi.c
@@ -0,0 +1,9 @@
+static int foo(void)
+{
+	if (0)
+		return 0;
+}
+
+/*
+ * check-name: null-phi
+ */
-- 
2.16.2

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux