lang: Borrow inputs in hot compiler paths
14cc6511bc76aa6c5d88c2315f884d1bc2b62bad95bbc0e42843898915ca66f2
Share instructions and values across register visitors, allocator scans, and instruction selection to avoid aggregate argument snapshots. Move the callee-class bitset into assignment. Use one target for dictionary probes and spill-cost updates. Fixed-point benchmarks use 2.91% fewer instructions for the 23 fixtures and 2.55% fewer for matched-source self-compilation. Assisted-by: Codex:gpt-6 Change-Id: I78ecf58fbdcf5744c6e29e2ab2eba429e3a8ed40
1 parent
ea59b123
lib/std/arch/rv64.rad
+1 -1
| 396 | 396 | // so the restore below reclaims no live storage. |
|
| 397 | 397 | let ralloc = try regalloc::allocate(func, &config, arena) catch { |
|
| 398 | 398 | restoreArena(arena, checkpoint); |
|
| 399 | 399 | throw Error::Allocation; |
|
| 400 | 400 | }; |
|
| 401 | - | try isel::selectFn(&mut generator.e, ralloc, func, layouts, arena) catch error { |
|
| 401 | + | try isel::selectFn(&mut generator.e, &ralloc, func, layouts, arena) catch error { |
|
| 402 | 402 | restoreArena(arena, checkpoint); |
|
| 403 | 403 | throw error; |
|
| 404 | 404 | }; |
|
| 405 | 405 | // Reclaim unused memory after instruction selection. |
|
| 406 | 406 | restoreArena(arena, checkpoint); |
lib/std/arch/rv64/isel.rad
+13 -13
| 90 | 90 | // Selector State // |
|
| 91 | 91 | //////////////////// |
|
| 92 | 92 | ||
| 93 | 93 | /// Instruction selector state. |
|
| 94 | 94 | /// |
|
| 95 | - | /// The emitter is passed to each selection function as a separate `&mut` |
|
| 96 | - | /// argument, because a record cannot hold a reference. |
|
| 95 | + | /// The state shares allocation tables throughout selection. Each selection |
|
| 96 | + | /// function receives the output emitter as a separate mutable argument. |
|
| 97 | 97 | export record Selector: Copy { |
|
| 98 | 98 | /// Register allocation result for the function being selected. |
|
| 99 | 99 | ralloc: regalloc::AllocResult, |
|
| 100 | 100 | /// Total stack frame size. |
|
| 101 | 101 | frameSize: i32, |
| 416 | 416 | observeArgs(o, func, c.target, c.args); |
|
| 417 | 417 | } |
|
| 418 | 418 | return true; |
|
| 419 | 419 | } |
|
| 420 | 420 | else => { |
|
| 421 | - | il::forEachReg(func, instr, o); |
|
| 421 | + | il::forEachReg(func, &instr, o); |
|
| 422 | 422 | return false; |
|
| 423 | 423 | } |
|
| 424 | 424 | } |
|
| 425 | 425 | return true; |
|
| 426 | 426 | } |
| 548 | 548 | meetArgs(x, func, c.target, c.args); |
|
| 549 | 549 | } |
|
| 550 | 550 | return true; |
|
| 551 | 551 | } |
|
| 552 | 552 | else => { |
|
| 553 | - | if let dst = il::instrDst(instr) { |
|
| 553 | + | if let dst = il::instrDst(&instr) { |
|
| 554 | 554 | update(x, dst, UNKNOWN); |
|
| 555 | 555 | } |
|
| 556 | 556 | } |
|
| 557 | 557 | } |
|
| 558 | 558 | return false; |
| 1079 | 1079 | func: *il::Fn, blockIdx: u32, index: u32, layouts: &[il::Layout], l: &il::Layout, reg: il::Reg |
|
| 1080 | 1080 | ) -> bool { |
|
| 1081 | 1081 | let instrs = func.blocks[blockIdx].instrs; |
|
| 1082 | 1082 | let mut at = index + 1; |
|
| 1083 | 1083 | while at < instrs.len and at <= index + ZERO_LOOKAHEAD { |
|
| 1084 | - | let instr = instrs[at]; |
|
| 1084 | + | let instr = &instrs[at]; |
|
| 1085 | 1085 | let mut uses = RegCount { reg, count: 0 }; |
|
| 1086 | 1086 | il::forEachReg(func, instr, &mut uses); |
|
| 1087 | 1087 | if uses.count > 0 { |
|
| 1088 | 1088 | let mut written: u64 = 0; |
|
| 1089 | - | match instr { |
|
| 1089 | + | match *instr { |
|
| 1090 | 1090 | case il::Instr::Blit { dst, layout, .. } => { |
|
| 1091 | 1091 | if dst.n == reg.n { |
|
| 1092 | 1092 | set written = layouts[layout].size as u64; |
|
| 1093 | 1093 | } |
|
| 1094 | 1094 | } |
| 1733 | 1733 | } |
|
| 1734 | 1734 | ||
| 1735 | 1735 | /// Select instructions for a function. |
|
| 1736 | 1736 | export fn selectFn( |
|
| 1737 | 1737 | e: &mut emit::Emitter, |
|
| 1738 | - | ralloc: regalloc::AllocResult, |
|
| 1738 | + | ralloc: ®alloc::AllocResult, |
|
| 1739 | 1739 | func: *il::Fn, |
|
| 1740 | 1740 | layouts: &[il::Layout], |
|
| 1741 | 1741 | arena: &heap::Heap |
|
| 1742 | 1742 | ) throws (super::Error) { |
|
| 1743 | 1743 | // Pre-scan the reserves to give them fixed frame slots. |
| 1769 | 1769 | try uses.counts.resize(count, 0, arena) catch { |
|
| 1770 | 1770 | throw super::Error::Allocation; |
|
| 1771 | 1771 | }; |
|
| 1772 | 1772 | for block in func.blocks { |
|
| 1773 | 1773 | for instr in block.instrs { |
|
| 1774 | - | il::forEachReg(func, instr, &mut uses); |
|
| 1774 | + | il::forEachReg(func, &instr, &mut uses); |
|
| 1775 | 1775 | } |
|
| 1776 | 1776 | } |
|
| 1777 | 1777 | // Conditional branches start in their short form. When one does not reach |
|
| 1778 | 1778 | // its target, the body is emitted again with that branch in its long form. |
|
| 1779 | 1779 | let start = emit::beginBody(e); |
| 1788 | 1788 | } |
|
| 1789 | 1789 | ||
| 1790 | 1790 | /// Emit the prologue, the blocks, and the epilogue of a function. |
|
| 1791 | 1791 | fn selectBody( |
|
| 1792 | 1792 | e: &mut emit::Emitter, |
|
| 1793 | - | ralloc: regalloc::AllocResult, |
|
| 1793 | + | ralloc: ®alloc::AllocResult, |
|
| 1794 | 1794 | exts: *[Extension], |
|
| 1795 | 1795 | observed: *[bool], |
|
| 1796 | 1796 | uses: &[u32], |
|
| 1797 | 1797 | func: *il::Fn, |
|
| 1798 | 1798 | layouts: &[il::Layout], |
| 1800 | 1800 | ) throws (super::Error) { |
|
| 1801 | 1801 | // Reset block offsets for this function. |
|
| 1802 | 1802 | labels::resetBlocks(&mut e.labels); |
|
| 1803 | 1803 | // Synthetic block indices start after real blocks and the epilogue block. |
|
| 1804 | 1804 | let mut s = Selector { |
|
| 1805 | - | ralloc, |
|
| 1805 | + | ralloc: *ralloc, |
|
| 1806 | 1806 | frameSize: frame.totalSize, |
|
| 1807 | 1807 | reserveOffset: 0, |
|
| 1808 | 1808 | pendingSpill: nil, |
|
| 1809 | 1809 | instrIndex: 0, |
|
| 1810 | 1810 | nextSynthBlock: func.blocks.len + 1, |
| 1885 | 1885 | set s.instrIndex = i; |
|
| 1886 | 1886 | if let combined = combination(&block.instrs[i ..], uses) { |
|
| 1887 | 1887 | try selectCombined(s, e, &combined); |
|
| 1888 | 1888 | set skip = combined.count - 1; |
|
| 1889 | 1889 | } else { |
|
| 1890 | - | try selectInstr(s, e, blockIdx, instr, frame, func, layouts); |
|
| 1890 | + | try selectInstr(s, e, blockIdx, &instr, frame, func, layouts); |
|
| 1891 | 1891 | } |
|
| 1892 | 1892 | // Flush the pending spill store, if any. |
|
| 1893 | 1893 | if let p = s.pendingSpill { |
|
| 1894 | 1894 | if let slot = regalloc::spill::spillSlot(&s.ralloc.spill, p.ssa) { |
|
| 1895 | 1895 | try emit::emitSd(e, p.rd, super::SP, spillOffset(s, slot)); |
| 1902 | 1902 | /// Select instructions for a single IL instruction. |
|
| 1903 | 1903 | fn selectInstr( |
|
| 1904 | 1904 | s: &mut Selector, |
|
| 1905 | 1905 | e: &mut emit::Emitter, |
|
| 1906 | 1906 | blockIdx: u32, |
|
| 1907 | - | instr: il::Instr, |
|
| 1907 | + | instr: &il::Instr, |
|
| 1908 | 1908 | frame: &emit::Frame, |
|
| 1909 | 1909 | func: *il::Fn, |
|
| 1910 | 1910 | layouts: &[il::Layout] |
|
| 1911 | 1911 | ) throws (super::Error) { |
|
| 1912 | - | match instr { |
|
| 1912 | + | match *instr { |
|
| 1913 | 1913 | case il::Instr::BinOp { op, typ, dst, a, b } => { |
|
| 1914 | 1914 | let rd = getDstReg(s, dst, super::SCRATCH1); |
|
| 1915 | 1915 | let rs1 = try resolveVal(s, e, super::SCRATCH1, a); |
|
| 1916 | 1916 | try selectAluBinOp(s, e, op, typ, rd, rs1, a, b); |
|
| 1917 | 1917 | } |
lib/std/arch/rv64/tests/bounds.rad
+5 -5
| 1475 | 1475 | let mut i = block.instrs.len; |
|
| 1476 | 1476 | while i > 0 { |
|
| 1477 | 1477 | set i -= 1; |
|
| 1478 | 1478 | let instr = block.instrs[i]; |
|
| 1479 | 1479 | bitset::copy(&mut tmp, &cur); |
|
| 1480 | - | if let dst = il::instrDst(instr) { |
|
| 1480 | + | if let dst = il::instrDst(&instr) { |
|
| 1481 | 1481 | bitset::put(&mut tmp, dst.n); |
|
| 1482 | 1482 | } |
|
| 1483 | 1483 | set bad += conflicts(&tmp, r, 0); |
|
| 1484 | - | if il::isCall(instr) { |
|
| 1484 | + | if il::isCall(&instr) { |
|
| 1485 | 1485 | bitset::copy(&mut tmp, &cur); |
|
| 1486 | - | if let dst = il::instrDst(instr) { |
|
| 1486 | + | if let dst = il::instrDst(&instr) { |
|
| 1487 | 1487 | bitset::clear(&mut tmp, dst.n); |
|
| 1488 | 1488 | } |
|
| 1489 | 1489 | set bad += conflicts(&tmp, r, calleeSaved); |
|
| 1490 | 1490 | } |
|
| 1491 | - | if let dst = il::instrDst(instr) { |
|
| 1491 | + | if let dst = il::instrDst(&instr) { |
|
| 1492 | 1492 | bitset::clear(&mut cur, dst.n); |
|
| 1493 | 1493 | } |
|
| 1494 | - | il::forEachReg(func, instr, &mut cur); |
|
| 1494 | + | il::forEachReg(func, &instr, &mut cur); |
|
| 1495 | 1495 | bitset::copy(&mut tmp, &cur); |
|
| 1496 | 1496 | set bad += conflicts(&tmp, r, 0); |
|
| 1497 | 1497 | } |
|
| 1498 | 1498 | bitset::copy(&mut tmp, &cur); |
|
| 1499 | 1499 | for p in block.params { |
lib/std/collections/dict.rad
+9 -8
| 58 | 58 | ||
| 59 | 59 | /// Insert or update a key-value pair. Throws if the table exceeds 50% load. |
|
| 60 | 60 | /// The key must not be empty. |
|
| 61 | 61 | export fn insert(m: &mut Dict, key: *[u8], value: i32) throws (Error) { |
|
| 62 | 62 | let mask = m.entries.len - 1; |
|
| 63 | + | let limit = m.entries.len / 2; |
|
| 63 | 64 | let mut idx = hash(key) & mask; |
|
| 64 | 65 | ||
| 65 | 66 | loop { |
|
| 66 | - | // Copy the key pointer out of the slot, so that no loan on the entries |
|
| 67 | - | // is live across the writes below. |
|
| 68 | - | let slotKey = m.entries[idx].key; |
|
| 69 | - | if slotKey.len == 0 { |
|
| 70 | - | if m.count >= m.entries.len / 2 { |
|
| 67 | + | // The selected entry stays borrowed for this probe. The count is |
|
| 68 | + | // stored in a separate field. |
|
| 69 | + | let entry = &mut m.entries[idx]; |
|
| 70 | + | if entry.key.len == 0 { |
|
| 71 | + | if m.count >= limit { |
|
| 71 | 72 | throw Error::Capacity; |
|
| 72 | 73 | } |
|
| 73 | - | set m.entries[idx] = Entry { key, value }; |
|
| 74 | + | set *entry = Entry { key, value }; |
|
| 74 | 75 | set m.count += 1; |
|
| 75 | 76 | return; |
|
| 76 | 77 | } |
|
| 77 | - | if mem::eq(slotKey, key) { |
|
| 78 | - | set m.entries[idx].value = value; |
|
| 78 | + | if mem::eq(entry.key, key) { |
|
| 79 | + | set entry.value = value; |
|
| 79 | 80 | return; |
|
| 80 | 81 | } |
|
| 81 | 82 | set idx = (idx + 1) & mask; |
|
| 82 | 83 | } |
|
| 83 | 84 | } |
lib/std/lang/gen/regalloc.rad
+4 -3
| 16 | 16 | ||
| 17 | 17 | export mod liveness; |
|
| 18 | 18 | export mod spill; |
|
| 19 | 19 | export mod assign; |
|
| 20 | 20 | ||
| 21 | - | use std::lang::il; |
|
| 22 | 21 | use std::lang::alloc; |
|
| 22 | + | use std::lang::il; |
|
| 23 | 23 | use std::mem::heap; |
|
| 24 | 24 | ||
| 25 | 25 | /// Target configuration for register allocation. |
|
| 26 | 26 | export record TargetConfig: Copy { |
|
| 27 | 27 | /// List of allocatable physical registers. |
| 59 | 59 | // Phase 2: Spill analysis (determine which values need stack slots). |
|
| 60 | 60 | let spills = try spill::analyze( |
|
| 61 | 61 | func, &live, config.allocatable.len, config.calleeSaved.len, config.slotSize, a |
|
| 62 | 62 | ); |
|
| 63 | 63 | // Phase 3: Register assignment (map SSA registers to physical registers). |
|
| 64 | - | let assignInfo = try assign::assign(func, &live, &spills, config, a); |
|
| 64 | + | let spillInfo = spills.info; |
|
| 65 | + | let assignInfo = try assign::assign(func, &live, spills, config, a); |
|
| 65 | 66 | ||
| 66 | 67 | return AllocResult { |
|
| 67 | 68 | assignments: assignInfo.assignments, |
|
| 68 | - | spill: spills.info, |
|
| 69 | + | spill: spillInfo, |
|
| 69 | 70 | usedCalleeSaved: assignInfo.usedCalleeSaved, |
|
| 70 | 71 | }; |
|
| 71 | 72 | } |
lib/std/lang/gen/regalloc/assign.rad
+10 -10
| 88 | 88 | /// Compute register assignment. |
|
| 89 | 89 | /// The assignment arrays and sets are allocated from `a`. |
|
| 90 | 90 | export fn assign( |
|
| 91 | 91 | func: *il::Fn, |
|
| 92 | 92 | live: &liveness::LiveInfo, |
|
| 93 | - | spills: &spill::SpillResult, |
|
| 93 | + | spills: spill::SpillResult, |
|
| 94 | 94 | config: &super::TargetConfig, |
|
| 95 | 95 | a: &heap::Heap |
|
| 96 | 96 | ) -> AssignInfo throws (alloc::AllocError) { |
|
| 97 | 97 | let maxReg = live.maxReg; |
|
| 98 | 98 | let blockCount = func.blocks.len; |
| 121 | 121 | } |
|
| 122 | 122 | } |
|
| 123 | 123 | } |
|
| 124 | 124 | // Allocate used registers bitset (32 physical registers per 32-bit word). |
|
| 125 | 125 | let usedRegs = try bitset::allocate(a, rv64::NUM_REGISTERS as u32); |
|
| 126 | - | // Copy the callee-class set, which the assignment state keeps for the whole function. |
|
| 127 | - | let mut crossCall = try bitset::allocate(a, maxReg); |
|
| 128 | - | bitset::copy(&mut crossCall, &spills.calleeClass); |
|
| 126 | + | // The assignment state keeps the callee-class set for the whole function. |
|
| 127 | + | let case spill::SpillResult { info: spillInfo, calleeClass } = spills |
|
| 128 | + | else panic "assign: spill result required"; |
|
| 129 | 129 | ||
| 130 | 130 | let mut params = try bitset::allocate(a, maxReg); |
|
| 131 | 131 | for param in func.params { |
|
| 132 | 132 | bitset::put(&mut params, param.value.n); |
|
| 133 | 133 | } |
|
| 134 | 134 | let mut ctx = AssignCtx { |
|
| 135 | 135 | current: RegMap { virtRegs: [0; MAX_ACTIVE], physRegs: [gen::Reg(0); MAX_ACTIVE], n: 0 }, |
|
| 136 | 136 | usedRegs, |
|
| 137 | - | crossCall, |
|
| 137 | + | crossCall: calleeClass, |
|
| 138 | 138 | params, |
|
| 139 | 139 | lastUse: LastUse { indices: lastUseIndices, index: 0 }, |
|
| 140 | 140 | assignments, |
|
| 141 | 141 | liveOut: live.liveOut, |
|
| 142 | - | spillInfo: spills.info, |
|
| 142 | + | spillInfo, |
|
| 143 | 143 | allocatable, |
|
| 144 | 144 | calleeSaved: config.calleeSaved, |
|
| 145 | 145 | blockIdx: 0, |
|
| 146 | 146 | instrIdx: 0, |
|
| 147 | 147 | exhausted: false, |
| 160 | 160 | // marked as unused, so that their registers are free again at once. |
|
| 161 | 161 | for p in block.params { |
|
| 162 | 162 | set ctx.lastUse.indices[p.value.n] = NO_USE; |
|
| 163 | 163 | } |
|
| 164 | 164 | for instr in block.instrs { |
|
| 165 | - | if let dst = il::instrDst(instr) { |
|
| 165 | + | if let dst = il::instrDst(&instr) { |
|
| 166 | 166 | set ctx.lastUse.indices[dst.n] = NO_USE; |
|
| 167 | 167 | } |
|
| 168 | 168 | } |
|
| 169 | 169 | for instr, i in block.instrs { |
|
| 170 | 170 | set ctx.lastUse.index = i; |
|
| 171 | - | il::forEachReg(func, instr, &mut ctx.lastUse); |
|
| 171 | + | il::forEachReg(func, &instr, &mut ctx.lastUse); |
|
| 172 | 172 | } |
|
| 173 | 173 | // Reset for new block. |
|
| 174 | 174 | set ctx.current.n = 0; |
|
| 175 | 175 | set ctx.blockIdx = b; |
|
| 176 | 176 | bitset::clearAll(&mut ctx.usedRegs); |
| 212 | 212 | } |
|
| 213 | 213 | } |
|
| 214 | 214 | // Process each instruction. |
|
| 215 | 215 | for instr, i in block.instrs { |
|
| 216 | 216 | set ctx.instrIdx = i; |
|
| 217 | - | il::forEachReg(func, instr, &mut ctx); |
|
| 217 | + | il::forEachReg(func, &instr, &mut ctx); |
|
| 218 | 218 | if ctx.exhausted { |
|
| 219 | 219 | throw alloc::AllocError::OutOfMemory; |
|
| 220 | 220 | } |
|
| 221 | 221 | // Allocate destination. |
|
| 222 | - | if let dst = il::instrDst(instr) { |
|
| 222 | + | if let dst = il::instrDst(&instr) { |
|
| 223 | 223 | if dst.n < maxReg and not spill::isSpilled(&ctx.spillInfo, dst) { |
|
| 224 | 224 | set ctx.assignments[dst.n] = try allocateDef(&mut ctx, dst.n); |
|
| 225 | 225 | // A result that nothing uses must not hold its register. |
|
| 226 | 226 | if isUnused(&ctx, dst.n) { |
|
| 227 | 227 | releaseReg(&mut ctx, dst.n); |
lib/std/lang/gen/regalloc/liveness.rad
+5 -5
| 98 | 98 | let block = &func.blocks[b]; |
|
| 99 | 99 | for p in block.params { |
|
| 100 | 100 | countRegister(p.value, &mut counter); |
|
| 101 | 101 | } |
|
| 102 | 102 | for instr in block.instrs { |
|
| 103 | - | il::forEachReg(func, instr, &mut counter); |
|
| 104 | - | if let dst = il::instrDst(instr) { |
|
| 103 | + | il::forEachReg(func, &instr, &mut counter); |
|
| 104 | + | if let dst = il::instrDst(&instr) { |
|
| 105 | 105 | countRegister(dst, &mut counter); |
|
| 106 | 106 | } |
|
| 107 | 107 | } |
|
| 108 | 108 | } |
|
| 109 | 109 | if counter.count > MAX_SSA_REGS as u64 { |
| 252 | 252 | fn computeLocalDefsUses(func: *il::Fn, block: *il::Block, sets: &mut DefsUses) { |
|
| 253 | 253 | for p in block.params { |
|
| 254 | 254 | bitset::put(&mut sets.defs[sets.block], p.value.n); |
|
| 255 | 255 | } |
|
| 256 | 256 | for instr in block.instrs { |
|
| 257 | - | il::forEachReg(func, instr, sets); |
|
| 257 | + | il::forEachReg(func, &instr, sets); |
|
| 258 | 258 | ||
| 259 | - | if let dst = il::instrDst(instr) { |
|
| 259 | + | if let dst = il::instrDst(&instr) { |
|
| 260 | 260 | bitset::put(&mut sets.defs[sets.block], dst.n); |
|
| 261 | 261 | } |
|
| 262 | 262 | } |
|
| 263 | 263 | } |
|
| 264 | 264 |
| 304 | 304 | ||
| 305 | 305 | if bitset::contains(&info.liveOut[blockIdx], reg.n) { |
|
| 306 | 306 | return true; |
|
| 307 | 307 | } |
|
| 308 | 308 | for i in instrIdx + 1 .. block.instrs.len { |
|
| 309 | - | if il::usesReg(func, block.instrs[i], reg) { |
|
| 309 | + | if il::usesReg(func, &block.instrs[i], reg) { |
|
| 310 | 310 | return true; |
|
| 311 | 311 | } |
|
| 312 | 312 | } |
|
| 313 | 313 | return false; |
|
| 314 | 314 | } |
lib/std/lang/gen/regalloc/spill.rad
+8 -10
| 133 | 133 | ||
| 134 | 134 | // Walk instructions backwards. |
|
| 135 | 135 | let mut i = block.instrs.len; |
|
| 136 | 136 | while i > 0 { |
|
| 137 | 137 | set i -= 1; |
|
| 138 | - | let instr = block.instrs[i]; |
|
| 138 | + | let instr = &block.instrs[i]; |
|
| 139 | 139 | ||
| 140 | 140 | // Limit register pressure before processing this instruction. A result that |
|
| 141 | 141 | // nothing uses is not in the live set, but it needs a register while the |
|
| 142 | 142 | // instruction runs, so one register stays free for it. |
|
| 143 | 143 | let mut limit = numRegs; |
| 195 | 195 | if bitset::contains(&walk.active, p.value.n) { |
|
| 196 | 196 | set bound += 1; |
|
| 197 | 197 | } |
|
| 198 | 198 | } |
|
| 199 | 199 | for instr in block.instrs { |
|
| 200 | - | if let dst = il::instrDst(instr) { |
|
| 200 | + | if let dst = il::instrDst(&instr) { |
|
| 201 | 201 | if bitset::contains(&walk.active, dst.n) { |
|
| 202 | 202 | set bound += 1; |
|
| 203 | 203 | } |
|
| 204 | 204 | } |
|
| 205 | 205 | } |
| 216 | 216 | } |
|
| 217 | 217 | } |
|
| 218 | 218 | let mut i = block.instrs.len; |
|
| 219 | 219 | while i > 0 { |
|
| 220 | 220 | set i -= 1; |
|
| 221 | - | let instr = block.instrs[i]; |
|
| 221 | + | let instr = &block.instrs[i]; |
|
| 222 | 222 | limitClassPressure(&mut walk, &mut spilled, &counts.costs[..], numCalleeSaved); |
|
| 223 | 223 | if let dst = il::instrDst(instr) { |
|
| 224 | 224 | if bitset::contains(&walk.live, dst.n) { |
|
| 225 | 225 | bitset::clear(&mut walk.live, dst.n); |
|
| 226 | 226 | set walk.count -= 1; |
| 261 | 261 | set counts.weight = weight; |
|
| 262 | 262 | ||
| 263 | 263 | // Count block parameter definitions. |
|
| 264 | 264 | for p in block.params { |
|
| 265 | 265 | if p.value.n < counts.costs.len { |
|
| 266 | - | set counts.costs[p.value.n].defs = counts.costs[p.value.n].defs + weight; |
|
| 266 | + | set counts.costs[p.value.n].defs += weight; |
|
| 267 | 267 | } |
|
| 268 | 268 | } |
|
| 269 | 269 | // Count instruction defs and uses. |
|
| 270 | - | for i in 0 .. block.instrs.len { |
|
| 271 | - | let instr = block.instrs[i]; |
|
| 272 | - | ||
| 270 | + | for instr in block.instrs { |
|
| 273 | 271 | // Count definition. |
|
| 274 | - | if let dst = il::instrDst(instr) { |
|
| 272 | + | if let dst = il::instrDst(&instr) { |
|
| 275 | 273 | if dst.n < counts.costs.len { |
|
| 276 | - | set counts.costs[dst.n].defs = counts.costs[dst.n].defs + weight; |
|
| 274 | + | set counts.costs[dst.n].defs += weight; |
|
| 277 | 275 | } |
|
| 278 | 276 | } |
|
| 279 | 277 | // Count uses. |
|
| 280 | - | il::forEachReg(func, instr, counts); |
|
| 278 | + | il::forEachReg(func, &instr, counts); |
|
| 281 | 279 | } |
|
| 282 | 280 | } |
|
| 283 | 281 | } |
|
| 284 | 282 | ||
| 285 | 283 | instance il::RegVisitor for CountCtx { |
lib/std/lang/il.rad
+57 -57
| 1049 | 1049 | /// Kernel operation behind `page.heap`. a0 is a Page handle. Success returns the address of |
|
| 1050 | 1050 | /// the heap in a0. Failure returns a negative error in a0. |
|
| 1051 | 1051 | export constant PAGE_HEAP: u32 = 33; |
|
| 1052 | 1052 | ||
| 1053 | 1053 | /// Get the destination register of an instruction, if any. |
|
| 1054 | - | export fn instrDst(instr: Instr) -> ?Reg { |
|
| 1055 | - | match instr { |
|
| 1054 | + | export fn instrDst(instr: &Instr) -> ?Reg { |
|
| 1055 | + | match *instr { |
|
| 1056 | 1056 | case Instr::Reserve { dst, .. } => return dst, |
|
| 1057 | 1057 | case Instr::Load { dst, .. } => return dst, |
|
| 1058 | 1058 | case Instr::Sload { dst, .. } => return dst, |
|
| 1059 | 1059 | case Instr::Copy { dst, .. } => return dst, |
|
| 1060 | 1060 | case Instr::Field { dst, .. } => return dst, |
| 1076 | 1076 | else => return nil, |
|
| 1077 | 1077 | } |
|
| 1078 | 1078 | } |
|
| 1079 | 1079 | ||
| 1080 | 1080 | /// Check if an instruction is a function call. |
|
| 1081 | - | export fn isCall(instr: Instr) -> bool { |
|
| 1081 | + | export fn isCall(instr: &Instr) -> bool { |
|
| 1082 | 1082 | match instr { |
|
| 1083 | 1083 | case |
|
| 1084 | 1084 | Instr::Call { .. }, |
|
| 1085 | 1085 | Instr::TraitCall { .. }, |
|
| 1086 | 1086 | Instr::Ecall { .. }, |
| 1091 | 1091 | else => return false, |
|
| 1092 | 1092 | } |
|
| 1093 | 1093 | } |
|
| 1094 | 1094 | ||
| 1095 | 1095 | /// Check if an instruction ends a block. |
|
| 1096 | - | export fn isTerminator(instr: Instr) -> bool { |
|
| 1096 | + | export fn isTerminator(instr: &Instr) -> bool { |
|
| 1097 | 1097 | match instr { |
|
| 1098 | 1098 | case |
|
| 1099 | 1099 | Instr::Ret { .. }, |
|
| 1100 | 1100 | Instr::Jmp { .. }, |
|
| 1101 | 1101 | Instr::Br { .. }, |
| 1158 | 1158 | fn (&mut RegVisitor) visit(reg: Reg); |
|
| 1159 | 1159 | } |
|
| 1160 | 1160 | ||
| 1161 | 1161 | /// Visit each register used by an instruction of `func`, in operand order. |
|
| 1162 | 1162 | /// This is called by the register allocator to analyze register usage. |
|
| 1163 | - | export fn forEachReg(func: &Fn, instr: Instr, visitor: &mut opaque RegVisitor) { |
|
| 1164 | - | match instr { |
|
| 1163 | + | export fn forEachReg(func: &Fn, instr: &Instr, visitor: &mut opaque RegVisitor) { |
|
| 1164 | + | match *instr { |
|
| 1165 | 1165 | case Instr::Reserve { .. } => {} |
|
| 1166 | 1166 | case Instr::Load { src, .. } => visitor.visit(src), |
|
| 1167 | 1167 | case Instr::Sload { src, .. } => visitor.visit(src), |
|
| 1168 | 1168 | case Instr::Store { src, dst, .. } => { |
|
| 1169 | - | withReg(src, visitor); |
|
| 1169 | + | withReg(&src, visitor); |
|
| 1170 | 1170 | visitor.visit(dst); |
|
| 1171 | 1171 | } |
|
| 1172 | 1172 | case Instr::Blit { dst, src, .. } => { |
|
| 1173 | 1173 | visitor.visit(dst); |
|
| 1174 | 1174 | visitor.visit(src); |
|
| 1175 | 1175 | } |
|
| 1176 | 1176 | case Instr::Copy { val, .. } => |
|
| 1177 | - | withReg(val, visitor), |
|
| 1177 | + | withReg(&val, visitor), |
|
| 1178 | 1178 | case Instr::Field { src, .. } => visitor.visit(src), |
|
| 1179 | 1179 | case Instr::Elem { base, index, .. } => { |
|
| 1180 | 1180 | visitor.visit(base); |
|
| 1181 | - | withReg(index, visitor); |
|
| 1181 | + | withReg(&index, visitor); |
|
| 1182 | 1182 | } |
|
| 1183 | 1183 | case Instr::SliceElem { slice, index, .. } => { |
|
| 1184 | 1184 | visitor.visit(slice); |
|
| 1185 | - | withReg(index, visitor); |
|
| 1185 | + | withReg(&index, visitor); |
|
| 1186 | 1186 | } |
|
| 1187 | 1187 | case Instr::BytesLoad { slice, offset, .. } => { |
|
| 1188 | 1188 | visitor.visit(slice); |
|
| 1189 | - | withReg(offset, visitor); |
|
| 1189 | + | withReg(&offset, visitor); |
|
| 1190 | 1190 | } |
|
| 1191 | 1191 | case Instr::BytesStore { slice, offset, value, .. } => { |
|
| 1192 | 1192 | visitor.visit(slice); |
|
| 1193 | - | withReg(offset, visitor); |
|
| 1194 | - | withReg(value, visitor); |
|
| 1193 | + | withReg(&offset, visitor); |
|
| 1194 | + | withReg(&value, visitor); |
|
| 1195 | 1195 | } |
|
| 1196 | 1196 | case Instr::SliceNew { dst, base, start, end, .. } => { |
|
| 1197 | 1197 | visitor.visit(dst); |
|
| 1198 | - | withReg(base, visitor); |
|
| 1199 | - | withReg(start, visitor); |
|
| 1200 | - | withReg(end, visitor); |
|
| 1198 | + | withReg(&base, visitor); |
|
| 1199 | + | withReg(&start, visitor); |
|
| 1200 | + | withReg(&end, visitor); |
|
| 1201 | 1201 | } |
|
| 1202 | 1202 | case Instr::SliceSub { dst, src, start, end, .. } => { |
|
| 1203 | 1203 | visitor.visit(dst); |
|
| 1204 | 1204 | visitor.visit(src); |
|
| 1205 | - | withReg(start, visitor); |
|
| 1206 | - | withReg(end, visitor); |
|
| 1205 | + | withReg(&start, visitor); |
|
| 1206 | + | withReg(&end, visitor); |
|
| 1207 | 1207 | } |
|
| 1208 | 1208 | case Instr::SliceLen { dst, length, .. } => { |
|
| 1209 | 1209 | visitor.visit(dst); |
|
| 1210 | - | withReg(length, visitor); |
|
| 1210 | + | withReg(&length, visitor); |
|
| 1211 | 1211 | } |
|
| 1212 | 1212 | case Instr::SliceCopy { dst, src, .. } => { |
|
| 1213 | 1213 | visitor.visit(dst); |
|
| 1214 | 1214 | visitor.visit(src); |
|
| 1215 | 1215 | } |
|
| 1216 | 1216 | case Instr::SliceGrow { slice, heap, capacity, .. } => { |
|
| 1217 | 1217 | visitor.visit(slice); |
|
| 1218 | - | withReg(heap, visitor); |
|
| 1219 | - | withReg(capacity, visitor); |
|
| 1218 | + | withReg(&heap, visitor); |
|
| 1219 | + | withReg(&capacity, visitor); |
|
| 1220 | 1220 | } |
|
| 1221 | 1221 | case Instr::LoadPtr { src, .. } => visitor.visit(src), |
|
| 1222 | 1222 | case Instr::StorePtr { src, dst, .. } => { |
|
| 1223 | - | withReg(src, visitor); |
|
| 1223 | + | withReg(&src, visitor); |
|
| 1224 | 1224 | visitor.visit(dst); |
|
| 1225 | 1225 | } |
|
| 1226 | 1226 | case Instr::TraitNew { dst, recv, table } => { |
|
| 1227 | 1227 | visitor.visit(dst); |
|
| 1228 | 1228 | visitor.visit(recv); |
|
| 1229 | - | withReg(table, visitor); |
|
| 1229 | + | withReg(&table, visitor); |
|
| 1230 | 1230 | } |
|
| 1231 | 1231 | case Instr::TraitCopy { dst, src } => { |
|
| 1232 | 1232 | visitor.visit(dst); |
|
| 1233 | 1233 | visitor.visit(src); |
|
| 1234 | 1234 | } |
| 1236 | 1236 | visitor.visit(dst); |
|
| 1237 | 1237 | visitor.visit(src); |
|
| 1238 | 1238 | } |
|
| 1239 | 1239 | case Instr::UnionSet { dst, src, .. } => { |
|
| 1240 | 1240 | visitor.visit(dst); |
|
| 1241 | - | withReg(src, visitor); |
|
| 1241 | + | withReg(&src, visitor); |
|
| 1242 | 1242 | } |
|
| 1243 | 1243 | case Instr::TraitCall { obj, args, .. } => { |
|
| 1244 | 1244 | visitor.visit(obj); |
|
| 1245 | 1245 | for arg in argVals(func, args) { |
|
| 1246 | - | withReg(arg, visitor); |
|
| 1246 | + | withReg(&arg, visitor); |
|
| 1247 | 1247 | } |
|
| 1248 | 1248 | } |
|
| 1249 | 1249 | case Instr::BinOp { a, b, .. } => { |
|
| 1250 | - | withReg(a, visitor); |
|
| 1251 | - | withReg(b, visitor); |
|
| 1250 | + | withReg(&a, visitor); |
|
| 1251 | + | withReg(&b, visitor); |
|
| 1252 | 1252 | } |
|
| 1253 | 1253 | case Instr::UnOp { a, .. } => |
|
| 1254 | - | withReg(a, visitor), |
|
| 1254 | + | withReg(&a, visitor), |
|
| 1255 | 1255 | case Instr::Zext { val, .. } => |
|
| 1256 | - | withReg(val, visitor), |
|
| 1256 | + | withReg(&val, visitor), |
|
| 1257 | 1257 | case Instr::Sext { val, .. } => |
|
| 1258 | - | withReg(val, visitor), |
|
| 1258 | + | withReg(&val, visitor), |
|
| 1259 | 1259 | case Instr::Call { func: callee, args, .. } => { |
|
| 1260 | - | withReg(callee, visitor); |
|
| 1260 | + | withReg(&callee, visitor); |
|
| 1261 | 1261 | for arg in argVals(func, args) { |
|
| 1262 | - | withReg(arg, visitor); |
|
| 1262 | + | withReg(&arg, visitor); |
|
| 1263 | 1263 | } |
|
| 1264 | 1264 | } |
|
| 1265 | 1265 | case Instr::Ret { val } => { |
|
| 1266 | 1266 | if let v = val { |
|
| 1267 | - | withReg(v, visitor); |
|
| 1267 | + | withReg(&v, visitor); |
|
| 1268 | 1268 | } |
|
| 1269 | 1269 | } |
|
| 1270 | 1270 | case Instr::Jmp { args, .. } => { |
|
| 1271 | 1271 | for arg in argVals(func, args) { |
|
| 1272 | - | withReg(arg, visitor); |
|
| 1272 | + | withReg(&arg, visitor); |
|
| 1273 | 1273 | } |
|
| 1274 | 1274 | } |
|
| 1275 | 1275 | case Instr::Br { a, b, thenArgs, elseArgs, .. } => { |
|
| 1276 | - | withReg(a, visitor); |
|
| 1277 | - | withReg(b, visitor); |
|
| 1276 | + | withReg(&a, visitor); |
|
| 1277 | + | withReg(&b, visitor); |
|
| 1278 | 1278 | for arg in argVals(func, thenArgs) { |
|
| 1279 | - | withReg(arg, visitor); |
|
| 1279 | + | withReg(&arg, visitor); |
|
| 1280 | 1280 | } |
|
| 1281 | 1281 | for arg in argVals(func, elseArgs) { |
|
| 1282 | - | withReg(arg, visitor); |
|
| 1282 | + | withReg(&arg, visitor); |
|
| 1283 | 1283 | } |
|
| 1284 | 1284 | } |
|
| 1285 | 1285 | case Instr::Switch { val, defaultArgs, cases, .. } => { |
|
| 1286 | - | withReg(val, visitor); |
|
| 1286 | + | withReg(&val, visitor); |
|
| 1287 | 1287 | for arg in argVals(func, defaultArgs) { |
|
| 1288 | - | withReg(arg, visitor); |
|
| 1288 | + | withReg(&arg, visitor); |
|
| 1289 | 1289 | } |
|
| 1290 | 1290 | for c in switchCases(func, cases) { |
|
| 1291 | 1291 | for arg in argVals(func, c.args) { |
|
| 1292 | - | withReg(arg, visitor); |
|
| 1292 | + | withReg(&arg, visitor); |
|
| 1293 | 1293 | } |
|
| 1294 | 1294 | } |
|
| 1295 | 1295 | } |
|
| 1296 | 1296 | case Instr::Ecall { num, a0, a1, a2, a3, buf, .. } => { |
|
| 1297 | - | withReg(num, visitor); |
|
| 1298 | - | withReg(a0, visitor); |
|
| 1299 | - | withReg(a1, visitor); |
|
| 1300 | - | withReg(a2, visitor); |
|
| 1301 | - | withReg(a3, visitor); |
|
| 1297 | + | withReg(&num, visitor); |
|
| 1298 | + | withReg(&a0, visitor); |
|
| 1299 | + | withReg(&a1, visitor); |
|
| 1300 | + | withReg(&a2, visitor); |
|
| 1301 | + | withReg(&a3, visitor); |
|
| 1302 | 1302 | if let b = buf { |
|
| 1303 | 1303 | visitor.visit(b.ptr); |
|
| 1304 | 1304 | } |
|
| 1305 | 1305 | } |
|
| 1306 | 1306 | case Instr::PageSlice { slot, handle, .. } => { |
|
| 1307 | 1307 | visitor.visit(slot); |
|
| 1308 | - | withReg(handle, visitor); |
|
| 1308 | + | withReg(&handle, visitor); |
|
| 1309 | 1309 | } |
|
| 1310 | 1310 | case Instr::PageHeap { slot, handle, .. } => { |
|
| 1311 | 1311 | visitor.visit(slot); |
|
| 1312 | - | withReg(handle, visitor); |
|
| 1312 | + | withReg(&handle, visitor); |
|
| 1313 | 1313 | } |
|
| 1314 | - | case Instr::HeapReset { heap } => withReg(heap, visitor), |
|
| 1314 | + | case Instr::HeapReset { heap } => withReg(&heap, visitor), |
|
| 1315 | 1315 | case Instr::DeviceRead { handle, offset, .. } => { |
|
| 1316 | - | withReg(handle, visitor); |
|
| 1317 | - | withReg(offset, visitor); |
|
| 1316 | + | withReg(&handle, visitor); |
|
| 1317 | + | withReg(&offset, visitor); |
|
| 1318 | 1318 | } |
|
| 1319 | 1319 | case Instr::DeviceWrite { handle, offset, value, .. } => { |
|
| 1320 | - | withReg(handle, visitor); |
|
| 1321 | - | withReg(offset, visitor); |
|
| 1322 | - | withReg(value, visitor); |
|
| 1320 | + | withReg(&handle, visitor); |
|
| 1321 | + | withReg(&offset, visitor); |
|
| 1322 | + | withReg(&value, visitor); |
|
| 1323 | 1323 | } |
|
| 1324 | 1324 | case Instr::Unreachable, Instr::Ebreak, Instr::MemoryFence => {} |
|
| 1325 | 1325 | } |
|
| 1326 | 1326 | } |
|
| 1327 | 1327 | ||
| 1328 | 1328 | /// Visit the value if it is a register. |
|
| 1329 | - | fn withReg(val: Val, visitor: &mut opaque RegVisitor) { |
|
| 1330 | - | if let case Val::Reg(r) = val { |
|
| 1329 | + | fn withReg(val: &Val, visitor: &mut opaque RegVisitor) { |
|
| 1330 | + | if let case Val::Reg(r) = *val { |
|
| 1331 | 1331 | visitor.visit(r); |
|
| 1332 | 1332 | } |
|
| 1333 | 1333 | } |
|
| 1334 | 1334 | ||
| 1335 | 1335 | /// Whether two borrowed result contracts name the same leaf sources in order. |
| 1352 | 1352 | /// Whether an operand has the target register number. |
|
| 1353 | 1353 | found: bool, |
|
| 1354 | 1354 | } |
|
| 1355 | 1355 | ||
| 1356 | 1356 | /// Check if an instruction uses a specific register. |
|
| 1357 | - | export fn usesReg(func: &Fn, instr: Instr, reg: Reg) -> bool { |
|
| 1357 | + | export fn usesReg(func: &Fn, instr: &Instr, reg: Reg) -> bool { |
|
| 1358 | 1358 | let mut ctx = FindCtx { target: reg.n, found: false }; |
|
| 1359 | 1359 | forEachReg(func, instr, &mut ctx); |
|
| 1360 | 1360 | return ctx.found; |
|
| 1361 | 1361 | } |
|
| 1362 | 1362 |
lib/std/lang/il/binary/program.rad
+1 -1
| 501 | 501 | throw binary::Error::Storage; |
|
| 502 | 502 | }; |
|
| 503 | 503 | let mut hasCall = false; |
|
| 504 | 504 | for _ in 0 .. instrCount { |
|
| 505 | 505 | let instr = try input.instr(a); |
|
| 506 | - | if il::isCall(instr) { |
|
| 506 | + | if il::isCall(&instr) { |
|
| 507 | 507 | set hasCall = true; |
|
| 508 | 508 | } |
|
| 509 | 509 | try instrs.append(instr, a) catch { |
|
| 510 | 510 | throw binary::Error::Storage; |
|
| 511 | 511 | }; |
lib/std/lang/il/verify.rad
+5 -5
| 568 | 568 | try checkType(c, param.type, Role::Param, at); |
|
| 569 | 569 | set regs = try reserveReg(c, regs, param.value, at); |
|
| 570 | 570 | } |
|
| 571 | 571 | for i in 0 .. block.instrs.len { |
|
| 572 | 572 | let place = Place::Instr { func: fi, block: b, instr: i }; |
|
| 573 | - | if il::isTerminator(block.instrs[i]) <> (i == block.instrs.len - 1) { |
|
| 573 | + | if il::isTerminator(&block.instrs[i]) <> (i == block.instrs.len - 1) { |
|
| 574 | 574 | throw Error { rule: Rule::Structure, place }; |
|
| 575 | 575 | } |
|
| 576 | - | if let reg = il::instrDst(block.instrs[i]) { |
|
| 576 | + | if let reg = il::instrDst(&block.instrs[i]) { |
|
| 577 | 577 | set regs = try reserveReg(c, regs, reg, place); |
|
| 578 | 578 | } |
|
| 579 | 579 | } |
|
| 580 | 580 | for k in 0 .. il::successorCount(func, b) { |
|
| 581 | 581 | if il::successor(func, b, k) >= func.blocks.len { |
| 1719 | 1719 | set fact = not p.own; |
|
| 1720 | 1720 | } |
|
| 1721 | 1721 | setAddressFact(v, target, param.value.n, fact); |
|
| 1722 | 1722 | } |
|
| 1723 | 1723 | for instr in block.instrs { |
|
| 1724 | - | let dst = il::instrDst(instr) else continue; |
|
| 1724 | + | let dst = il::instrDst(&instr) else continue; |
|
| 1725 | 1725 | let mut candidate = false; |
|
| 1726 | 1726 | match instr { |
|
| 1727 | 1727 | case il::Instr::Reserve { .. } => set candidate = not target, |
|
| 1728 | 1728 | case |
|
| 1729 | 1729 | il::Instr::Field { .. }, |
| 1786 | 1786 | if let value = |
|
| 1787 | 1787 | from; |
|
| 1788 | 1788 | not addressValue(v, target, value) |
|
| 1789 | 1789 | and not (target and loaded and addressValue(v, false, value)) |
|
| 1790 | 1790 | { |
|
| 1791 | - | let dst = il::instrDst(instr) else continue; |
|
| 1791 | + | let dst = il::instrDst(&instr) else continue; |
|
| 1792 | 1792 | if addressFact(v, target, dst.n) { |
|
| 1793 | 1793 | setAddressFact(v, target, dst.n, false); |
|
| 1794 | 1794 | set changed = true; |
|
| 1795 | 1795 | } |
|
| 1796 | 1796 | } |
| 2299 | 2299 | il::Instr::Zext { .. }, |
|
| 2300 | 2300 | il::Instr::Sext { .. }, |
|
| 2301 | 2301 | il::Instr::PageSlice { .. }, |
|
| 2302 | 2302 | il::Instr::PageHeap { .. } => |
|
| 2303 | 2303 | {} |
|
| 2304 | - | else => set input = il::usesReg(func, instr, buffer), |
|
| 2304 | + | else => set input = il::usesReg(func, &instr, buffer), |
|
| 2305 | 2305 | } |
|
| 2306 | 2306 | if input { |
|
| 2307 | 2307 | return true; |
|
| 2308 | 2308 | } |
|
| 2309 | 2309 | } |
lib/std/lang/lower.rad
+3 -3
| 3357 | 3357 | /// Emit an instruction to the current block. |
|
| 3358 | 3358 | fn emit(self: &mut Lowerer, instr: il::Instr) throws (LowerError) { |
|
| 3359 | 3359 | let blk = self.currentBlock else panic; |
|
| 3360 | 3360 | ||
| 3361 | 3361 | // Track whether this function is a leaf. |
|
| 3362 | - | if il::isCall(instr) { |
|
| 3362 | + | if il::isCall(&instr) { |
|
| 3363 | 3363 | set self.isLeaf = false; |
|
| 3364 | 3364 | } |
|
| 3365 | 3365 | // Record source location alongside instruction when enabled. |
|
| 3366 | 3366 | if self.options.debug { |
|
| 3367 | 3367 | let loc = self.srcLoc; |
| 4082 | 4082 | let blk = currentBlock(self); |
|
| 4083 | 4083 | let count = self.blockData[*blk].instrs.len; |
|
| 4084 | 4084 | if count == 0 { |
|
| 4085 | 4085 | return false; |
|
| 4086 | 4086 | } |
|
| 4087 | - | return il::isTerminator(self.blockData[*blk].instrs[count - 1]); |
|
| 4087 | + | return il::isTerminator(&self.blockData[*blk].instrs[count - 1]); |
|
| 4088 | 4088 | } |
|
| 4089 | 4089 | ||
| 4090 | 4090 | /// Emit a jump to merge block if the current block hasn't terminated. |
|
| 4091 | 4091 | /// |
|
| 4092 | 4092 | /// This is used after lowering branches of an if-else, for example. If the |
| 4596 | 4596 | if param.value == reg { |
|
| 4597 | 4597 | set def = b; |
|
| 4598 | 4598 | } |
|
| 4599 | 4599 | } |
|
| 4600 | 4600 | for instr in &self.blockData[b].instrs[..] { |
|
| 4601 | - | if let dst = il::instrDst(instr) { |
|
| 4601 | + | if let dst = il::instrDst(&instr) { |
|
| 4602 | 4602 | if dst == reg { |
|
| 4603 | 4603 | set def = b; |
|
| 4604 | 4604 | } |
|
| 4605 | 4605 | } |
|
| 4606 | 4606 | } |