|
76 | 76 |
|
77 | 77 | function compute_value_for_use(ir::IRCode, domtree::DomTree, allblocks::Vector{Int}, du::SSADefUse, phinodes::IdDict{Int, SSAValue}, fidx::Int, use_idx::Int)
|
78 | 78 | # Find the first dominating def
|
79 |
| - curblock = stmtblock = block_for_inst(ir.cfg, use_idx) |
80 |
| - curblock = find_curblock(domtree, allblocks, curblock) |
81 |
| - defblockdefs = let curblock = curblock |
82 |
| - Int[stmt for stmt in du.defs if block_for_inst(ir.cfg, stmt) == curblock] |
83 |
| - end |
84 |
| - def = 0 |
85 |
| - if !isempty(defblockdefs) |
86 |
| - if curblock != stmtblock |
87 |
| - # Find the last def in this block |
88 |
| - def = 0 |
89 |
| - for x in defblockdefs |
90 |
| - def = max(def, x) |
91 |
| - end |
92 |
| - else |
93 |
| - # Find the last def before our use |
94 |
| - def = 0 |
95 |
| - for x in defblockdefs |
96 |
| - def = max(def, x >= use_idx ? 0 : x) |
| 79 | + stmtblock = block_for_inst(ir.cfg, use_idx) |
| 80 | + curblock = find_curblock(domtree, allblocks, stmtblock) |
| 81 | + local def = 0 |
| 82 | + for idx in du.defs |
| 83 | + if block_for_inst(ir.cfg, idx) == curblock |
| 84 | + if curblock != stmtblock |
| 85 | + # Find the last def in this block |
| 86 | + def = max(def, idx) |
| 87 | + else |
| 88 | + # Find the last def before our use |
| 89 | + def = max(def, idx >= use_idx ? 0 : idx) |
97 | 90 | end
|
98 | 91 | end
|
99 | 92 | end
|
@@ -564,15 +557,10 @@ a result of dead code elimination.
|
564 | 557 | """
|
565 | 558 | function getfield_elim_pass!(ir::IRCode)
|
566 | 559 | compact = IncrementalCompact(ir)
|
567 |
| - insertions = Vector{Any}() |
568 | 560 | defuses = IdDict{Int, Tuple{IdSet{Int}, SSADefUse}}()
|
569 | 561 | lifting_cache = IdDict{Pair{AnySSAValue, Any}, AnySSAValue}()
|
570 |
| - revisit_worklist = Int[] |
571 |
| - #ndone, nmax = 0, 200 |
572 | 562 | for ((_, idx), stmt) in compact
|
573 | 563 | isa(stmt, Expr) || continue
|
574 |
| - #ndone >= nmax && continue |
575 |
| - #ndone += 1 |
576 | 564 | result_t = compact_exprtype(compact, SSAValue(idx))
|
577 | 565 | is_getfield = is_setfield = false
|
578 | 566 | field_ordering = :unspecified
|
@@ -998,8 +986,6 @@ function adce_pass!(ir::IRCode)
|
998 | 986 | end
|
999 | 987 |
|
1000 | 988 | function type_lift_pass!(ir::IRCode)
|
1001 |
| - type_ctx_uses = Vector{Vector{Int}}[] |
1002 |
| - has_non_type_ctx_uses = IdSet{Int}() |
1003 | 989 | lifted_undef = IdDict{Int, Any}()
|
1004 | 990 | insts = ir.stmts
|
1005 | 991 | for idx in 1:length(insts)
|
|
0 commit comments