-
Notifications
You must be signed in to change notification settings - Fork 12
feat(DeadCodeElimination - While loop and Function wrapper): Add WhileStatementElimination and UnusedFunctionElimination in DCE pass #39
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: dce
Are you sure you want to change the base?
Conversation
Introduces a new WhileStatementElimination pass to the Dead Code Elimination framework. This pass identifies 'while' loops with a constantly false condition and removes them entirely. Also includes minor header reordering and adjusts pointer syntax for consistency within 'pass.cc'.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
| "input.js", | ||
| "output.generated.txt", | ||
| "//maldoca/js/ir:lit_test_files", | ||
| "//third_party/maldoca/js/ir:lit_test_files", |
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.
We should drop the third_party part, since that is an internal path.
| @@ -0,0 +1,1489 @@ | |||
| // exec:begin | |||
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.
Add a test case that just runs DCE, i.e. the input should be the state after dynamic constant propagation.
|
|
||
| while(true){ | ||
| console.log("Should not be eliminated"); | ||
| } No newline at end of file |
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 add an empty line at the end to get rid of this warning.
| @@ -0,0 +1,7 @@ | |||
| while(false){ | |||
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.
Let's format this (maybe you have to do it manually).
| namespace maldoca { | ||
| void IfStatementElimination(mlir::Operation* root_op) { | ||
| root_op->walk([&](JshirIfStatementOp op) { | ||
| namespace maldoca |
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.
Could you try putting a clang-format config in the repo?
I found this: https://github.com/kehanXue/google-style-clang-format
| mlir::Region &test_region = op.getTest(); | ||
| if (test_region.empty()) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| auto expr_region_end_op = | ||
| llvm::dyn_cast<JsirExprRegionEndOp>(&test_region.front().back()); | ||
| if (expr_region_end_op == nullptr) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| auto condition_op = | ||
| expr_region_end_op.getOperand().getDefiningOp<JsirBooleanLiteralOp>(); | ||
| if (condition_op == nullptr) | ||
| { | ||
| 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.
GetExprRegionOp<JsirBooleanLiteralOp>(op.getTest())
| }); | ||
| } | ||
|
|
||
| struct SymbolInfo |
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.
Add comments that at least explain what inner and outer mean.
| if (llvm::isa<JsirExprsRegionEndOp>(op) || llvm::isa<JsirExprRegionEndOp>(op) ) { | ||
| 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.
// TODO: We can remove this special handling once the trivia is fixed.
| LOG(INFO) << "Warning: Symbol has references but no definitions: " | ||
| << symbol.name() << std::endl; |
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.
We should remove this log if this is not an error, otherwise it might spam the log.
| } | ||
| if (info.definitions.size() > 1) | ||
| { | ||
| LOG(INFO) << "Warning: Multiple definitions for symbol: " |
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 remind us why this happens?
Introduces a new WhileStatementElimination pass to the Dead Code Elimination framework. This pass identifies 'while' loops with a constantly false condition and removes them entirely.