From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 3/5] add an implicit __builtin_unreachable() for __noreturn
Date: Wed, 18 Mar 2020 18:31:18 +0100 [thread overview]
Message-ID: <20200318173120.63939-4-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200318173120.63939-1-luc.vanoostenryck@gmail.com>
The semantic of a __noreturn function is that ... it doesn't return.
So, insert an instruction OP_UNREACH after calls to such functions.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
linearize.c | 10 ++++++++++
validation/linear/noreturn-unreachable0.c | 1 -
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/linearize.c b/linearize.c
index f1e538e23ae1..19c284c4a456 100644
--- a/linearize.c
+++ b/linearize.c
@@ -657,6 +657,13 @@ static void add_one_insn(struct entrypoint *ep, struct instruction *insn)
}
}
+static void add_unreachable(struct entrypoint *ep)
+{
+ struct instruction *insn = alloc_instruction(OP_UNREACH, 0);
+ add_one_insn(ep, insn);
+ ep->active = NULL;
+}
+
static void set_activeblock(struct entrypoint *ep, struct basic_block *bb)
{
if (!bb_terminated(ep->active))
@@ -1551,6 +1558,9 @@ static pseudo_t linearize_call_expression(struct entrypoint *ep, struct expressi
add_one_insn(ep, insn);
}
} END_FOR_EACH_PTR(context);
+
+ if (ctype->modifiers & MOD_NORETURN)
+ add_unreachable(ep);
}
return retval;
diff --git a/validation/linear/noreturn-unreachable0.c b/validation/linear/noreturn-unreachable0.c
index b76319458e96..13fddc8cfd40 100644
--- a/validation/linear/noreturn-unreachable0.c
+++ b/validation/linear/noreturn-unreachable0.c
@@ -9,7 +9,6 @@ int foo(void)
/*
* check-name: noreturn-unreachable0
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-start
foo:
--
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 ` [PATCH 1/5] add testcases for OP_UNREACH Luc Van Oostenryck
2020-03-19 22:24 ` 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 ` Luc Van Oostenryck [this message]
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-4-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).