Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/auto-assign.yml

This file was deleted.

13 changes: 8 additions & 5 deletions src/compiler/cgir/pass/register_coalescer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2226,10 +2226,11 @@ class JoinVals {
/// Erase any machine instructions that have been coalesced away.
/// Add erased instructions to ErasedInstrs.
/// Add foreign virtual registers to ShrinkRegs if their live range ended at
/// the erased instrs.
/// the erased instrs. Set ShrinkMainRange when erasing a COPY whose source
/// is part of the coalesced pair, so the merged interval gets shrunk.
void eraseInstrs(SmallPtrSetImpl<CgInstruction *> &ErasedInstrs,
SmallVectorImpl<CgRegister> &ShrinkRegs,
CgLiveInterval *LI = nullptr);
bool &ShrinkMainRange, CgLiveInterval *LI = nullptr);

/// Remove liverange defs at places where implicit defs will be removed.
void removeImplicitDefs();
Expand Down Expand Up @@ -3019,7 +3020,7 @@ void JoinVals::removeImplicitDefs() {

void JoinVals::eraseInstrs(SmallPtrSetImpl<CgInstruction *> &ErasedInstrs,
SmallVectorImpl<CgRegister> &ShrinkRegs,
CgLiveInterval *LI) {
bool &ShrinkMainRange, CgLiveInterval *LI) {
for (unsigned i = 0, e = LR.getNumValNums(); i != e; ++i) {
// Get the def location before markUnused() below invalidates it.
CgVNInfo *VNI = LR.getValNumInfo(i);
Expand Down Expand Up @@ -3101,6 +3102,8 @@ void JoinVals::eraseInstrs(SmallPtrSetImpl<CgInstruction *> &ErasedInstrs,
if (Register::isVirtualRegister(Reg) && Reg != CP.getSrcReg() &&
Reg != CP.getDstReg())
ShrinkRegs.push_back(Reg);
else if (Register::isVirtualRegister(Reg) && MI->allDefsAreDead())
ShrinkMainRange = true;
}
ErasedInstrs.insert(MI);
LLVM_DEBUG(dbgs() << "\t\terased:\t" << Def << '\t' << *MI);
Expand Down Expand Up @@ -3294,8 +3297,8 @@ bool CgRegisterCoalescer::joinVirtRegs(CgCoalescerPair &CP) {
// Erase COPY and IMPLICIT_DEF instructions. This may cause some external
// registers to require trimming.
SmallVector<CgRegister, 8> ShrinkRegs;
LHSVals.eraseInstrs(ErasedInstrs, ShrinkRegs, &LHS);
RHSVals.eraseInstrs(ErasedInstrs, ShrinkRegs);
LHSVals.eraseInstrs(ErasedInstrs, ShrinkRegs, ShrinkMainRange, &LHS);
RHSVals.eraseInstrs(ErasedInstrs, ShrinkRegs, ShrinkMainRange);
while (!ShrinkRegs.empty())
shrinkToUses(&LIS->getInterval(ShrinkRegs.pop_back_val()));

Expand Down
21 changes: 21 additions & 0 deletions tests/wast/spec_extra/coalescer_if_local_tee.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(module
(type (;0;) (func (result f64)))
(type (;1;) (func (result i64)))
(func (;0;) (type 0) (result f64)
(local f64)
i32.const 1
if ;; label = @1
end
call 1
local.get 0
local.set 0
drop
f64.const 0x0p+0 (;=0;)
local.tee 0
local.get 0
i32.trunc_f64_u
drop)
(func (;1;) (type 1) (result i64)
i64.const 1)
(export "to_test" (func 0)))
(assert_return (invoke "to_test") (f64.const 0))
16 changes: 16 additions & 0 deletions tests/wast/spec_extra/coalescer_memory_grow_local_tee.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(module
(type (;0;) (func (param i32) (result i64)))
(type (;1;) (func (result i64)))
(func (;0;) (type 1) (result i64)
(local i32)
i32.const -1812402867
memory.grow
local.get 0
local.set 0
local.tee 0
drop
local.get 0
i64.load32_u offset=55218920 align=1)
(memory (;0;) 1)
(export "to_test" (func 0)))
(assert_trap (invoke "to_test") "out of bounds memory access")
Loading