[flang-commits] [flang] [flang] Fix fir.call setCalleeFromCallable (PR #187124)
Razvan Lupusoru via flang-commits
flang-commits at lists.llvm.org
Wed Mar 18 09:39:44 PDT 2026
================
@@ -2701,11 +2701,25 @@ def fir_CallOp : fir_Op<"call",
/// Set the callee for this operation.
void setCalleeFromCallable(mlir::CallInterfaceCallable callee) {
- if (auto calling =
- (*this)->getAttrOfType<mlir::SymbolRefAttr>(getCalleeAttrName()))
- (*this)->setAttr(getCalleeAttrName(),
- llvm::cast<mlir::SymbolRefAttr>(callee));
- setOperand(0, llvm::cast<mlir::Value>(callee));
+ if (auto symbolRef = llvm::dyn_cast<mlir::SymbolRefAttr>(callee)) {
+ // Switching to direct call: set attribute and remove callee operand
+ // if the op was in indirect form (operand 0 was the callable value).
+ bool wasIndirect = llvm::isa<mlir::Value>(getCallableForCallee());
+ (*this)->setAttr(getCalleeAttrName(), symbolRef);
+ if (wasIndirect && getNumOperands() > 0)
+ (*this)->eraseOperand(0);
+ return;
+ }
----------------
razvanlupusoru wrote:
Nice catch! Fixed :)
https://github.com/llvm/llvm-project/pull/187124
More information about the flang-commits
mailing list