[PATCH 01/10] add simple testcases for internal infinite loops

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

 



The current SSA conversion kinda ignore undefined variables.
Those may then later be detected when they are part of a
LOAD + (ADD|SUB) cycle but they can also create other cycles
which are not detected.

These cycles inhibit (or uselessly complicate) lots of optimizations.
For example, code like:
	and.32	%r2 <- %r1, $1
	and.32	%r3 <- %r2, $1
should be simplified into:
	and.32	%r3 <- %r1, $1
but this simplification would behave horribly with 'cycles' like:
	and.32	%r1 <- %r1, $1

This patch add a testcase for a number a very simple situations
where such cycles can be created.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/infinite-loop01.c | 54 ++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 validation/infinite-loop01.c

diff --git a/validation/infinite-loop01.c b/validation/infinite-loop01.c
new file mode 100644
index 000000000..521cfb4d4
--- /dev/null
+++ b/validation/infinite-loop01.c
@@ -0,0 +1,54 @@
+void fnp(void)
+{
+	int a;
+	for (;;)
+		a += 1;
+}
+
+void fnm(void)
+{
+	int a;
+	for (;;)
+		a -= 1;
+}
+
+void fna(void)
+{
+	int a;
+	for (;;)
+		a &= 1;
+}
+
+void fno(void)
+{
+	int a;
+	for (;;)
+		a |= 1;
+}
+
+void fnx(void)
+{
+	int a;
+	for (;;)
+		a ^= 1;
+}
+
+void fnl(void)
+{
+	int a;
+	for (;;)
+		a <<= 1;
+}
+
+void fnr(void)
+{
+	int a;
+	for (;;)
+		a >>= 1;
+}
+
+/*
+ * check-name: infinite loop 01
+ * check-command: sparse -Wno-decl $file
+ * check-timeout:
+ */
-- 
2.18.0

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