[clang] [CIR] Upstream proper function alias lowering (PR #150520)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 25 08:23:36 PDT 2025
================
@@ -919,13 +919,46 @@ rewriteCallOrInvoke(mlir::Operation *op, mlir::ValueRange callOperands,
memoryEffects, noUnwind, willReturn);
mlir::LLVM::LLVMFunctionType llvmFnTy;
+
+ // Temporary to handle the case where we need to prepend an operand if the
+ // callee is an alias.
+ SmallVector<mlir::Value> adjustedCallOperands;
+
if (calleeAttr) { // direct call
- mlir::FunctionOpInterface fn =
- mlir::SymbolTable::lookupNearestSymbolFrom<mlir::FunctionOpInterface>(
- op, calleeAttr);
- assert(fn && "Did not find function for call");
- llvmFnTy = cast<mlir::LLVM::LLVMFunctionType>(
- converter->convertType(fn.getFunctionType()));
+ mlir::Operation *callee =
+ mlir::SymbolTable::lookupNearestSymbolFrom(op, calleeAttr);
+ if (auto fn = dyn_cast<mlir::FunctionOpInterface>(callee)) {
+ llvmFnTy = cast<mlir::LLVM::LLVMFunctionType>(
+ converter->convertType(fn.getFunctionType()));
----------------
xlauko wrote:
```suggestion
llvmFnTy =
converter->convertType<mlir::LLVM::LLVMFunctionType>(fn.getFunctionType());
```
https://github.com/llvm/llvm-project/pull/150520
More information about the cfe-commits
mailing list