[PATCH] Module: Use existing library functions

Duncan P. N. Exon Smith dexonsmith at apple.com
Sat Mar 1 16:22:42 PST 2014


During LTO, user-supplied definitions of C library functions often
exist.  -instcombine uses Module::getOrInsertFunction() to get a handle
on library functions (e.g., @puts, when optimizing @printf).

Previously, Module::getOrInsertFunction() would rename any matching
functions with local linkage, and create a new declaration.  In LTO,
this is the opposite of desired behaviour, as it skips by the
user-supplied version of the library function and creates a new
undefined reference which the linker often cannot resolve.

Removing that logic did not cause any tests to fail, and I couldn't
think of why it's *good* behaviour.  Maybe no one was using it?

I added two testcases: one specifically for the -instcombine behaviour
and one for the LTO flow that exposed it.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: module-renaming-library-functions.patch
Type: application/octet-stream
Size: 4625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140301/0ae2f4f7/attachment.obj>


More information about the llvm-commits mailing list