This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Add no-prototype attribute to prototype-less C functions
ClosedPublic

Authored by sbc100 on Jun 21 2018, 10:06 AM.

Diff Detail

Event Timeline

sbc100 created this revision.Jun 21 2018, 10:06 AM
sbc100 updated this revision to Diff 152335.Jun 21 2018, 10:07 AM

wrong test

sbc100 retitled this revision from Add no-prototype attribute to prototype-less C functions to [WIP] Add no-prototype attribute to prototype-less C functions.Jun 21 2018, 10:08 AM
sbc100 added reviewers: jgravelle-google, dschuff.
sbc100 added a reviewer: sunfish.

Looks very reasonable and straightforward. LGTM in spirit, but I'll wait for someone who knows Clang better.

dschuff added inline comments.Jun 21 2018, 2:10 PM
lib/CodeGen/CGCall.cpp
1850 ↗(On Diff #152335)

Would it make sense to put this in AddAttributesFormFunctionProtoType Does this have the same effect as that would? For that matter, what's the practical difference between this call and the one on line 1826?

aheejin added inline comments.Jun 21 2018, 2:25 PM
lib/CodeGen/CGCall.cpp
1849 ↗(On Diff #152335)

Is there a reason why this is not something like llvm::Attribute::NoPrototype like other attributes?

dschuff added inline comments.Jun 21 2018, 3:12 PM
lib/CodeGen/CGCall.cpp
1849 ↗(On Diff #152335)

Target-independent attributes get enums, and target-specific attributes are just strings: https://llvm.org/docs/LangRef.html#attribute-groups
We could potentially make this attribute target-independent if there is wider interest in removing the reliance on bare (...) signatures to signify prototypeless C functions. I would like to see more details of how we plan to handle this in the backend before I have any idea about what anyone else might thing.

dschuff added inline comments.Jun 21 2018, 3:13 PM
lib/CodeGen/CGCall.cpp
1849 ↗(On Diff #152335)

Actually, I just noticed that we don't appear to have made this actually target-dependent (the test uses X86). So we should either make this attribute actually wasm-only, or make it an enum.

sbc100 updated this revision to Diff 152505.Jun 22 2018, 10:00 AM
  • feedback

OK, I made this target specific. I think this is cleaner now.

sbc100 retitled this revision from [WIP] Add no-prototype attribute to prototype-less C functions to [WebAssembly] Add no-prototype attribute to prototype-less C functions.Jun 22 2018, 10:03 AM
sbc100 edited the summary of this revision. (Show Details)
sunfish accepted this revision.Jun 22 2018, 2:18 PM

I haven't thought through all the possibilities related to !FD->doesThisDeclarationHaveABody(), but overall this looks good.

This revision is now accepted and ready to land.Jun 22 2018, 2:18 PM

Without the check for doesThisDeclarationHaveABody() the attribute will also be added to baz which is IIRC is not what we want since the C notions of "prototypeless" only applies to forward declarations I think.

This revision was automatically updated to reflect the committed changes.