-
Notifications
You must be signed in to change notification settings - Fork 15k
[MLIR][RemoveDeadValues] Privatize public function with NonLive arguments before RDV. #162038
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
52cf8cb
be516b7
6c62398
3f4d69f
4904fb9
8f92fee
443dff2
12322aa
f6a9b62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -569,6 +569,24 @@ module @return_void_with_unused_argument { | |
| call @fn_return_void_with_unused_argument(%arg0, %unused) : (i32, memref<4xi32>) -> () | ||
| return %unused : memref<4xi32> | ||
| } | ||
|
|
||
| // the function signature is immutable because it is public. | ||
| func.func public @immutable_fn_with_unused_argument(%arg0: i32, %arg1: memref<4xf32>) -> () { | ||
| return | ||
| } | ||
|
|
||
| // CHECK-LABEL: func.func @main2 | ||
| // CHECK: %[[MEM:.*]] = memref.alloc() : memref<4xf32> | ||
| // CHECK: %[[UNUSED:.*]] = arith.constant 0 : i32 | ||
| // CHECK: call @immutable_fn_with_unused_argument(%[[UNUSED]], %[[MEM]]) : (i32, memref<4xf32>) -> () | ||
| func.func @main2() -> () { | ||
| %one = arith.constant 1 : i32 | ||
| %scalar = arith.addi %one, %one: i32 | ||
| %mem = memref.alloc() : memref<4xf32> | ||
|
|
||
| call @immutable_fn_with_unused_argument(%scalar, %mem) : (i32, memref<4xf32>) -> () | ||
| return | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add two CFG examples where the blocks are listed in different order to ensure you're not sensitive to the order the blocks are in-memory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi, @joker-eph Here is a testcase only for RegionBranchOpinterface. From %0 is live at line 11, we need to mark %0 is live at line 2. After that, we need to mark %c1_i32 at line 4 and c0_i32 at line 7 live as well. In order words, we need to walk function @main3 preorder + backward. I manage to fix this in propagateBackward. It pretty much redo what liveness analysis has done. TBH, I don't think this is the right way to proceed. RemoveDeadValues should keep its own single responsibility. I take a step back and think about why we end up here. The very reason we try to propagate liveness in it because:
How about we just introduce a new pass: 'privatize-public-function' right before 'remove-dead-values'.
Here is a demo what this pass transforms. This is my prototype here. do you think it's more feasible solution? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems reasonable, but this needs to be callable from RemoveDeadValues itself (the pass can't crash itself here) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figure out how to invalidate an analysis in analysis-manager, so I can combine them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update this branch. could you take a look at the new implementation? |
||
|
|
||
| // ----- | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.