[NFC][libclc] Define _CLC_DEF_WEAK and replace _CLC_DEF_ldexp with it#156378
[NFC][libclc] Define _CLC_DEF_WEAK and replace _CLC_DEF_ldexp with it#156378
Conversation
_CLC_DEF_WEAK can be used in our downstream libclc to allow overriding generic __clc_tgamma implementation.
frasercrmck
left a comment
There was a problem hiding this comment.
LGTM.
My main question is - why not make all definitions weak? The alternative is to make them weak as and when we or a downstream needs them, or come up with some rationale for which ones are or aren't weak.
Do you mean make all generic definitions weak? That sounds like a good idea. |
|
Unfortunately weak linkage prevents PostOrderFunctionAttrsPass from deducing attributes for functions that have weak linkage: weak_odr probably suits libclc and it can enables optimization in PostOrderFunctionAttrsPass. However, there is no corresponding clang attribute, i.e. edit: weak_odr doesn't work either since hasExactDefinition returns false for weak_odr linkage. |
|
Applying weak attribute to a small set of libclc functions, like this PR does, might be acceptable because libclc will eventually set linkage to linkonce_odr for all functions. The small set of libclc functions, that were not optimized by PostOrderFunctionAttrsPass during libclc build, will be optimized by the same pass after being linked into user code. |
|
@frasercrmck I proposed an alternative approach that overrides generic symbol using llvm-link --override flag instead of using weak linkage: #156778 |
_CLC_DEF_WEAK can be used in our downstream libclc to allow overriding generic __clc_tgamma implementation.