llvm-6502/tools/lto
Bill Wendling 97d9903236 The internalize pass can be dangerous for LTO.
Consider the following program:

$ cat main.c
void foo(void) { }

int main(int argc, char *argv[]) {
    foo();
    return 0;
}
$ cat bundle.c 
extern void foo(void);

void bar(void) {
     foo();
}
$ clang -o main main.c
$ clang -o bundle.so bundle.c -bundle -bundle_loader ./main
$ nm -m bundle.so
0000000000000f40 (__TEXT,__text) external _bar
                 (undefined) external _foo (from executable)
                 (undefined) external dyld_stub_binder (from libSystem)
$ clang -o main main.c -O4
$ clang -o bundle.so bundle.c -bundle -bundle_loader ./main
Undefined symbols for architecture x86_64:
  "_foo", referenced from:
      _bar in bundle-elQN6d.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

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."

Get around this by not invoking the 'internalize' pass by default. This is an
admitted hack for LTO correctness.
<rdar://problem/11185386>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154124 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-05 21:26:44 +00:00
..
CMakeLists.txt Add a basic-block autovectorization pass. 2012-02-01 03:51:43 +00:00
lto.cpp Cleanup whitespace and remove unneeded 'extern' keyword on function definitions. 2012-03-31 10:44:20 +00:00
lto.exports Expoert c interface for disassembler. 2011-03-29 00:01:39 +00:00
LTOCodeGenerator.cpp The internalize pass can be dangerous for LTO. 2012-04-05 21:26:44 +00:00
LTOCodeGenerator.h Move trivial functions into the class definition. 2012-03-31 11:25:18 +00:00
LTOModule.cpp Reformatting. No functionality change. 2012-04-03 03:56:52 +00:00
LTOModule.h Hack the hack. If we have a situation where an ASM object is defined but isn't 2012-04-02 10:01:21 +00:00
Makefile Add a basic-block autovectorization pass. 2012-02-01 03:51:43 +00:00