diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 7c41302c75b..1b4567e34ba 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -578,21 +578,29 @@ ix86_can_inline_p (tree caller, tree callee) && lookup_attribute ("always_inline", DECL_ATTRIBUTES (callee))); + /* NB: Skip ISA check for always_inline in system headers if caller + has target attribute. */ + bool skip_isa_check = (always_inline + && caller_tree != target_option_default_node + && DECL_IN_SYSTEM_HEADER (callee)); + cgraph_node *callee_node = cgraph_node::get (callee); /* Callee's isa options should be a subset of the caller's, i.e. a SSE4 function can inline a SSE2 function but a SSE2 function can't inline a SSE4 function. */ - if (((caller_opts->x_ix86_isa_flags & callee_opts->x_ix86_isa_flags) - != callee_opts->x_ix86_isa_flags) - || ((caller_opts->x_ix86_isa_flags2 & callee_opts->x_ix86_isa_flags2) - != callee_opts->x_ix86_isa_flags2)) + if (!skip_isa_check + && (((caller_opts->x_ix86_isa_flags & callee_opts->x_ix86_isa_flags) + != callee_opts->x_ix86_isa_flags) + || ((caller_opts->x_ix86_isa_flags2 & callee_opts->x_ix86_isa_flags2) + != callee_opts->x_ix86_isa_flags2))) ret = false; /* See if we have the same non-isa options. */ - else if ((!always_inline - && caller_opts->x_target_flags != callee_opts->x_target_flags) - || (caller_opts->x_target_flags & ~always_inline_safe_mask) - != (callee_opts->x_target_flags & ~always_inline_safe_mask)) + else if (!skip_isa_check + && ((!always_inline + && caller_opts->x_target_flags != callee_opts->x_target_flags) + || ((caller_opts->x_target_flags & ~always_inline_safe_mask) + != (callee_opts->x_target_flags & ~always_inline_safe_mask)))) ret = false; /* See if arch, tune, etc. are the same. */ diff --git a/gcc/testsuite/gcc.target/i386/pr98209.c b/gcc/testsuite/gcc.target/i386/pr98209.c new file mode 100644 index 00000000000..4566d4c7fc3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr98209.c @@ -0,0 +1,13 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-options "-O2 -D_FORTIFY_SOURCE=2" } */ + +#include + +extern int main(int argc, char** argv) + __attribute__ ((__target__ ("no-sse,no-mmx"))); + +int main(int argc, char** argv) +{ + printf ("hello!\n"); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/pr99744-1.c b/gcc/testsuite/gcc.target/i386/pr99744-1.c new file mode 100644 index 00000000000..92535923a56 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99744-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +#include + +extern unsigned long long int curr_deadline; +extern void bar (void); + +__attribute__ ((target("general-regs-only"))) +void +foo (void) +{ + if (__rdtsc () < curr_deadline) + return; + bar (); +} diff --git a/gcc/testsuite/gcc.target/i386/pr99744-2.c b/gcc/testsuite/gcc.target/i386/pr99744-2.c new file mode 100644 index 00000000000..4bb2a6bb6dc --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99744-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2" } */ + +#include + +extern __m128i x, y; + +__attribute__ ((target("general-regs-only"))) +void +foo (void) +{ + x = _mm_move_epi64 (y); /* { dg-error "SSE register return with SSE disabled" } */ +}