On Mon, Apr 12, 2021 at 11:53 PM H.J. Lu <hjl.to...@gmail.com> wrote:
>
> On Mon, Apr 12, 2021 at 2:21 AM Richard Biener
> <richard.guent...@gmail.com> wrote:
> >
> > On Sat, Apr 10, 2021 at 5:11 PM H.J. Lu via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> > >
> > > Add inline_ignore_target function attribute to inform the compiler that
> > > target specific option mismatch on functions with the always_inline
> > > attribute may be ignored.  On x86 targets, this attribute can be used on
> > > integer functions to ignore target non-integer option mismatch.
> >
> > I'm not sure I like such attribute but please adjust 
> > default_target_can_inline_p
> > accordingly (only few targets override this hook).
> >
> > Richard.
> >
>
> Like this?

Hmm, so

 bool
 default_target_can_inline_p (tree caller, tree callee)
 {
-  tree callee_opts = DECL_FUNCTION_SPECIFIC_TARGET (callee);
-  tree caller_opts = DECL_FUNCTION_SPECIFIC_TARGET (caller);
-  if (! callee_opts)
+  tree callee_opts;
+  if (lookup_attribute ("inline_ignore_target",
+                       DECL_ATTRIBUTES (callee)))
     callee_opts = target_option_default_node;
+  else
+    {
+      callee_opts = DECL_FUNCTION_SPECIFIC_TARGET (callee);
+      if (! callee_opts)
+       callee_opts = target_option_default_node;
+    }

this means the attribute will "not work" for

statici inline void __attribute__((always_inline,inline_ignore_target))
foo() {}

void __attribute__((target("-mfoo")))
bar() { foo(); }

because while it ignores the target attribute on 'foo',
target_option_default_node
will still conflict with the target attribute of 'bar'.

Is that the intended behavior?  Ignore 'foo's target attribute for the
inlining decision, but not 'bar's?

What about __attribute__((optimization)) mismatches?

It might be more sensible to have a separate always-inline
attribute, say __attribute__((force_inline)) that does what I think
always-inline should do (inline, no matter what)?

Now, I still believe always-inline should behave and this new attribute
is totally unnecessary.

Richard.

> Thanks.
>
> --
> H.J.

Reply via email to