Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

LLVM IR should be able to represent definitions of interposable functions #23500

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR23501
Status NEW
Importance P normal
Reported by Reid Kleckner (rnk@google.com)
Reported on 2015-05-12 13:51:48 -0700
Last modified on 2016-11-29 13:58:30 -0800
Version trunk
Hardware PC Windows NT
CC joker.eph@gmail.com, llvm-bugs@lists.llvm.org, mseaborn@chromium.org, rafael@espindo.la, t.p.northover@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
ELF allows users to interpose function definitions in shared libraries, and C's
version of the ODR permits this. While this functionality isn't often used, we
should have some way of representing a function definition with external
linkage (it's not ELF weak) but may be overridden at runtime.

We probably don't want to enable interposability for all external C function
definitions by default in Clang, but once we have LLVM support this we can add
an attribute or flag get at this.

A GCC developer claimed this was an LLVM bug in the blog post below, but I
think the LLVM consensus is that this is working as intended. We just need an
escape hatch to complete the picture and reduce this to a difference in default
behaviors.
http://hubicka.blogspot.com/2015/04/GCC5-IPA-LTO-news.html

Anyway, I would probably add a new linkage type, like external_interposable or
external_nonodr, and add it to the appropriate GlobalValue linkage predicates,
like mayBeOverridden().
Quuxplusone commented 9 years ago
A new linkage is probably fine.

Another option is splitting the interposability into a new field:

<empty>: we have the final definition.
ODR: we have the final value.
Interposable: we have neither.

The weak linkage would require (or imply) Interposable. The *_odr linkages
would be removed.

I need to go over the lanlanguage reference again to really have an opinion.
Quuxplusone commented 9 years ago

Why do you think the new field needs 3 states? I think two is fine. This interposability bit really just feeds into "mayBeOverridden", just like ODR. They're just opposites. Since this is pretty low priority, we can probably just wait and get this for free whenever we split "ODR-ness" out of linkage.

Quuxplusone commented 7 years ago

See: https://reviews.llvm.org/D20217