Merge pull request #1142 from dbabokin/linker_fix

Move only unused declaration, the rest will be moved by Linker.
This commit is contained in:
Dmitry Babokin
2015-12-25 14:25:29 +03:00

View File

@@ -906,6 +906,9 @@ AddBitcodeToModule(const unsigned char *bitcode, int length,
// This trick should be legal, as both modules use the same LLVMContext.
for (llvm::Function& f : *bcModule) {
if (f.isDeclaration()) {
// Declarations with uses will be moved by Linker.
if (f.getNumUses() > 0)
continue;
module->getOrInsertFunction(f.getName(), f.getFunctionType(),
f.getAttributes());
}