[compiler-rt] r208603 - Move .subsections_via_symbols directives into DEFINE_COMPILERRT_PRIVATE_FUNCTION
jonathan at codesourcery.com
Mon May 12 16:18:51 PDT 2014
On 5/12/14, 3:47 PM, Nick Kledzik wrote:
> FYI, this is a semantic change. The .subsection_via_symbols directive tells the linker that the .o file has no functions that will fall into the next one (the compiler never does that, but it is common enough in hand written assembly). That means the linker can dead strip functions not referenced. By moving .subsection_via_symbols into FILE_LEVEL_DIRECTIVE, you’ve caused every file to opt-in to the directive, even if they have fall through code.
I think the real gotcha here is that DEFINE_COMPILERRT_FUNCTION, which defines something that looks like function level scope had/has a global directive in it affecting file level scope...
> I just did a quick survey of the .S files in compiler-rt and do not see any with fall through code. Mostly because compiler-rt has the convention of one function per file.
Does it really though? I didn't move .subsection_via_symbols into FILE_LEVEL_DIRECTIVE, it was already there. This only changes it for private functions, and further it makes those behave the same way
as non-private ones, which already had it.
> So, this change should be benign now, but may cause surprises on darwin in the future if someone tries to write fall-through assembly code.
So to eliminate this gotcha, it sounds like you are suggesting that I:
a) Remove FILE_LEVEL_DIRECTIVE from DEFINE_COMPILERRT_FUNCTION and DEFINE_COMPILERRT_PRIVATE_FUNCTION
b) Maybe also remove .subsections_via_symbols from FILE_LEVEL_DIRECTIVE
c) Add .subsections_via_symbols to every *.S file (possibly inside some other appropriately named macro)
I'm happy to do this, but I want to make sure I'm clear on what you want.
> On May 12, 2014, at 10:38 AM, Jonathan Roelofs <jonathan at codesourcery.com> wrote:
>> Author: jroelofs
>> Date: Mon May 12 12:38:36 2014
>> New Revision: 208603
>> URL: http://llvm.org/viewvc/llvm-project?rev=208603&view=rev
>> Move .subsections_via_symbols directives into DEFINE_COMPILERRT_PRIVATE_FUNCTION
>> Modified: compiler-rt/trunk/lib/builtins/assembly.h
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/assembly.h?rev=208603&r1=208602&r2=208603&view=diff
>> --- compiler-rt/trunk/lib/builtins/assembly.h (original)
>> +++ compiler-rt/trunk/lib/builtins/assembly.h Mon May 12 12:38:36 2014
>> @@ -25,6 +25,7 @@
>> #if defined(__APPLE__)
>> #define HIDDEN_DIRECTIVE .private_extern
>> #define LOCAL_LABEL(name) L_##name
>> +// tell linker it can break up file at label boundaries
>> #define FILE_LEVEL_DIRECTIVE .subsections_via_symbols
>> #define SYMBOL_IS_FUNC(name)
>> @@ -103,6 +104,7 @@
>> #define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name) \
>> + FILE_LEVEL_DIRECTIVE SEPARATOR \
>> .globl SYMBOL_NAME(name) SEPARATOR \
>> SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
>> HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR \
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded
More information about the llvm-commits