@@ -17,29 +17,6 @@ using namespace mlir;
1717#include " NeuraDialect/NeuraPasses.h.inc"
1818
1919namespace {
20- LogicalResult promoteFunctionArgsToConstants (Region ®ion) {
21- if (region.empty ()) {
22- return success ();
23- }
24-
25- Block &entry_block = region.front ();
26- OpBuilder builder (&entry_block, entry_block.begin ());
27-
28- // Collects all function arguments.
29- SmallVector<BlockArgument, 4 > args (entry_block.getArguments ().begin (),
30- entry_block.getArguments ().end ());
31-
32- // Creates a constant operation for each function argument.
33- for (auto [idx, arg] : llvm::enumerate (args)) {
34- auto const_op = builder.create <neura::ConstantOp>(
35- arg.getLoc (), arg.getType (),
36- builder.getStringAttr (" \%arg" + std::to_string (idx)));
37- arg.replaceAllUsesWith (const_op.getResult ());
38- }
39-
40- return success ();
41- }
42-
4320LogicalResult promoteLiveInValuesToBlockArgs (Region ®ion) {
4421 if (region.empty ()) {
4522 return success ();
@@ -286,8 +263,8 @@ LogicalResult promoteLiveInValuesToBlockArgs(Region ®ion) {
286263 if (needs_update) {
287264 OpBuilder builder (cond_br_op);
288265 builder.create <neura::CondBr>(
289- cond_br_op.getLoc (), cond_br_op.getCondition (),
290- true_operands, false_operands, cond_br_op.getTrueDest (),
266+ cond_br_op.getLoc (), cond_br_op.getCondition (), true_operands,
267+ false_operands, cond_br_op.getTrueDest (),
291268 cond_br_op.getFalseDest ());
292269 cond_br_op.erase ();
293270 }
@@ -336,11 +313,6 @@ struct CanonicalizeLiveInPass
336313 return ;
337314 }
338315
339- if (failed (promoteFunctionArgsToConstants (*region))) {
340- signalPassFailure ();
341- return ;
342- }
343-
344316 if (failed (promoteLiveInValuesToBlockArgs (*region))) {
345317 signalPassFailure ();
346318 return ;
0 commit comments