Linker: Add flag to override linkage rules
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 22 Apr 2015 04:11:00 +0000 (04:11 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 22 Apr 2015 04:11:00 +0000 (04:11 +0000)
commitfae374b95efd9f07a7bcb9fae374c10b02b9283d
tree5643343e503dddcf70a7d2c2b1490653f13b52b5
parentd9443d717dbb3ec01ae8441dd70c2a077a7b5c09
Linker: Add flag to override linkage rules

Add a flag to lib/Linker (and `llvm-link`) to override linkage rules.
When set, the functions in the source module *always* replace those in
the destination module.

The `llvm-link` option is `-override=abc.ll`.  All the "regular" modules
are loaded and linked first, followed by the `-override` modules.  This
is useful for debugging workflows where some subset of the module (e.g.,
a single function) is extracted into a separate file where it's
optimized differently, before being merged back in.

Patch by Luqman Aden!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235473 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Linker/Linker.h
lib/Linker/LinkModules.cpp
test/Linker/Inputs/override-different-linkage.ll [new file with mode: 0644]
test/Linker/Inputs/override-with-internal-linkage-2.ll [new file with mode: 0644]
test/Linker/Inputs/override-with-internal-linkage.ll [new file with mode: 0644]
test/Linker/Inputs/override.ll [new file with mode: 0644]
test/Linker/override-different-linkage.ll [new file with mode: 0644]
test/Linker/override-with-internal-linkage-2.ll [new file with mode: 0644]
test/Linker/override-with-internal-linkage.ll [new file with mode: 0644]
test/Linker/override.ll [new file with mode: 0644]
tools/llvm-link/llvm-link.cpp