[Mlir-commits] [mlir] [mlir][llvm] Fixes CallOp builder for the case of indirect call (PR #76240)

Tobias Gysi llvmlistbot at llvm.org
Mon Dec 25 02:35:41 PST 2023


================
@@ -908,8 +908,9 @@ void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results,
 
 void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results,
                    FlatSymbolRefAttr callee, ValueRange args) {
+  auto fargs = callee ? args : args.drop_front();
----------------
gysit wrote:

> This is because there is no way to infer whether the callee is variadic or not in the case of an indirect call.

Good point... didn't consider that the callee type is actually only relevant for variadics. Then using the builder that takes the callee type makes most sense.

> So I think the change that is needed upstream is to just add an assert that callee is not nullptr. This will make it explicit that that builder will create a direct call.

Agreed. Is there actually a reason to set the callee type in the builder that the revision modifies. After all, the builder does not work for variadic functions. So just setting the calle_type to nullptr may also be an option?

https://github.com/llvm/llvm-project/pull/76240


More information about the Mlir-commits mailing list