* [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration
@ 2014-01-08 9:05 Laurent Alfonsi
2014-01-09 5:02 ` Jeff Law
0 siblings, 1 reply; 6+ messages in thread
From: Laurent Alfonsi @ 2014-01-08 9:05 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 684 bytes --]
All,
I was looking at PR49718. I have enclosed a simple fix for this bug report.
2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
* c-family/c-common.c (handle_no_instrument_function_attribute): Allow
no_instrument_function attribute in class member
definition/declaration.
Looking at the implementation of the function attributes, I see no
reason anymore to keep this error message.
Let me know if I missed something.
I have also added a testcase in the enclosed patch.
2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
PR c++/49718
* g++.dg/pr49718.C: New
gcc/g++/libstdc++ testsuites are ok on x86-64. Ok for trunk ?
Regards,
Laurent
[-- Attachment #2: Fix-PR49718-allow-no_instrument_function-attribute-i.patch --]
[-- Type: text/x-patch, Size: 2524 bytes --]
From 141d2bcfeab5e0635c7f4e362387fd5b1b9494e6 Mon Sep 17 00:00:00 2001
From: Laurent ALFONSI <laurent.alfonsi@st.com>
Date: Tue, 7 Jan 2014 16:26:04 +0100
Subject: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class
member definition/declaration
---
gcc/c-family/c-common.c | 6 ------
gcc/testsuite/g++.dg/pr49718.C | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/pr49718.C
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 8ecb70c..17fcb0d 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -7929,12 +7929,6 @@ handle_no_instrument_function_attribute (tree *node, tree name,
"%qE attribute applies only to functions", name);
*no_add_attrs = true;
}
- else if (DECL_INITIAL (decl))
- {
- error_at (DECL_SOURCE_LOCATION (decl),
- "can%'t set %qE attribute after definition", name);
- *no_add_attrs = true;
- }
else
DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1;
diff --git a/gcc/testsuite/g++.dg/pr49718.C b/gcc/testsuite/g++.dg/pr49718.C
new file mode 100644
index 0000000..07cac8c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr49718.C
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -finstrument-functions" } */
+/* { dg-final { scan-assembler-times "__cyg_profile_func_enter" 1} } */
+
+#define NOINSTR __attribute__((no_instrument_function))
+
+struct t
+{
+ public:
+ /* Function code should be instrumented */
+ __attribute__((noinline)) t() {}
+
+ /* Function t::a() should not be instrumented */
+ NOINSTR void a(){
+ }
+ /* Function t::b() should not be instrumented */
+ void NOINSTR b(){
+ }
+ /* Function t::c() should not be instrumented */
+ void c() NOINSTR {
+ }
+ /* Function t::d() should not be instrumented */
+ void d() NOINSTR;
+};
+
+void t::d()
+{
+}
+
+/* Function call_all_functions() should not be instrumented */
+struct t call_all_functions() __attribute__((no_instrument_function));
+struct t call_all_functions()
+{
+ struct t a; /* Constructor not inlined */
+ a.a(); /* Inlined t::a() should not be instrumented */
+ a.b(); /* Inlined t::b() should not be instrumented */
+ a.c(); /* Inlined t::c() should not be instrumented */
+ a.d(); /* Inlined t::d() should not be instrumented */
+ return a;
+}
+
--
1.8.4.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration
2014-01-08 9:05 [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration Laurent Alfonsi
@ 2014-01-09 5:02 ` Jeff Law
2014-01-09 14:18 ` Laurent Alfonsi
0 siblings, 1 reply; 6+ messages in thread
From: Jeff Law @ 2014-01-09 5:02 UTC (permalink / raw)
To: Laurent Alfonsi, gcc-patches
On 01/08/14 02:05, Laurent Alfonsi wrote:
> All,
>
> I was looking at PR49718. I have enclosed a simple fix for this bug report.
>
> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>
> * c-family/c-common.c (handle_no_instrument_function_attribute): Allow
> no_instrument_function attribute in class member
> definition/declaration.
>
>
> Looking at the implementation of the function attributes, I see no
> reason anymore to keep this error message.
> Let me know if I missed something.
> I have also added a testcase in the enclosed patch.
>
> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>
> PR c++/49718
> * g++.dg/pr49718.C: New
Isn't the idea here that if we've already generated the function body
(presumably with instrumentation) that a no-instrument attribute
appearing on a later declaration won't do anything useful?
jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration
2014-01-09 5:02 ` Jeff Law
@ 2014-01-09 14:18 ` Laurent Alfonsi
2014-01-15 8:51 ` Laurent Alfonsi
2014-01-15 19:25 ` Jeff Law
0 siblings, 2 replies; 6+ messages in thread
From: Laurent Alfonsi @ 2014-01-09 14:18 UTC (permalink / raw)
To: Jeff Law, gcc-patches
On 01/09/14 06:02, Jeff Law wrote:
> On 01/08/14 02:05, Laurent Alfonsi wrote:
>> All,
>>
>> I was looking at PR49718. I have enclosed a simple fix for this bug report.
>>
>> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>>
>> * c-family/c-common.c (handle_no_instrument_function_attribute): Allow
>> no_instrument_function attribute in class member
>> definition/declaration.
>>
>>
>> Looking at the implementation of the function attributes, I see no
>> reason anymore to keep this error message.
>> Let me know if I missed something.
>> I have also added a testcase in the enclosed patch.
>>
>> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>>
>> PR c++/49718
>> * g++.dg/pr49718.C: New
> Isn't the idea here that if we've already generated the function body
> (presumably with instrumentation) that a no-instrument attribute
> appearing on a later declaration won't do anything useful?
>
> jeff
>
>
Jeff,
You are right. That's probably the reason.
From what i can see, the code instrumentation is performed in the
gimplification pass (gimplify_function_tree), and the function attribute
is handled and attached earlier in the parsing phase.
I ve checked with an example like :
---8<------8<------8<------8<------8<---
int foo () {
return 2;
}
int bar () {
return 1;
}
int foo () __attribute__((no_instrument_function));
---8<------8<------8<------8<------8<---
The attribute is well honored on foo function.
I might need to add this test case too.
Let me know if fix is ok.
Thanks
Laurent
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration
2014-01-09 14:18 ` Laurent Alfonsi
@ 2014-01-15 8:51 ` Laurent Alfonsi
2014-01-15 19:25 ` Jeff Law
1 sibling, 0 replies; 6+ messages in thread
From: Laurent Alfonsi @ 2014-01-15 8:51 UTC (permalink / raw)
To: Jeff Law, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1703 bytes --]
Ping ? Ok for trunk ?
On 01/09/14 15:17, Laurent Alfonsi wrote:
> On 01/09/14 06:02, Jeff Law wrote:
>> On 01/08/14 02:05, Laurent Alfonsi wrote:
>>> All,
>>>
>>> I was looking at PR49718. I have enclosed a simple fix for this bug
>>> report.
>>>
>>> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>>>
>>> * c-family/c-common.c
>>> (handle_no_instrument_function_attribute): Allow
>>> no_instrument_function attribute in class member
>>> definition/declaration.
>>>
>>>
>>> Looking at the implementation of the function attributes, I see no
>>> reason anymore to keep this error message.
>>> Let me know if I missed something.
>>> I have also added a testcase in the enclosed patch.
>>>
>>> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>>>
>>> PR c++/49718
>>> * g++.dg/pr49718.C: New
>> Isn't the idea here that if we've already generated the function body
>> (presumably with instrumentation) that a no-instrument attribute
>> appearing on a later declaration won't do anything useful?
>>
>> jeff
>>
>>
> Jeff,
>
> You are right. That's probably the reason.
> From what i can see, the code instrumentation is performed in the
> gimplification pass (gimplify_function_tree), and the function
> attribute is handled and attached earlier in the parsing phase.
>
> I ve checked with an example like :
> ---8<------8<------8<------8<------8<---
> int foo () {
> return 2;
> }
>
> int bar () {
> return 1;
> }
>
> int foo () __attribute__((no_instrument_function));
> ---8<------8<------8<------8<------8<---
> The attribute is well honored on foo function.
> I might need to add this test case too.
>
> Let me know if fix is ok.
>
> Thanks
> Laurent
[-- Attachment #2: Fix-PR49718-allow-no_instrument_function-attribute-i.patch --]
[-- Type: text/plain, Size: 2524 bytes --]
From 141d2bcfeab5e0635c7f4e362387fd5b1b9494e6 Mon Sep 17 00:00:00 2001
From: Laurent ALFONSI <laurent.alfonsi@st.com>
Date: Tue, 7 Jan 2014 16:26:04 +0100
Subject: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class
member definition/declaration
---
gcc/c-family/c-common.c | 6 ------
gcc/testsuite/g++.dg/pr49718.C | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/pr49718.C
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 8ecb70c..17fcb0d 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -7929,12 +7929,6 @@ handle_no_instrument_function_attribute (tree *node, tree name,
"%qE attribute applies only to functions", name);
*no_add_attrs = true;
}
- else if (DECL_INITIAL (decl))
- {
- error_at (DECL_SOURCE_LOCATION (decl),
- "can%'t set %qE attribute after definition", name);
- *no_add_attrs = true;
- }
else
DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1;
diff --git a/gcc/testsuite/g++.dg/pr49718.C b/gcc/testsuite/g++.dg/pr49718.C
new file mode 100644
index 0000000..07cac8c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr49718.C
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -finstrument-functions" } */
+/* { dg-final { scan-assembler-times "__cyg_profile_func_enter" 1} } */
+
+#define NOINSTR __attribute__((no_instrument_function))
+
+struct t
+{
+ public:
+ /* Function code should be instrumented */
+ __attribute__((noinline)) t() {}
+
+ /* Function t::a() should not be instrumented */
+ NOINSTR void a(){
+ }
+ /* Function t::b() should not be instrumented */
+ void NOINSTR b(){
+ }
+ /* Function t::c() should not be instrumented */
+ void c() NOINSTR {
+ }
+ /* Function t::d() should not be instrumented */
+ void d() NOINSTR;
+};
+
+void t::d()
+{
+}
+
+/* Function call_all_functions() should not be instrumented */
+struct t call_all_functions() __attribute__((no_instrument_function));
+struct t call_all_functions()
+{
+ struct t a; /* Constructor not inlined */
+ a.a(); /* Inlined t::a() should not be instrumented */
+ a.b(); /* Inlined t::b() should not be instrumented */
+ a.c(); /* Inlined t::c() should not be instrumented */
+ a.d(); /* Inlined t::d() should not be instrumented */
+ return a;
+}
+
--
1.8.4.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration
2014-01-09 14:18 ` Laurent Alfonsi
2014-01-15 8:51 ` Laurent Alfonsi
@ 2014-01-15 19:25 ` Jeff Law
2014-01-16 8:41 ` Laurent Alfonsi
1 sibling, 1 reply; 6+ messages in thread
From: Jeff Law @ 2014-01-15 19:25 UTC (permalink / raw)
To: Laurent Alfonsi, gcc-patches
On 01/09/14 07:17, Laurent Alfonsi wrote:
> On 01/09/14 06:02, Jeff Law wrote:
>> On 01/08/14 02:05, Laurent Alfonsi wrote:
>>> All,
>>>
>>> I was looking at PR49718. I have enclosed a simple fix for this bug
>>> report.
>>>
>>> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>>>
>>> * c-family/c-common.c
>>> (handle_no_instrument_function_attribute): Allow
>>> no_instrument_function attribute in class member
>>> definition/declaration.
>>>
>>>
>>> Looking at the implementation of the function attributes, I see no
>>> reason anymore to keep this error message.
>>> Let me know if I missed something.
>>> I have also added a testcase in the enclosed patch.
>>>
>>> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>>>
>>> PR c++/49718
>>> * g++.dg/pr49718.C: New
>> Isn't the idea here that if we've already generated the function body
>> (presumably with instrumentation) that a no-instrument attribute
>> appearing on a later declaration won't do anything useful?
>>
>> jeff
>>
>>
> Jeff,
>
> You are right. That's probably the reason.
> From what i can see, the code instrumentation is performed in the
> gimplification pass (gimplify_function_tree), and the function attribute
> is handled and attached earlier in the parsing phase.
>
> I ve checked with an example like :
> ---8<------8<------8<------8<------8<---
> int foo () {
> return 2;
> }
>
> int bar () {
> return 1;
> }
>
> int foo () __attribute__((no_instrument_function));
> ---8<------8<------8<------8<------8<---
> The attribute is well honored on foo function.
> I might need to add this test case too.
Thanks. I checked with Jakub and he confirmed that all the flags to
disable unit-at-a-time mode are gone and there's no way to generate
gimple for a function prior to parsing the entire TU.
That means this patch should be OK. I don't see you in the MAINTAINERS
file or with an account on gcc.gnu.org, so I'll check it in for you shortly.
Thanks for your patience,
Jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration
2014-01-15 19:25 ` Jeff Law
@ 2014-01-16 8:41 ` Laurent Alfonsi
0 siblings, 0 replies; 6+ messages in thread
From: Laurent Alfonsi @ 2014-01-16 8:41 UTC (permalink / raw)
To: Jeff Law; +Cc: gcc-patches
Perfect. Thanks very much for the commit.
Regards,
Laurent
On 01/15/14 20:25, Jeff Law wrote:
> On 01/09/14 07:17, Laurent Alfonsi wrote:
>> On 01/09/14 06:02, Jeff Law wrote:
>>> On 01/08/14 02:05, Laurent Alfonsi wrote:
>>>> All,
>>>>
>>>> I was looking at PR49718. I have enclosed a simple fix for this bug
>>>> report.
>>>>
>>>> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>>>>
>>>> * c-family/c-common.c
>>>> (handle_no_instrument_function_attribute): Allow
>>>> no_instrument_function attribute in class member
>>>> definition/declaration.
>>>>
>>>>
>>>> Looking at the implementation of the function attributes, I see no
>>>> reason anymore to keep this error message.
>>>> Let me know if I missed something.
>>>> I have also added a testcase in the enclosed patch.
>>>>
>>>> 2014-01-07 Laurent Alfonsi <laurent.alfonsi@st.com>
>>>>
>>>> PR c++/49718
>>>> * g++.dg/pr49718.C: New
>>> Isn't the idea here that if we've already generated the function body
>>> (presumably with instrumentation) that a no-instrument attribute
>>> appearing on a later declaration won't do anything useful?
>>>
>>> jeff
>>>
>>>
>> Jeff,
>>
>> You are right. That's probably the reason.
>> From what i can see, the code instrumentation is performed in the
>> gimplification pass (gimplify_function_tree), and the function attribute
>> is handled and attached earlier in the parsing phase.
>>
>> I ve checked with an example like :
>> ---8<------8<------8<------8<------8<---
>> int foo () {
>> return 2;
>> }
>>
>> int bar () {
>> return 1;
>> }
>>
>> int foo () __attribute__((no_instrument_function));
>> ---8<------8<------8<------8<------8<---
>> The attribute is well honored on foo function.
>> I might need to add this test case too.
> Thanks. I checked with Jakub and he confirmed that all the flags to
> disable unit-at-a-time mode are gone and there's no way to generate
> gimple for a function prior to parsing the entire TU.
>
> That means this patch should be OK. I don't see you in the MAINTAINERS
> file or with an account on gcc.gnu.org, so I'll check it in for you shortly.
>
> Thanks for your patience,
>
> Jeff
>
> .
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-01-16 8:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-08 9:05 [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration Laurent Alfonsi
2014-01-09 5:02 ` Jeff Law
2014-01-09 14:18 ` Laurent Alfonsi
2014-01-15 8:51 ` Laurent Alfonsi
2014-01-15 19:25 ` Jeff Law
2014-01-16 8:41 ` Laurent Alfonsi
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 read-only IMAP folder(s) and NNTP newsgroup(s).