diff options
Diffstat (limited to 'llvm/lib/Transforms/IPO')
| -rw-r--r-- | llvm/lib/Transforms/IPO/LowerTypeTests.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp index 693df5e7ba9..cdda8a68ecc 100644 --- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp @@ -1512,14 +1512,27 @@ bool LowerTypeTestsModule::lower() { FunctionType::get(Type::getVoidTy(M.getContext()), false), GlobalVariable::ExternalLinkage, FunctionName, &M); - if (Linkage == CFL_Definition) - F->eraseMetadata(LLVMContext::MD_type); + // If the function is available_externally, remove its definition so + // that it is handled the same way as a declaration. Later we will try + // to create an alias using this function's linkage, which will fail if + // the linkage is available_externally. This will also result in us + // following the code path below to replace the type metadata. + if (F->hasAvailableExternallyLinkage()) { + F->setLinkage(GlobalValue::ExternalLinkage); + F->deleteBody(); + F->setComdat(nullptr); + F->clearMetadata(); + } + // If the function in the full LTO module is a declaration, replace its + // type metadata with the type metadata we found in cfi.functions. That + // metadata is presumed to be more accurate than the metadata attached + // to the declaration. if (F->isDeclaration()) { if (Linkage == CFL_WeakDeclaration) F->setLinkage(GlobalValue::ExternalWeakLinkage); - SmallVector<MDNode *, 2> Types; + F->eraseMetadata(LLVMContext::MD_type); for (unsigned I = 2; I < FuncMD->getNumOperands(); ++I) F->addMetadata(LLVMContext::MD_type, *cast<MDNode>(FuncMD->getOperand(I).get())); |

