From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 1/5] add testcases for OP_UNREACH
Date: Wed, 18 Mar 2020 18:31:16 +0100 [thread overview]
Message-ID: <20200318173120.63939-2-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200318173120.63939-1-luc.vanoostenryck@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
validation/context-unreachable.c | 16 ++++++++++
validation/linear/builtin_unreachable0.c | 30 +++++++++++++++++++
...n_unreachable.c => builtin_unreachable1.c} | 14 ++++-----
validation/linear/noreturn-unreachable0.c | 23 ++++++++++++++
4 files changed, 76 insertions(+), 7 deletions(-)
create mode 100644 validation/context-unreachable.c
create mode 100644 validation/linear/builtin_unreachable0.c
rename validation/linear/{builtin_unreachable.c => builtin_unreachable1.c} (65%)
create mode 100644 validation/linear/noreturn-unreachable0.c
diff --git a/validation/context-unreachable.c b/validation/context-unreachable.c
new file mode 100644
index 000000000000..3e330403ce01
--- /dev/null
+++ b/validation/context-unreachable.c
@@ -0,0 +1,16 @@
+int fun(void);
+
+static void foo(void)
+{
+ __context__(1);
+ if (!fun()) {
+ __builtin_unreachable();
+ return;
+ }
+ __context__(-1);
+}
+
+/*
+ * check-name: context-unreachable
+ * check-known-to-fail
+ */
diff --git a/validation/linear/builtin_unreachable0.c b/validation/linear/builtin_unreachable0.c
new file mode 100644
index 000000000000..5da9d074ae5f
--- /dev/null
+++ b/validation/linear/builtin_unreachable0.c
@@ -0,0 +1,30 @@
+extern void die(void) __attribute__((noreturn));
+
+int foo(int p)
+{
+ if (p == 3)
+ __builtin_unreachable();
+ return p;
+}
+
+/*
+ * check-name: builtin_unreachable0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-start
+foo:
+.L0:
+ <entry-point>
+ seteq.32 %r2 <- %arg1, $3
+ cbr %r2, .L1, .L3
+
+.L1:
+ unreach
+
+.L3:
+ ret.32 %arg1
+
+
+ * check-output-end
+ */
diff --git a/validation/linear/builtin_unreachable.c b/validation/linear/builtin_unreachable1.c
similarity index 65%
rename from validation/linear/builtin_unreachable.c
rename to validation/linear/builtin_unreachable1.c
index 4f13b892af54..280f853d8a07 100644
--- a/validation/linear/builtin_unreachable.c
+++ b/validation/linear/builtin_unreachable1.c
@@ -1,15 +1,15 @@
-void function_that_never_returns(void);
+extern void die(void);
int foo(int c)
{
if (c)
return 1;
- function_that_never_returns();
+ die();
__builtin_unreachable();
}
/*
- * check-name: __builtin_unreachable()
+ * check-name: builtin_unreachable1
* check-command: test-linearize -Wno-decl $file
*
* check-known-to-fail
@@ -19,13 +19,13 @@ foo:
<entry-point>
cbr %arg1, .L3, .L2
-.L2:
- call function_that_never_returns
- unreach
-
.L3:
ret.32 $1
+.L2:
+ call die
+ unreach
+
* check-output-end
*/
diff --git a/validation/linear/noreturn-unreachable0.c b/validation/linear/noreturn-unreachable0.c
new file mode 100644
index 000000000000..b76319458e96
--- /dev/null
+++ b/validation/linear/noreturn-unreachable0.c
@@ -0,0 +1,23 @@
+extern void die(void) __attribute__((noreturn));
+
+int foo(void)
+{
+ die();
+ return 0;
+}
+
+/*
+ * check-name: noreturn-unreachable0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-start
+foo:
+.L0:
+ <entry-point>
+ call die
+ unreach
+
+
+ * check-output-end
+ */
--
2.25.1
next prev parent reply other threads:[~2020-03-18 17:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-18 17:31 [PATCH 0/5] add support for __builtin_unreachable() Luc Van Oostenryck
2020-03-18 17:31 ` Luc Van Oostenryck [this message]
2020-03-19 22:24 ` [PATCH 1/5] add testcases for OP_UNREACH Ramsay Jones
2020-03-19 23:54 ` Luc Van Oostenryck
2020-03-18 17:31 ` [PATCH 2/5] add instruction OP_UNREACH Luc Van Oostenryck
2020-03-18 17:31 ` [PATCH 3/5] add an implicit __builtin_unreachable() for __noreturn Luc Van Oostenryck
2020-03-18 17:31 ` [PATCH 4/5] add support for linearization of builtins Luc Van Oostenryck
2020-03-18 17:31 ` [PATCH 5/5] teach sparse to linearize __builtin_unreachable() 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=20200318173120.63939-2-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.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).