[cfe-commits] [PATCH] Potential fix for PR9614

Eli Friedman eli.friedman at gmail.com
Tue Oct 11 16:02:29 PDT 2011


On Tue, Oct 11, 2011 at 3:51 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> On Tue, Oct 11, 2011 at 01:32:14PM -0700, Eli Friedman wrote:
>> On Tue, Oct 11, 2011 at 1:28 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
>> > On Sun, Oct 9, 2011 at 12:11 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
>> >> Hi,
>> >>
>> >> These patches (for Clang and LLVM) together fix PR9614.
>> >>
>> >> The Clang patch causes it to mark self calls to available_externally
>> >> functions via an asm label as noinline, and the LLVM patch inhibits
>> >> certain optimizations, including tail call elimination, for noinline
>> >> calls to available_externally functions, forcing a call to the external
>> >> version of the function.
>> >>
>> >> Any thoughts on this approach?  Is this OK to commit?
>> >
>> > I really don't like overloading the semantics of noinline in this
>> > way... noinline is supposed to prevent inlining, not stop every
>> > optimization that might examine the contents of the function.  If you
>> > need to represent something new, use a new call attribute, or
>> > something like that.
>
> OK, I like that better.  What about adding a call attribute 'external'
> which resides before 'tail' in the grammar of the call instruction?
>
>> >  (Granted, that's still a bit messy, but I can't
>> > think of a particularly better solution... the only other thing I can
>> > think of is abusing aliases somehow to get the desired semantics,
>> > using a special kind of linkage.  Possibly more localized, but aliases
>> > can get messy.)
>
> I considered using aliases for this, but aliases don't really capture
> the semantics of the call as well as a call attribute would do, and
> the attribute seems to be simpler for frontends for other languages
> which need this same functionality to emit.  So, less messy IMHO.

In some sense, it's not really a property of the call, though... for
example, consider the following:

extern void __foo_alias(void) __asm ("foo");
inline void foo() {
  void (*ptr)(void) = __foo_alias;
  ptr();
}

(Granted, I doubt there's any real-world code that actually does that,
but I'm sure it works in gcc.)

-Eli




More information about the cfe-commits mailing list