[llvm-commits] [llvm] r154124 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp
Chris Lattner
clattner at apple.com
Fri Apr 6 10:22:41 PDT 2012
On Apr 6, 2012, at 12:34 AM, Duncan Sands wrote:
>> The linker was told that the 'foo' in 'main' was 'internal' and had no uses, so
>> it was dead stripped.
>>
>> Another situation is something like:
>>
>> define void @foo() {
>> ret void
>> }
>>
>> define void @bar() {
>> call asm volatile "call _foo" ...
>> ret void
>> }
>>
>> The only use of 'foo' is inside of an inline ASM call. Since we don't look
>> inside those for uses of functions, we don't specify this as a "use."
>
> This is user error: the user should add a "used" attribute to foo. This isn't
> anything new: lots of people make this mistake (it's come up again and again on
> the mailing list and in bugzilla). The user should be educated here.
"What Duncan Said". This is expected behavior - and it really is a bug in the source code.
That said, if clang is running internalize at "clang -O4" or "clang -flto" then we should talk about whether that really is the right default. I'm not convinced it is. GCC has a -fwhole-program flag (or something like that) which might be appropriate. Otherwise, the standard linker visibility stuff should be used.
-Chris
More information about the llvm-commits
mailing list