linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kamil Dudka <kdudka@redhat.com>
To: linux-sparse@vger.kernel.org
Subject: [PATCH] do not ignore attribute 'noreturn'...
Date: Fri, 28 Aug 2009 23:30:08 +0200	[thread overview]
Message-ID: <200908282330.08332.kdudka@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

Hello,

enclosed is a simple patch adding support for attribute 'noreturn' to the 
parser. The enhancement makes it possible to optimize walk through CFG and 
thus help us to fight with the state explosion. The benefit is demonstrated 
on a simple real-world example.

Generated CFG before patch:
http://dudka.cz/devel/html/slsparse-before/slplug.c-handle_stmt_assign.svg

Generated CFG after patch:
http://dudka.cz/devel/html/slsparse-after/slplug.c-handle_stmt_assign.svg

It's one of the key features I am currently missing in SPARSE in contrast
to gcc used as parser. Thanks in advance for considering it!

Kamil

[-- Attachment #2: 0001-do-not-ignore-attribute-noreturn.patch --]
[-- Type: text/x-diff, Size: 2134 bytes --]

From 892f19915cbcbe26b3a7ad2c3baf1a1420f3c954 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Fri, 28 Aug 2009 21:49:16 +0200
Subject: [PATCH] do not ignore attribute 'noreturn'...

... and thus make it possible to optimize walk through CFG.

Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 parse.c  |    4 ++--
 symbol.h |    4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/parse.c b/parse.c
index e5ad867..215c4da 100644
--- a/parse.c
+++ b/parse.c
@@ -480,8 +480,8 @@ static struct init_keyword {
 	{ "const",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__const",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__const__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "noreturn",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__noreturn__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "noreturn",	NS_KEYWORD,	MOD_NORETURN,	.op = &attr_mod_op },
+	{ "__noreturn__",	NS_KEYWORD,	MOD_NORETURN,	.op = &attr_mod_op },
 	{ "no_instrument_function",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__no_instrument_function__",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "sentinel",	NS_KEYWORD,	.op = &ignore_attr_op },
diff --git a/symbol.h b/symbol.h
index 42d69d6..d8d1793 100644
--- a/symbol.h
+++ b/symbol.h
@@ -216,6 +216,8 @@ struct symbol {
 #define MOD_EXPLICITLY_SIGNED	0x40000000
 #define MOD_BITWISE	0x80000000
 
+#define MOD_NORETURN	0x100000000
+
 #define MOD_NONLOCAL	(MOD_EXTERN | MOD_TOPLEVEL)
 #define MOD_STORAGE	(MOD_AUTO | MOD_REGISTER | MOD_STATIC | MOD_EXTERN | MOD_INLINE | MOD_TOPLEVEL)
 #define MOD_SIGNEDNESS	(MOD_SIGNED | MOD_UNSIGNED | MOD_EXPLICITLY_SIGNED)
@@ -223,7 +225,7 @@ struct symbol {
 #define MOD_SIZE	(MOD_CHAR | MOD_SHORT | MOD_LONG | MOD_LONGLONG)
 #define MOD_IGNORE (MOD_TOPLEVEL | MOD_STORAGE | MOD_ADDRESSABLE |	\
 	MOD_ASSIGNED | MOD_USERTYPE | MOD_ACCESSED | MOD_EXPLICITLY_SIGNED)
-#define MOD_PTRINHERIT (MOD_VOLATILE | MOD_CONST | MOD_NODEREF | MOD_STORAGE)
+#define MOD_PTRINHERIT (MOD_VOLATILE | MOD_CONST | MOD_NODEREF | MOD_STORAGE | MOD_NORETURN)
 
 
 /* Current parsing/evaluation function */
-- 
1.6.4.1


             reply	other threads:[~2009-08-28 21:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-28 21:30 Kamil Dudka [this message]
2009-08-28 21:44 ` [PATCH] do not ignore attribute 'noreturn' Christopher Li
2009-09-14 17:27   ` Christopher Li
2009-09-14 17:32     ` Kamil Dudka
2009-09-14 17:55       ` Christopher Li
2009-09-14 19:44         ` Kamil Dudka
2009-09-14 20:47           ` Christopher Li
2009-09-14 21:13             ` Kamil Dudka

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=200908282330.08332.kdudka@redhat.com \
    --to=kdudka@redhat.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).