-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[MLIR][EmitC] Bugfix in emitc.call_opaque operand emission #153980
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-emitc @llvm/pr-subscribers-mlir Author: Gabriel Dehame (gdehame) ChangesThe operand emission needed the operand to be in scope which lead to failure when the emitc.call_opaque is in an emitc.expression's body Full diff: https://github.com/llvm/llvm-project/pull/153980.diff 1 Files Affected:
diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
index 8e83e455d1a7f..510bf7b72b00c 100644
--- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp
+++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
@@ -749,10 +749,8 @@ static LogicalResult printOperation(CppEmitter &emitter,
if (t.getType().isIndex()) {
int64_t idx = t.getInt();
Value operand = op.getOperand(idx);
- if (!emitter.hasValueInScope(operand))
- return op.emitOpError("operand ")
- << idx << "'s value not defined in scope";
- os << emitter.getOrCreateName(operand);
+ if (failed(emitter.emitOperand(operand)))
+ return failure();
return success();
}
}
|
Example MLIR leading to an error before fix:
|
I think it would be good to add a test for this. |
@marbre, @simon-camp, @mgehre-amd - this LGTM, but I'm fixing a very similar bug in #155171 so I'm biased. Could you take a look? |
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.
Looks good to me, Just two nits. Thanks you forbthe fix!
return op.emitOpError("operand ") | ||
<< idx << "'s value not defined in scope"; | ||
os << emitter.getOrCreateName(operand); | ||
if (failed(emitter.emitOperand(operand))) |
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.
You can return emitter.emitOperand directly.
yield %4 : i1 | ||
} | ||
return | ||
} |
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.
Missing new line
41b704a
to
c03d58f
Compare
The operand emission needed the operand to be in scope which lead to failure when the emitc.call_opaque is in an emitc.expression's body
c03d58f
to
4168756
Compare
Fixed format and squashed commits to merge a single commit |
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! Do you want me to merge on your behalf @gdehame?
Yes please |
The operand emission needed the operand to be in scope which lead to failure when the emitc.call_opaque is in an emitc.expression's body