Index: llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp =================================================================== --- llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp +++ llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp @@ -855,15 +855,20 @@ FDecl = Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage, Name + ".cfi_jt", &M); FDecl->setVisibility(GlobalValue::HiddenVisibility); - } else { - // Definition. - assert(isDefinition); + } else if (isDefinition) { F->setName(Name + ".cfi"); F->setLinkage(GlobalValue::ExternalLinkage); F->setVisibility(GlobalValue::HiddenVisibility); FDecl = Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage, Name, &M); FDecl->setVisibility(Visibility); + } else { + // Function definition without type metadata, where some other translation + // unit contained a declaration with type metadata. This normally happens + // during mixed CFI + non-CFI compilation. We do nothing with the function + // so that it is treated the same way as a function defined outside of the + // LTO unit. + return; } if (F->isWeakForLinker()) Index: llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-icall.yaml =================================================================== --- llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-icall.yaml +++ llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-icall.yaml @@ -16,4 +16,5 @@ CfiFunctionDecls: - external - external_weak + - local_decl ... Index: llvm/trunk/test/Transforms/LowerTypeTests/import-icall.ll =================================================================== --- llvm/trunk/test/Transforms/LowerTypeTests/import-icall.ll +++ llvm/trunk/test/Transforms/LowerTypeTests/import-icall.ll @@ -19,6 +19,10 @@ ret i8 %x } +define void @local_decl() { + call void @local_decl() + ret void +} declare void @external() declare extern_weak void @external_weak() @@ -33,6 +37,9 @@ ; CHECK: define internal i8 @local_b() { ; CHECK-NEXT: call i8 @local_a() +; CHECK: define void @local_decl() +; CHECK-NEXT: call void @local_decl() + ; CHECK: declare void @external() ; CHECK: declare extern_weak void @external_weak() ; CHECK: declare i8 @local_a()