[llvm] r258694 - [WebAssembly] Fix unbalanced register stack code in the case of late DCE.
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 25 08:48:45 PST 2016
Author: djg
Date: Mon Jan 25 10:48:44 2016
New Revision: 258694
URL: http://llvm.org/viewvc/llvm-project?rev=258694&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp
llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp?rev=258694&r1=258693&r2=258694&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp Mon Jan 25 10:48:44 2016
@@ -92,6 +92,9 @@ bool WebAssemblyRegNumbering::runOnMachi
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::runOnMachi
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++);
Modified: llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll?rev=258694&r1=258693&r2=258694&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll Mon Jan 25 10:48:44 2016
@@ -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() {
More information about the llvm-commits
mailing list