From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Christopher Li <sparse@chrisli.org>
Cc: linux-sparse@vger.kernel.org,
Michael Stefaniuc <mstefani@mykolab.com>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH v3 2/7] fix infinite simplification loops
Date: Mon, 31 Jul 2017 22:36:19 +0200 [thread overview]
Message-ID: <20170731203624.58971-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170731203624.58971-1-luc.vanoostenryck@gmail.com>
Each time a parent is removed from a BB there is
the possibility that the BB become unreachable.
This in turn can create cycles of dead BBs which
can the create inifinite loops during the
simplification process.
Fix this by setting the flag REPEAT_CFG_CLEANUP when
a branch is rewritten, this will in turn trigger
a call to kill_unreachable_bbs() which will break
these loops.
Reported-by: Michael Stefaniuc <mstefani@mykolab.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
flow.c | 3 ++-
validation/infinite-loop02.c | 11 +++++++++++
validation/infinite-loop03.c | 16 ++++++++++++++++
3 files changed, 29 insertions(+), 1 deletion(-)
create mode 100644 validation/infinite-loop02.c
create mode 100644 validation/infinite-loop03.c
diff --git a/flow.c b/flow.c
index fce8bde21..536bf257f 100644
--- a/flow.c
+++ b/flow.c
@@ -34,7 +34,8 @@ static int rewrite_branch(struct basic_block *bb,
return 0;
/* We might find new if-conversions or non-dominating CSEs */
- repeat_phase |= REPEAT_CSE;
+ /* we may also create new dead cycles */
+ repeat_phase |= REPEAT_CSE | REPEAT_CFG_CLEANUP;
*ptr = new;
replace_bb_in_list(&bb->children, old, new, 1);
remove_bb_from_list(&old->parents, bb, 1);
diff --git a/validation/infinite-loop02.c b/validation/infinite-loop02.c
new file mode 100644
index 000000000..7d0761d87
--- /dev/null
+++ b/validation/infinite-loop02.c
@@ -0,0 +1,11 @@
+void foo(void)
+{
+ int a = 1;
+ while ((a = !a))
+ ;
+}
+
+/*
+ * check-name: infinite loop 02
+ * check-command: sparse -Wno-decl $file
+ */
diff --git a/validation/infinite-loop03.c b/validation/infinite-loop03.c
new file mode 100644
index 000000000..ac8a9519d
--- /dev/null
+++ b/validation/infinite-loop03.c
@@ -0,0 +1,16 @@
+static void foo(int *buf)
+{
+ int a = 1;
+ int *b;
+ do {
+ if (a)
+ b = buf;
+ if (a)
+ *buf = 0;
+ } while (!(a = !a));
+}
+
+/*
+ * check-name: infinite loop 03
+ * check-command: sparse -Wno-decl $file
+ */
--
2.13.2
next prev parent reply other threads:[~2017-07-31 20:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-31 20:36 [PATCH v3 0/7] fixes for rare issues Luc Van Oostenryck
2017-07-31 20:36 ` [PATCH v3 1/7] fix ptrlist corruption while killing unreachable BBs Luc Van Oostenryck
2017-07-31 21:41 ` Christopher Li
2017-07-31 22:10 ` Luc Van Oostenryck
2017-07-31 20:36 ` Luc Van Oostenryck [this message]
2017-07-31 20:36 ` [PATCH v3 3/7] fix BB dependencies on phi-nodes Luc Van Oostenryck
2017-07-31 20:36 ` [PATCH v3 4/7] fix crash when ep->active is NULL Luc Van Oostenryck
2017-07-31 20:36 ` [PATCH v3 5/7] fix crash in rewrite_branch() Luc Van Oostenryck
2017-07-31 20:36 ` [PATCH v3 6/7] fix some crashes in add_dominators() Luc Van Oostenryck
2017-07-31 20:36 ` [PATCH v3 7/7] fix crash with sym->bb_target == NULL Luc Van Oostenryck
2017-07-31 21:01 ` [PATCH v3 0/7] fixes for rare issues Christopher Li
2017-07-31 21:54 ` Luc Van Oostenryck
2017-07-31 22:34 ` Luc Van Oostenryck
2017-07-31 22:42 ` Luc Van Oostenryck
2017-08-01 20:46 ` Luc Van Oostenryck
2017-08-01 21:49 ` Christopher Li
2017-08-01 22:10 ` Luc Van Oostenryck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170731203624.58971-3-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=mstefani@mykolab.com \
--cc=sparse@chrisli.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).