sbc100 abandoned this revision.
sbc100 added a comment.

In D76547#4231604 <https://reviews.llvm.org/D76547#4231604>, @aaron.ballman 
wrote:

> In D76547#4231501 <https://reviews.llvm.org/D76547#4231501>, @sbc100 wrote:
>
>> In D76547#4231476 <https://reviews.llvm.org/D76547#4231476>, @aaron.ballman 
>> wrote:
>>
>>> In D76547#4231422 <https://reviews.llvm.org/D76547#4231422>, @sbc100 wrote:
>>>
>>>> The reason `__attribute__((export_name("foo")))` doesn't work in all use 
>>>> cases is that we have a lot of existing code that uses the 
>>>> `EMSCRIPTEN_KEEPALIVE` macro.     We also have run into other folks who 
>>>> want to include this is some kind of `FOO_API`, or `EXPORT_API` type 
>>>> macros.  Its not possible to have such a macro map to the existing 
>>>> export_name since they don't include the symbol name: e.g:
>>>>
>>>>   EMSCRIPTEN_KEEPALIVE int foo();`
>>>>   
>>>>   JNI_EXPORT int myfunct();
>>>>
>>>> In these cases we need something that uses the llvm symbol name for the 
>>>> export.
>>>
>>> I think there's two ways we could address this without adding a new 
>>> attribute (maybe you've thought of this and have reasons for this to be a 
>>> bad suggestion):
>>>
>>> - It seems that `export_name` doesn't care if you put in an empty string 
>>> for the argument, so we could treat that case as meaning "export with the 
>>> name of the symbol this attribute is attached to"
>>> - We could allow `export_name` to take zero or one argument. The 
>>> one-argument form is the same as it is today, but the zero argument form 
>>> exports with the name of the symbol the attribute is attached to.
>>>
>>> Do you think either of those could work?
>>
>> Yes, I think the second one would be ideal.  The first one is slightly less 
>> idea because it prevents something being exported with the empty string as 
>> its name (wasm allows such things).
>
> Ah, yeah, that's a good reason to avoid the first one.
>
>> Can an attribute take an optional argument?  That would be great solution.   
>> For my initial version of this change I did look into making 
>> `export_name(DEFAULT)` work (note the lack of quotes around the word DEFAULT 
>> here), but I could not find way to make a single attribute take both a 
>> string *or* a constant.
>
> Yup, it takes only a little bit of extra work to do right. Have the 
> attribute's argument list take a `VariadicStringArgument` instead of 
> `StringArgument` so you can pass zero or more arguments, then have the 
> attribute handler in SemaDeclAttr.cpp diagnose if the attribute is given > 1 
> argument. The rest should be things like documentation or fall out somewhat 
> naturally (there will be accessors added to the `WebAssemblyExportNameAttr` 
> class that let you access the arguments with iterators, and a size accessor 
> as well, so you can tell if the semantic attribute does/does not have an 
> argument).

Thanks!  Closing this one for now then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76547/new/

https://reviews.llvm.org/D76547

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to