[Mlir-commits] [mlir] [MLIR][LLVMIR] Allow llvm.call and llvm.invoke to use llvm.mlir.alias as callee (PR #189154)
Tobias Gysi
llvmlistbot at llvm.org
Sat Mar 28 05:55:27 PDT 2026
================
@@ -639,11 +643,29 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
ArrayRef<llvm::Value *> operandsRef(operands);
llvm::InvokeInst *result;
if (auto attr = opInst.getAttrOfType<FlatSymbolRefAttr>("callee")) {
- result = builder.CreateInvoke(
- moduleTranslation.lookupFunction(attr.getValue()),
- moduleTranslation.lookupBlock(invOp.getSuccessor(0)),
- moduleTranslation.lookupBlock(invOp.getSuccessor(1)), operandsRef,
- opBundles);
+ if (llvm::Function *function =
+ moduleTranslation.lookupFunction(attr.getValue())) {
+ result = builder.CreateInvoke(
+ function, moduleTranslation.lookupBlock(invOp.getSuccessor(0)),
+ moduleTranslation.lookupBlock(invOp.getSuccessor(1)), operandsRef,
+ opBundles);
+ } else {
+ Operation *moduleOp = parentLLVMModule(&opInst);
+ Operation *calleeOp =
+ moduleTranslation.symbolTable().lookupSymbolIn(moduleOp, attr);
+ llvm::FunctionType *calleeType = llvm::cast<llvm::FunctionType>(
+ moduleTranslation.convertType(invOp.getCalleeFunctionType()));
+ llvm::GlobalValue *calleeGV;
+ if (isa<LLVM::AliasOp>(calleeOp))
+ calleeGV = moduleTranslation.lookupAlias(calleeOp);
+ else
+ calleeGV = moduleTranslation.lookupIFunc(calleeOp);
----------------
gysit wrote:
Could it make sense to factor out a helper that takes symbol and function type and returns the lowered global and callee type, which then could be used for the call and invoke lowering. Or are there too many parameters needed?
https://github.com/llvm/llvm-project/pull/189154
More information about the Mlir-commits
mailing list