[PATCH] Prevent user-supplied libc implementations from premature removal in LTO

Rafael Espíndola rafael.espindola at gmail.com
Mon Nov 4 15:03:31 PST 2013


There is no need to check -globalopt in this patch too. Just check
that  llvm.compiler.used is created with the value you expect.

libLTO already knows about adding symbols used by inline asm to
llvm.compiler.used. Maybe this code would be better there?

On 4 November 2013 10:56, Duncan Exon Smith <dexonsmith at apple.com> wrote:
> This patch adds C runtime library functions to llvm.compiler.used during -internalize.  Since some transformations in -instcombine introduce new runtime library calls (e.g., by optimizing printf => puts), and some llvm intrinsics are lowered to runtime library calls (e.g., llvm.memset => memset), then it’s dangerous to discard any runtime library functions during optimizations.
>
> Adding internalized runtime library functions to llvm.compiler.used keeps them safe.  We still want internal linkage so that if these calls are truly unused, an intelligent linker can remove them (e.g., with -dead_strip).
>
> This is a particular problem when linking statically against user-supplied runtime libraries.
>
> Note: there’s a related problem with calls into compiler-rt that are added during instruction lowering (e.g., calls to __divdi3).  TargetLibraryInfo doesn’t know about any of those, so this patch does not address those cases.
>
> <rdar://problem/14740087>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list