mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[WebAssembly] Fix unbalanced register stack code in the case of late DCE.
Instructions can be DCE'd after the RegStackify pass. If the instruction which would be the pop for what would be a push is removed, don't use a push. llvm-svn: 258694
This commit is contained in:
parent
d1cae1c975
commit
d5075eb344
@ -92,6 +92,9 @@ bool WebAssemblyRegNumbering::runOnMachineFunction(MachineFunction &MF) {
|
||||
unsigned CurReg = MFI.getParams().size();
|
||||
for (unsigned VRegIdx = 0; VRegIdx < NumVRegs; ++VRegIdx) {
|
||||
unsigned VReg = TargetRegisterInfo::index2VirtReg(VRegIdx);
|
||||
// Skip unused registers.
|
||||
if (MRI.use_empty(VReg))
|
||||
continue;
|
||||
// Handle stackified registers.
|
||||
if (MFI.isVRegStackified(VReg)) {
|
||||
DEBUG(dbgs() << "VReg " << VReg << " -> WAReg "
|
||||
@ -99,9 +102,6 @@ bool WebAssemblyRegNumbering::runOnMachineFunction(MachineFunction &MF) {
|
||||
MFI.setWAReg(VReg, INT32_MIN | NumStackRegs++);
|
||||
continue;
|
||||
}
|
||||
// Skip unused registers.
|
||||
if (MRI.use_empty(VReg))
|
||||
continue;
|
||||
if (MFI.getWAReg(VReg) == WebAssemblyFunctionInfo::UnusedReg) {
|
||||
DEBUG(dbgs() << "VReg " << VReg << " -> WAReg " << CurReg << "\n");
|
||||
MFI.setWAReg(VReg, CurReg++);
|
||||
|
@ -1176,9 +1176,9 @@ bb5:
|
||||
; CHECK-NEXT: .LBB23_2:{{$}}
|
||||
; CHECK-NEXT: end_loop{{$}}
|
||||
; CHECK-NEXT: loop{{$}}
|
||||
; CHECK-NEXT: i32.const $discard=, 0{{$}}
|
||||
; CHECK-NEXT: i32.const $push1=, 0{{$}}
|
||||
; CHECK-NEXT: i32.const $push2=, 0{{$}}
|
||||
; CHECK-NEXT: br_if $pop2, 0{{$}}
|
||||
; CHECK-NEXT: br_if $pop1, 0{{$}}
|
||||
; CHECK-NEXT: end_loop{{$}}
|
||||
; CHECK-NEXT: return{{$}}
|
||||
define void @test14() {
|
||||
|
Loading…
Reference in New Issue
Block a user