New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-6209] Allow @_silgen_name to create a hidden symbol #48761
Comments
I think this just means not to eliminate it in dead function elimination, which seems reasonable. (It works in non-WMO -O and in -Onone.) @eeckstein, who works on dead function elimination these days? |
It's pretty easy to add that in dead function elimination: Just add an additional check in bool isAnchorFunction(SILFunction *F) |
That turns out not to work: isAnchorFunction() is never called during the stdlib's build (at least not a debug-stdlib build), presumably because DFE is not running at all. Something else must be killing the function. |
There is another thing: IRGen only emits functions lazily. The check for this is done in IRGenerator::emitGlobalTopLevel(). I think the best solution is to check for @_silgen_name in SILFunction::isPossiblyUsedExternally(). Unfortunately in some places (like IRGenerator::emitGlobalTopLevel) doesn't call this SILFunction member, but instead call the global function isPossiblyUsedExternally. This has to be changed. |
Original |
Changing SILFunction::isPossiblyUsedExternally() and SILFunction::isExternallyUsed() was insufficient. Changing the global isPossiblyUsedExternally() function in SILLinkage.h to One conceptually correct fix would be to introduce an additional SILLinkage value between Public and Hidden which I shall call MostlyHidden. |
> Changing SILFunction::isPossiblyUsedExternally() and SILFunction::isExternallyUsed() was insufficient. As I said earlier, there are some uses of the global isPossiblyUsedExternally function, which are called with the function's linkage (like in IRGen). You have to replace this with the SILFunction::isPossiblyUsedExternally. That's the cleanest and easiest fix. > Changing the global isPossiblyUsedExternally() function in SILLinkage.h to That would be bad for the optimizer. > One conceptually correct fix would be to introduce an additional SILLinkage value between Public and Hidden Please don't. It would make our already complicated linkage model even more not-understandable. |
This uses the There is residual ugliness involving this and |
This is done now. |
Additional Detail from JIRA
md5: 55224335b3454471952a666e403be0bd
Issue Description:
libswiftCore uses @_silgen_name to write Swift functions that can be called from C code. There should be a way to do this that creates a hidden symbol (matching clang's `__attribute__((visibility("hidden")))`).
Example of today's usage:
This function is intended to be called by libswiftCore's C code only, but the swift_stdlib_getErrorCode symbol is eventually exported from libSwiftCore. That's bad.
Suggested change: use a hidden symbol when an internal func implementation has @_silgen_name:
The text was updated successfully, but these errors were encountered: