@@ -334,7 +334,12 @@ LogicalResult ModuleTranslation::convertOperation(Operation &opInst,
334
334
return builder.CreateCall (functionMapping.lookup (attr.getValue ()),
335
335
operandsRef);
336
336
} else {
337
- return builder.CreateCall (operandsRef.front (), operandsRef.drop_front ());
337
+ auto *calleePtrType =
338
+ cast<llvm::PointerType>(operandsRef.front ()->getType ());
339
+ auto *calleeType =
340
+ cast<llvm::FunctionType>(calleePtrType->getElementType ());
341
+ return builder.CreateCall (calleeType, operandsRef.front (),
342
+ operandsRef.drop_front ());
338
343
}
339
344
};
340
345
@@ -353,14 +358,19 @@ LogicalResult ModuleTranslation::convertOperation(Operation &opInst,
353
358
if (auto invOp = dyn_cast<LLVM::InvokeOp>(opInst)) {
354
359
auto operands = lookupValues (opInst.getOperands ());
355
360
ArrayRef<llvm::Value *> operandsRef (operands);
356
- if (auto attr = opInst.getAttrOfType <FlatSymbolRefAttr>(" callee" ))
361
+ if (auto attr = opInst.getAttrOfType <FlatSymbolRefAttr>(" callee" )) {
357
362
builder.CreateInvoke (functionMapping.lookup (attr.getValue ()),
358
363
blockMapping[invOp.getSuccessor (0 )],
359
364
blockMapping[invOp.getSuccessor (1 )], operandsRef);
360
- else
365
+ } else {
366
+ auto *calleePtrType =
367
+ cast<llvm::PointerType>(operandsRef.front ()->getType ());
368
+ auto *calleeType =
369
+ cast<llvm::FunctionType>(calleePtrType->getElementType ());
361
370
builder.CreateInvoke (
362
- operandsRef.front (), blockMapping[invOp.getSuccessor (0 )],
371
+ calleeType, operandsRef.front (), blockMapping[invOp.getSuccessor (0 )],
363
372
blockMapping[invOp.getSuccessor (1 )], operandsRef.drop_front ());
373
+ }
364
374
return success ();
365
375
}
366
376
0 commit comments