@@ -426,13 +426,20 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
426426 moduleTranslation.lookupFunction (attr.getValue ())) {
427427 call = builder.CreateCall (function, operandsRef, opBundles);
428428 } else {
429- Operation *moduleOp = parentLLVMModule (&opInst);
430- Operation *ifuncOp =
431- moduleTranslation.symbolTable ().lookupSymbolIn (moduleOp, attr);
432- llvm::GlobalValue *ifunc = moduleTranslation.lookupIFunc (ifuncOp);
433- llvm::FunctionType *calleeType = llvm::cast<llvm::FunctionType>(
434- moduleTranslation.convertType (callOp.getCalleeFunctionType ()));
435- call = builder.CreateCall (calleeType, ifunc, operandsRef, opBundles);
429+ auto &st = moduleTranslation.symbolTable ().getSymbolTable (callOp);
430+ auto alias = st.lookup <AliasOp>(attr.getValue ());
431+ if (alias) {
432+ llvm::GlobalValue *callee = moduleTranslation.lookupAlias (alias);
433+ llvm::FunctionType *ftype = llvm::cast<llvm::FunctionType>(moduleTranslation.convertType (alias.getAliasType ()));
434+ call = builder.CreateCall (ftype, callee, operandsRef, opBundles);
435+ } else {
436+ Operation *moduleOp = parentLLVMModule (&opInst);
437+ Operation *ifuncOp = st.lookupSymbolIn (moduleOp, attr);
438+ llvm::GlobalValue *ifunc = moduleTranslation.lookupIFunc (ifuncOp);
439+ llvm::FunctionType *calleeType = llvm::cast<llvm::FunctionType>(
440+ moduleTranslation.convertType (callOp.getCalleeFunctionType ()));
441+ call = builder.CreateCall (calleeType, ifunc, operandsRef, opBundles);
442+ }
436443 }
437444 } else {
438445 llvm::FunctionType *calleeType = llvm::cast<llvm::FunctionType>(
@@ -554,8 +561,19 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
554561 ArrayRef<llvm::Value *> operandsRef (operands);
555562 llvm::InvokeInst *result;
556563 if (auto attr = opInst.getAttrOfType <FlatSymbolRefAttr>(" callee" )) {
564+ llvm::GlobalValue *callee;
565+ llvm::FunctionType *ftype;
566+ if (auto *func = moduleTranslation.lookupFunction (attr.getValue ())) {
567+ ftype = func->getFunctionType ();
568+ callee = func;
569+ } else {
570+ auto &st = moduleTranslation.symbolTable ().getSymbolTable (invOp);
571+ auto alias = st.lookup <AliasOp>(attr.getValue ());
572+ callee = moduleTranslation.lookupAlias (alias);
573+ ftype = llvm::cast<llvm::FunctionType>(moduleTranslation.convertType (alias.getAliasType ()));
574+ }
557575 result = builder.CreateInvoke (
558- moduleTranslation. lookupFunction (attr. getValue ()) ,
576+ ftype, callee ,
559577 moduleTranslation.lookupBlock (invOp.getSuccessor (0 )),
560578 moduleTranslation.lookupBlock (invOp.getSuccessor (1 )), operandsRef,
561579 opBundles);
0 commit comments