Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp =================================================================== --- llvm/lib/Transforms/IPO/LowerTypeTests.cpp +++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp @@ -983,7 +983,7 @@ if (F->isWeakForLinker()) replaceWeakDeclarationWithJumpTablePtr(F, FDecl); else - F->replaceAllUsesWith(FDecl); + F->replaceUsesExceptBlockAddr(FDecl); } void LowerTypeTestsModule::lowerTypeTestCalls( Index: llvm/test/ThinLTO/X86/blockaddr-import.ll =================================================================== --- /dev/null +++ llvm/test/ThinLTO/X86/blockaddr-import.ll @@ -0,0 +1,35 @@ +; RUN: opt -thinlto-bc %s -o %t1.bc +; RUN: llvm-lto2 run %t1.bc -r=%t1.bc,o,x -r=%t1.bc,l,plx -r=%t1.bc,m,plx -r=%t1.bc,d,plx -o %t2 + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux" + +@d = common hidden local_unnamed_addr global void (...)* null, align 8 + +declare i1 @llvm.type.test(i8*, metadata) #1 +declare !type !11 i32 @o(...) + +define hidden void @l() local_unnamed_addr #0 !type !3 { +entry: + %0 = load void (...)*, void (...)** @d, align 8 + %1 = bitcast void (...)* %0 to i8* + %2 = tail call i1 @llvm.type.test(i8* %1, metadata !"_ZTSFvE") + br i1 %2, label %cont, label %handler.cfi_check_fail + +handler.cfi_check_fail: + br label %cont + +cont: + ret void +} + +define hidden void @m() #0 !type !3 { +entry: + br label %n +n: + %call = tail call i32 (i8*, ...) bitcast (i32 (...)* @o to i32 (i8*, ...)*)(i8* blockaddress(@m, %n)) #4 + ret void +} + +!3 = !{i64 0, !"_ZTSFvE"} +!11 = !{i64 0, !"_ZTSFiE"}