public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/57756] New: Function target attribute is retaining  state of previously seen function
@ 2013-06-29  1:58 tmsriram at google dot com
  2013-10-15 21:43 ` [Bug target/57756] " tmsriram at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: tmsriram at google dot com @ 2013-06-29  1:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57756

            Bug ID: 57756
           Summary: Function target attribute is retaining  state of
                    previously seen function
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tmsriram at google dot com

Simple repro:

foo.cc:
-------
__attribute__((always_inline,target("sse4.2")))
inline int callee ()
{
  return 0;
}

__attribute__((target("sse4.1")))
inline int caller ()
{
  return callee();
}

int main ()
{
  return caller();
}

$ g++ foo.cc

callee is inlined into caller.  This is incorrect, the callee's target ISA is
higher and GCC must complain.  Digging deeper, the x_ix86_isa_flags of both
caller and callee are the same.  The problem is in ix86_set_current_function in
i386.c where 

     else if (new_tree)
    {
      cl_target_option_restore (&global_options,
                    TREE_TARGET_OPTION (new_tree));
      target_reinit ();
    }

where the restore, restores the previous decl's target options to global.

It is not clear to me how to fix this.

Replace the target attributes in the above source with the equivalent #pragma
GCC push_options .... and the program will fail as expected.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-11-20 11:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-29  1:58 [Bug target/57756] New: Function target attribute is retaining state of previously seen function tmsriram at google dot com
2013-10-15 21:43 ` [Bug target/57756] " tmsriram at gcc dot gnu.org
2013-10-16 11:25 ` graham.stott at btinternet dot com
2013-10-16 16:54 ` pthaugen at gcc dot gnu.org
2013-10-16 23:06 ` meissner at gcc dot gnu.org
2013-11-14 13:19 ` ysrumyan at gmail dot com
2013-11-14 13:22 ` ysrumyan at gmail dot com
2013-11-15  9:11 ` ubizjak at gmail dot com
2013-11-15 14:23 ` ysrumyan at gmail dot com
2013-11-20 11:59 ` kyukhin at gcc dot gnu.org

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).