This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Allow ctors functions that return values
ClosedPublic

Authored by sbc100 on Jun 16 2020, 12:48 PM.

Details

Summary

Some projects use the constructor attribute on functions that also
return values. In this case we just ignore them.

The error was reported in the libgpg-error project that marks
gpg_err_init with the __constructor__ attribute.

Diff Detail

Event Timeline

sbc100 created this revision.Jun 16 2020, 12:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2020, 12:48 PM

This change looks fine to me, though if you wanted to minimize the amount of code being emitted by the linker, another option would be to look into whether LLVM's FixFunctionBitcasts could handle this -- there should be a bitcast in the llvm.global_ctors array.

This change looks fine to me, though if you wanted to minimize the amount of code being emitted by the linker, another option would be to look into whether LLVM's FixFunctionBitcasts could handle this -- there should be a bitcast in the llvm.global_ctors array.

Interesting.. currently FixFunctionBitcasts only considered casts that are arguments to call instructions. Other kinds of casts such as ones that are used in stores we assume instead that that reverse cast will be applied when they are used.

Do you think its better to modify FixFunctionBitcasts to add this special case? (assuming I can).

ping..

Having looked at FixFunctionBitcasts it this fix is more appropriate. FixFunctionBitcasts is designed for callsites only (at least today).

dschuff accepted this revision.Jun 18 2020, 12:41 PM
This revision is now accepted and ready to land.Jun 18 2020, 12:41 PM
This revision was automatically updated to reflect the committed changes.