-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][LLVM] Fix CallOp asm parser for attr-dict #74372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-llvm Author: Billy Zhu (zyx-billy) ChangesCurrently the parser & printer of Full diff: https://github.com/llvm/llvm-project/pull/74372.diff 2 Files Affected:
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 28445945f07d6..4c3367336fa79 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -1219,8 +1219,7 @@ ParseResult CallOp::parse(OpAsmParser &parser, OperationState &result) {
return failure();
// Parse the function arguments.
- if (parser.parseOperandList(operands, OpAsmParser::Delimiter::Paren) ||
- parser.parseOptionalAttrDict(result.attributes))
+ if (parser.parseOperandList(operands, OpAsmParser::Delimiter::Paren))
return failure();
bool isVarArg = parser.parseOptionalKeyword("vararg").succeeded();
@@ -1232,6 +1231,9 @@ ParseResult CallOp::parse(OpAsmParser &parser, OperationState &result) {
return failure();
}
+ if (parser.parseOptionalAttrDict(result.attributes))
+ return failure();
+
// Parse the trailing type list and resolve the operands.
return parseCallTypeAndResolveOperands(parser, result, isDirect, operands);
}
diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir
index 3f84f9dc5a9b8..3ec8aa0e8bb12 100644
--- a/mlir/test/Target/LLVMIR/llvmir.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir.mlir
@@ -1227,15 +1227,19 @@ llvm.func @varargs(...)
// CHECK-LABEL: define void @varargs_call
llvm.func @varargs_call(%arg0 : i32) {
+// CHECK: call void (...) @varargs(i32 %{{.*}})
// CHECK: call void (...) @varargs(i32 %{{.*}})
llvm.call @varargs(%arg0) vararg(!llvm.func<void (...)>) : (i32) -> ()
+ llvm.call @varargs(%arg0) vararg(!llvm.func<void (...)>) {fastmathFlags = #llvm.fastmath<none>} : (i32) -> ()
llvm.return
}
// CHECK-LABEL: define void @indirect_varargs_call(ptr %0, i32 %1)
llvm.func @indirect_varargs_call(%arg0 : !llvm.ptr, %arg1 : i32) {
+// CHECK: call void (...) %0(i32 %1)
// CHECK: call void (...) %0(i32 %1)
llvm.call %arg0(%arg1) vararg(!llvm.func<void (...)>) : !llvm.ptr, (i32) -> ()
+ llvm.call %arg0(%arg1) vararg(!llvm.func<void (...)>) {fastmathFlags = #llvm.fastmath<none>} : !llvm.ptr, (i32) -> ()
llvm.return
}
|
mlir/test/Target/LLVMIR/llvmir.mlir
Outdated
llvm.return | ||
} | ||
|
||
// CHECK-LABEL: define void @indirect_varargs_call(ptr %0, i32 %1) | ||
llvm.func @indirect_varargs_call(%arg0 : !llvm.ptr, %arg1 : i32) { | ||
// CHECK: call void (...) %0(i32 %1) | ||
// CHECK: call void (...) %0(i32 %1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would thinks you would check the attributes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh there was no result to show any difference, I was just trying to test parsing. But let me change this to make the attribute show up in the conversion result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a test to the LLVM dialect roundtrip test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the fix 🙂
Let me know when we should land this for you.
Thank you for the suggestions! Please feel free to just land it any time now 🙏 thanks! |
Currently the parser & printer of
CallOp
do not match when both varargs and attr-dict are present (round tripping is broken). This fixes the parser so that it conforms to the written asm format in the comments.