Skip to contentSkip to conversation

ignore __cold__ attribute

PATCH In review Johannes Berg 3 participants 6 messages Apr 22, 2008 – Jun 19, 2008 1 message not in the archive Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ignore __cold__ attribute

This is a new attribute in gcc 4.3, which when used and sparse is compiled with gcc 4.3 leads to unknown attribute errors. Ignore it.

---

parse.c +1 -0
index 83e2d67..cdcd742 100644
@@ -355,6 +355,7 @@ static struct init_keyword {
 	{ "__constructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "destructor",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__destructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "__cold__",	NS_KEYWORD,	.op = &ignore_attr_op },
 };
 
 void init_parser(int stream)
#2 lore raw
In reply to a message not in the archive
Quoted 5 lines · Pavel Roskin

Quoting Johannes Berg <[email protected]>:

Quoted 2 lines

This is a new attribute in gcc 4.3, which when used and sparse is compiled with gcc 4.3 leads to unknown attribute errors. Ignore it.

Quoted 8 lines

According to
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html, the new attributes are "cold" and "hot". I think we need them ignored both with and without underscores.

The attributes indicate whether the function is likely to be executed, and thus affect optimization. There is nothing useful for sparse in that information.

*Shrug*. I just wanted the kernel to work again and failed (in about 20 minutes of searching) to find a changelog for gcc mentioning this so gave up and just added the one that the kernel uses. Want to amend the patch?

johannes

#3 lore raw
Quoted 4 lines · Johannes Berg

*Shrug*. I just wanted the kernel to work again and failed (in about 20 minutes of searching) to find a changelog for gcc mentioning this so gave up and just added the one that the kernel uses. Want to amend the patch?

I think this would be better. Now sparse would ignore both "cold" and "hot", both with and without underscores. They are also added to ident-list.h.

ident-list.h +2 -0
index 8fcd7de..6104826 100644
@@ -74,6 +74,8 @@ IDENT(__malloc__);
 IDENT(nonnull); IDENT(__nonnull); IDENT(__nonnull__);
 IDENT(constructor); IDENT(__constructor__);
 IDENT(destructor); IDENT(__destructor__);
+IDENT(cold); IDENT(__cold__);
+IDENT(hot); IDENT(__hot__);
 IDENT(cdecl); IDENT(__cdecl__);
 IDENT(stdcall); IDENT(__stdcall__);
 IDENT(fastcall); IDENT(__fastcall__);
parse.c +4 -0
index 137ba77..877414c 100644
@@ -353,6 +353,10 @@ static struct init_keyword {
 	{ "__constructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "destructor",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__destructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "cold",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "__cold__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "hot",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "__hot__",	NS_KEYWORD,	.op = &ignore_attr_op },
 };
 
 void init_parser(int stream)
Signature · 2 lines
Regards,
Pavel Roskin
#4 lore raw
Quoted 28 lines · Pavel Roskin
Quoted 4 lines · Johannes Berg

*Shrug*. I just wanted the kernel to work again and failed (in about 20 minutes of searching) to find a changelog for gcc mentioning this so gave up and just added the one that the kernel uses. Want to amend the patch?

I think this would be better. Now sparse would ignore both "cold" and "hot", both with and without underscores. They are also added to ident-list.h.

ident-list.h +2 -0
index 8fcd7de..6104826 100644
@@ -74,6 +74,8 @@ IDENT(__malloc__);
 IDENT(nonnull); IDENT(__nonnull); IDENT(__nonnull__);
 IDENT(constructor); IDENT(__constructor__);
 IDENT(destructor); IDENT(__destructor__);
+IDENT(cold); IDENT(__cold__);
+IDENT(hot); IDENT(__hot__);
 IDENT(cdecl); IDENT(__cdecl__);
 IDENT(stdcall); IDENT(__stdcall__);
 IDENT(fastcall); IDENT(__fastcall__);
parse.c +0 -0
index 137ba77..877414c 100644

parse.c static struct init_keyword { · line 360

Quoted 8 lines
parse.c +4 -0
@@ -353,6 +353,10 @@ static struct init_keyword {
 	{ "__constructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "destructor",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__destructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "cold",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "__cold__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "hot",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "__hot__",	NS_KEYWORD,	.op = &ignore_attr_op },
 };

Looks good to me. Could I get a signoff and commit message please?

- Josh Triplett

#5 lore raw
Quoted 1 line · Josh Triplett

Looks good to me. Could I get a signoff and commit message please?

I posted it already, but I think it was lost, so here it is again.

Ignore "cold" and "hot" attributes, which appeared in gcc 4.3

They describe how likely the function is to be executed, which can affect optimization. Also ignore the attributes with underscores.

---

 ident-list.h |    2 ++
 parse.c      |    4 ++++
 2 files changed, 6 insertions(+), 0 deletions(-)
ident-list.h +2 -0
index 8fcd7de..6104826 100644
@@ -74,6 +74,8 @@ IDENT(__malloc__);
 IDENT(nonnull); IDENT(__nonnull); IDENT(__nonnull__);
 IDENT(constructor); IDENT(__constructor__);
 IDENT(destructor); IDENT(__destructor__);
+IDENT(cold); IDENT(__cold__);
+IDENT(hot); IDENT(__hot__);
 IDENT(cdecl); IDENT(__cdecl__);
 IDENT(stdcall); IDENT(__stdcall__);
 IDENT(fastcall); IDENT(__fastcall__);
parse.c +4 -0
index 137ba77..877414c 100644
@@ -353,6 +353,10 @@ static struct init_keyword {
 	{ "__constructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "destructor",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__destructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "cold",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "__cold__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "hot",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "__hot__",	NS_KEYWORD,	.op = &ignore_attr_op },
 };
 
 void init_parser(int stream)
Signature · 2 lines
Regards,
Pavel Roskin
#6 lore raw
In reply to Josh Triplett
Quoted 31 lines · Josh Triplett
Quoted 30 lines · Pavel Roskin
Quoted 4 lines · Johannes Berg

*Shrug*. I just wanted the kernel to work again and failed (in about 20 minutes of searching) to find a changelog for gcc mentioning this so gave up and just added the one that the kernel uses. Want to amend the patch?

I think this would be better. Now sparse would ignore both "cold" and "hot", both with and without underscores. They are also added to ident-list.h.

ident-list.h +2 -0
index 8fcd7de..6104826 100644
@@ -74,6 +74,8 @@ IDENT(__malloc__);
 IDENT(nonnull); IDENT(__nonnull); IDENT(__nonnull__);
 IDENT(constructor); IDENT(__constructor__);
 IDENT(destructor); IDENT(__destructor__);
+IDENT(cold); IDENT(__cold__);
+IDENT(hot); IDENT(__hot__);
 IDENT(cdecl); IDENT(__cdecl__);
 IDENT(stdcall); IDENT(__stdcall__);
 IDENT(fastcall); IDENT(__fastcall__);
parse.c +0 -0
index 137ba77..877414c 100644
@@ -353,6 +353,10 @@ static struct init_keyword {
 	{ "__constructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "destructor",	NS_KEYWORD,	.op = &ignore_attr_op },
Quoted 8 lines

parse.c static struct init_keyword { · line 360

Quoted 6 lines
parse.c +4 -0
 	{ "__destructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "cold",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "__cold__",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "hot",	NS_KEYWORD,	.op = &ignore_attr_op },
+	{ "__hot__",	NS_KEYWORD,	.op = &ignore_attr_op },
 };

Looks good to me. Could I get a signoff and commit message please?

Sorry for delay. I thought I answered it already.

Signature · 2 lines
Regards,
Pavel Roskin