@@ -1620,7 +1620,7 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
16201620 return success ();
16211621 }
16221622 if (inst->getOpcode () == llvm::Instruction::Call) {
1623- auto callInst = cast<llvm::CallInst>(inst);
1623+ auto * callInst = cast<llvm::CallInst>(inst);
16241624 llvm::Value *calledOperand = callInst->getCalledOperand ();
16251625
16261626 FailureOr<SmallVector<Value>> operands =
@@ -1629,10 +1629,10 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
16291629 return failure ();
16301630
16311631 auto callOp = [&]() -> FailureOr<Operation *> {
1632- if ( auto asmI = dyn_cast<llvm::InlineAsm>(calledOperand)) {
1633- Type resultTy = convertType (callInst-> getType ());
1634- if (!resultTy)
1635- return failure ();
1632+ Type resultTy = convertType (callInst-> getType ());
1633+ if (!resultTy)
1634+ return failure ();
1635+ if ( auto *asmI = dyn_cast<llvm::InlineAsm>(calledOperand)) {
16361636 return builder
16371637 .create <InlineAsmOp>(
16381638 loc, resultTy, *operands,
@@ -1642,17 +1642,21 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
16421642 /* is_align_stack=*/ false , /* asm_dialect=*/ nullptr ,
16431643 /* operand_attrs=*/ nullptr )
16441644 .getOperation ();
1645- } else {
1646- LLVMFunctionType funcTy = convertFunctionType (callInst);
1647- if (!funcTy)
1648- return failure ();
1649-
1650- FlatSymbolRefAttr callee = convertCalleeName (callInst);
1651- auto callOp = builder.create <CallOp>(loc, funcTy, callee, *operands);
1652- if (failed (convertCallAttributes (callInst, callOp)))
1653- return failure ();
1654- return callOp.getOperation ();
16551645 }
1646+ LLVMFunctionType funcTy = convertFunctionType (callInst);
1647+ if (!funcTy)
1648+ return failure ();
1649+
1650+ if (funcTy.getReturnType () != resultTy)
1651+ return emitError (loc)
1652+ << " incompatible call and function return types: " << resultTy
1653+ << " vs. " << funcTy.getReturnType ();
1654+
1655+ FlatSymbolRefAttr callee = convertCalleeName (callInst);
1656+ auto callOp = builder.create <CallOp>(loc, funcTy, callee, *operands);
1657+ if (failed (convertCallAttributes (callInst, callOp)))
1658+ return failure ();
1659+ return callOp.getOperation ();
16561660 }();
16571661
16581662 if (failed (callOp))
@@ -1720,6 +1724,14 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
17201724 if (!funcTy)
17211725 return failure ();
17221726
1727+ Type resultTy = convertType (invokeInst->getType ());
1728+ if (!resultTy)
1729+ return failure ();
1730+ if (funcTy.getReturnType () != resultTy)
1731+ return emitError (loc)
1732+ << " incompatible invoke and function return types: " << resultTy
1733+ << " vs. " << funcTy.getReturnType ();
1734+
17231735 FlatSymbolRefAttr calleeName = convertCalleeName (invokeInst);
17241736
17251737 // Create the invoke operation. Normal destination block arguments will be
0 commit comments