-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[mlir][emitc] Fix bug in dereference translation #171028
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
[mlir][emitc] Fix bug in dereference translation #171028
Conversation
The op was not added to `hasDeferredEmission()` when introduced by f17abc2, causing incorrect translation.
|
@llvm/pr-subscribers-mlir-emitc @llvm/pr-subscribers-mlir Author: Gil Rapaport (aniragil) ChangesThe op was not added to Full diff: https://github.com/llvm/llvm-project/pull/171028.diff 2 Files Affected:
diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
index 55b9c3dc0a355..15c23c60d0b86 100644
--- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp
+++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
@@ -333,7 +333,8 @@ struct CppEmitter {
/// Determine whether expression \p op should be emitted in a deferred way.
static bool hasDeferredEmission(Operation *op) {
- return isa_and_nonnull<emitc::GetGlobalOp, emitc::LiteralOp, emitc::MemberOp,
+ return isa_and_nonnull<emitc::DereferenceOp, emitc::GetGlobalOp,
+ emitc::LiteralOp, emitc::MemberOp,
emitc::MemberOfPtrOp, emitc::SubscriptOp,
emitc::GetFieldOp>(op);
}
diff --git a/mlir/test/Target/Cpp/common-cpp.mlir b/mlir/test/Target/Cpp/common-cpp.mlir
index abf85c8e9a359..f397a4ae9709f 100644
--- a/mlir/test/Target/Cpp/common-cpp.mlir
+++ b/mlir/test/Target/Cpp/common-cpp.mlir
@@ -118,7 +118,7 @@ func.func @address_of() {
// CHECK-LABEL: void dereference
// CHECK-SAME: (int32_t* [[ARG0:[^ ]*]]) {
func.func @dereference(%arg0: !emitc.ptr<i32>) {
- // CHECK: int32_t [[V1:[^ ]*]] = *[[ARG0]];
+ // CHECK-NEXT: int32_t [[V1:[^ ]*]] = *[[ARG0]];
%2 = emitc.dereference %arg0 : !emitc.ptr<i32>
emitc.load %2 : !emitc.lvalue<i32>
return
|
|
@simon-camp , @marbre - I pushed this PR promptly to hopefully get this fix to downstream users before they hit the bug, but post-commit review is welcome. |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/52/builds/13397 Here is the relevant piece of the build log for the reference |
The op was not added to `hasDeferredEmission()` when introduced by f17abc2, causing incorrect translation.
The op was not added to
hasDeferredEmission()when introduced by f17abc2, causing incorrect translation.