public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
[not found] <bug-41201-4@http.gcc.gnu.org/bugzilla/>
@ 2010-12-08 14:11 ` davek at gcc dot gnu.org
2010-12-08 14:20 ` davek at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: davek at gcc dot gnu.org @ 2010-12-08 14:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
Dave Korn <davek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2010.12.08 14:10:43
CC| |davek at gcc dot gnu.org
AssignedTo|unassigned at gcc dot |davek at gcc dot gnu.org
|gnu.org |
Ever Confirmed|0 |1
--- Comment #6 from Dave Korn <davek at gcc dot gnu.org> 2010-12-08 14:10:43 UTC ---
I stumbled into the underlying cause of this bug while working on
dllimport/dllexport attributes. It turns out that the TARGET_INSERT_ATTRIBUTES
hook is broken in C++, because of a bit of premature optimisation in the
routine gcc/cp/decl2.c#cplus_decl_attributes(). This is a C++-specific wrapper
round the core compiler's gcc/attribs.c#decl_attributes() which takes care of
deferred attribute handling for templates:
/* Like decl_attributes, but handle C++ complexity. */
void
cplus_decl_attributes (tree *decl, tree attributes, int flags)
{
if (*decl == NULL_TREE || *decl == void_type_node
|| *decl == error_mark_node
|| attributes == NULL_TREE)
return;
if (processing_template_decl)
{
if (check_for_bare_parameter_packs (attributes))
return;
save_template_attributes (&attributes, decl);
if (attributes == NULL_TREE)
return;
}
if (TREE_CODE (*decl) == TEMPLATE_DECL)
decl = &DECL_TEMPLATE_RESULT (*decl);
decl_attributes (decl, attributes, flags);
if (TREE_CODE (*decl) == TYPE_DECL)
SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (*decl), TREE_TYPE (*decl));
}
The early exits when attributes == NULL_TREE are (I suppose) intended to save
the time taken calling decl_attributes when there aren't any attributes to be
added to the newly-created decl, but it has the side-effect of bypassing the
call that decl_attributes makes to TARGET_INSERT_ATTRIBUTES. The consequence
is that the default/target/pragma-derived attributes don't get inserted onto
any decls in C++ - except for decls that have some explicit attributes
specified!
I'm going to be testing this fix as part of a larger patch over the next
couple of days, perhaps others would like to give it a try on their platforms:
Index: gcc/cp/decl2.c
===================================================================
--- gcc/cp/decl2.c (revision 167484)
+++ gcc/cp/decl2.c (working copy)
@@ -1269,8 +1269,7 @@ void
cplus_decl_attributes (tree *decl, tree attributes, int flags)
{
if (*decl == NULL_TREE || *decl == void_type_node
- || *decl == error_mark_node
- || attributes == NULL_TREE)
+ || *decl == error_mark_node)
return;
if (processing_template_decl)
@@ -1279,13 +1278,13 @@ cplus_decl_attributes (tree *decl, tree attributes
return;
save_template_attributes (&attributes, decl);
- if (attributes == NULL_TREE)
- return;
}
if (TREE_CODE (*decl) == TEMPLATE_DECL)
decl = &DECL_TEMPLATE_RESULT (*decl);
+ /* Even if ATTRIBUTES is null, we must call this in order to
+ give the TARGET_INSERT_ATTRIBUTES hook a chance to run. */
decl_attributes (decl, attributes, flags);
if (TREE_CODE (*decl) == TYPE_DECL)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
[not found] <bug-41201-4@http.gcc.gnu.org/bugzilla/>
2010-12-08 14:11 ` [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C) davek at gcc dot gnu.org
@ 2010-12-08 14:20 ` davek at gcc dot gnu.org
2011-01-10 15:46 ` davek at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: davek at gcc dot gnu.org @ 2010-12-08 14:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
--- Comment #7 from Dave Korn <davek at gcc dot gnu.org> 2010-12-08 14:19:40 UTC ---
(In reply to comment #6)
> I stumbled into the underlying cause of this bug
Should clarify: I'm referring to the broken-ness referred to in comments 1 and
4. My patch probably won't make any difference to the original testcase,
because it's to do with declarations, not preprocessor macros.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
[not found] <bug-41201-4@http.gcc.gnu.org/bugzilla/>
2010-12-08 14:11 ` [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C) davek at gcc dot gnu.org
2010-12-08 14:20 ` davek at gcc dot gnu.org
@ 2011-01-10 15:46 ` davek at gcc dot gnu.org
2023-12-06 8:29 ` gb.devel at gmail dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: davek at gcc dot gnu.org @ 2011-01-10 15:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
Dave Korn <davek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |NEW
AssignedTo|davek at gcc dot gnu.org |unassigned at gcc dot
| |gnu.org
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
[not found] <bug-41201-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2011-01-10 15:46 ` davek at gcc dot gnu.org
@ 2023-12-06 8:29 ` gb.devel at gmail dot com
2023-12-06 8:33 ` sjames at gcc dot gnu.org
2023-12-06 8:33 ` sjames at gcc dot gnu.org
5 siblings, 0 replies; 11+ messages in thread
From: gb.devel at gmail dot com @ 2023-12-06 8:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
Gwenole Beauchesne <gb.devel at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gb.devel at gmail dot com
--- Comment #8 from Gwenole Beauchesne <gb.devel at gmail dot com> ---
Hi, this is a duplicate of PR preprocessor/87299, which is now fixed for GCC
14.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
[not found] <bug-41201-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2023-12-06 8:29 ` gb.devel at gmail dot com
@ 2023-12-06 8:33 ` sjames at gcc dot gnu.org
2023-12-06 8:33 ` sjames at gcc dot gnu.org
5 siblings, 0 replies; 11+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-12-06 8:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |87299
Target Milestone|--- |14.0
CC| |lhyatt at gcc dot gnu.org
See Also|https://gcc.gnu.org/bugzill |
|a/show_bug.cgi?id=87299 |
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299
[Bug 87299] #pragma GCC target behaves differently when using -save-temps
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
[not found] <bug-41201-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2023-12-06 8:33 ` sjames at gcc dot gnu.org
@ 2023-12-06 8:33 ` sjames at gcc dot gnu.org
5 siblings, 0 replies; 11+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-12-06 8:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #9 from Sam James <sjames at gcc dot gnu.org> ---
Fixed for 14. Thanks!
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
2009-08-31 20:19 [Bug c++/41201] New: " dbaron at dbaron dot org
` (3 preceding siblings ...)
2010-07-12 22:43 ` hjl dot tools at gmail dot com
@ 2010-07-26 16:21 ` justin dot lebar+bug at gmail dot com
4 siblings, 0 replies; 11+ messages in thread
From: justin dot lebar+bug at gmail dot com @ 2010-07-26 16:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from justin dot lebar+bug at gmail dot com 2010-07-26 16:20 -------
FWIW, it seems that MSVC is perfectly happy to compile code with intrinsics
inside a file which doesn't have any special flags. It would be awesome if
there were some way to do the same with GCC, even if it involves #pragma
hackery. The current limitation makes using intrinsics pretty painful, as it
requires a separate file for each targeted instruction set.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
2009-08-31 20:19 [Bug c++/41201] New: " dbaron at dbaron dot org
` (2 preceding siblings ...)
2010-07-12 22:22 ` justin dot lebar+bug at gmail dot com
@ 2010-07-12 22:43 ` hjl dot tools at gmail dot com
2010-07-26 16:21 ` justin dot lebar+bug at gmail dot com
4 siblings, 0 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-07-12 22:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from hjl dot tools at gmail dot com 2010-07-12 22:43 -------
I think the whole "pragma GCC target" is incomplete/broken.
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|hjl at gcc dot gnu dot org |hjl dot tools at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
2009-08-31 20:19 [Bug c++/41201] New: " dbaron at dbaron dot org
2010-04-27 22:44 ` [Bug c++/41201] " siarhei dot siamashka at gmail dot com
2010-07-12 22:09 ` justin dot lebar+bug at gmail dot com
@ 2010-07-12 22:22 ` justin dot lebar+bug at gmail dot com
2010-07-12 22:43 ` hjl dot tools at gmail dot com
2010-07-26 16:21 ` justin dot lebar+bug at gmail dot com
4 siblings, 0 replies; 11+ messages in thread
From: justin dot lebar+bug at gmail dot com @ 2010-07-12 22:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from justin dot lebar+bug at gmail dot com 2010-07-12 22:22 -------
Also cc'ing H.J. Lu, who wrote sse-23.c
--
justin dot lebar+bug at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hjl at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
2009-08-31 20:19 [Bug c++/41201] New: " dbaron at dbaron dot org
2010-04-27 22:44 ` [Bug c++/41201] " siarhei dot siamashka at gmail dot com
@ 2010-07-12 22:09 ` justin dot lebar+bug at gmail dot com
2010-07-12 22:22 ` justin dot lebar+bug at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: justin dot lebar+bug at gmail dot com @ 2010-07-12 22:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from justin dot lebar+bug at gmail dot com 2010-07-12 22:09 -------
cc'ing Harsha Jagasia, who wrote sse-22.c and funcspec-9.
I might be willing to put together a patch for this, but I'm totally unfamiliar
with the codebase, so I'd almost surely need some help.
--
justin dot lebar+bug at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harsha dot jagasia at amd
| |dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C)
2009-08-31 20:19 [Bug c++/41201] New: " dbaron at dbaron dot org
@ 2010-04-27 22:44 ` siarhei dot siamashka at gmail dot com
2010-07-12 22:09 ` justin dot lebar+bug at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: siarhei dot siamashka at gmail dot com @ 2010-04-27 22:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from siarhei dot siamashka at gmail dot com 2010-04-27 22:44 -------
"#pragma GCC <target|optimize>" just does not seem to work with C++. Just
stumbled on it trying to narrow down something that looks like wrong-code
generation bug in gcc 4.5.0 when compiling qt4.
Prepending "__attribute__((optimize("-O0")))" to each function still works, so
no real need to go through the trouble of splitting source files into parts to
bisect the issue.
--
siarhei dot siamashka at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |siarhei dot siamashka at
| |gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-12-06 8:33 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-41201-4@http.gcc.gnu.org/bugzilla/>
2010-12-08 14:11 ` [Bug c++/41201] #pragma GCC target ("sse2") doesn't alter __SSE2__ in C++ (as it does in C) davek at gcc dot gnu.org
2010-12-08 14:20 ` davek at gcc dot gnu.org
2011-01-10 15:46 ` davek at gcc dot gnu.org
2023-12-06 8:29 ` gb.devel at gmail dot com
2023-12-06 8:33 ` sjames at gcc dot gnu.org
2023-12-06 8:33 ` sjames at gcc dot gnu.org
2009-08-31 20:19 [Bug c++/41201] New: " dbaron at dbaron dot org
2010-04-27 22:44 ` [Bug c++/41201] " siarhei dot siamashka at gmail dot com
2010-07-12 22:09 ` justin dot lebar+bug at gmail dot com
2010-07-12 22:22 ` justin dot lebar+bug at gmail dot com
2010-07-12 22:43 ` hjl dot tools at gmail dot com
2010-07-26 16:21 ` justin dot lebar+bug at gmail dot com
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).