File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -256,9 +256,17 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) {
256
256
257
257
// Precompute the set of registers that are unused, so that we can insert
258
258
// drops to their defs.
259
+ // And unstackify any stackified registers that don't have any uses, so that
260
+ // they can be dropped later. This can happen when transformations after
261
+ // RegStackify remove instructions using stackified registers.
259
262
BitVector UseEmpty (MRI.getNumVirtRegs ());
260
- for (unsigned I = 0 , E = MRI.getNumVirtRegs (); I < E; ++I)
261
- UseEmpty[I] = MRI.use_empty (Register::index2VirtReg (I));
263
+ for (unsigned I = 0 , E = MRI.getNumVirtRegs (); I < E; ++I) {
264
+ Register Reg = Register::index2VirtReg (I);
265
+ if (MRI.use_empty (Reg)) {
266
+ UseEmpty[I] = true ;
267
+ MFI.unstackifyVReg (Reg);
268
+ }
269
+ }
262
270
263
271
// Visit each instruction in the function.
264
272
for (MachineBasicBlock &MBB : MF) {
Original file line number Diff line number Diff line change
1
+ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2
+ ; RUN: llc -O0 -verify-machineinstrs < %s | FileCheck %s
3
+
4
+ target triple = "wasm32-unknown-unknown"
5
+
6
+ define void @test (i1 %x ) {
7
+ ; CHECK-LABEL: test:
8
+ ; CHECK: .functype test (i32) -> ()
9
+ ; CHECK-NEXT: # %bb.0:
10
+ ; CHECK-NEXT: local.get 0
11
+ ; CHECK-NEXT: i32.const -1
12
+ ; CHECK-NEXT: i32.xor
13
+ ; CHECK-NEXT: i32.const 1
14
+ ; CHECK-NEXT: i32.and
15
+ ; CHECK-NEXT: drop
16
+ ; CHECK-NEXT: # %bb.1: # %exit
17
+ ; CHECK-NEXT: return
18
+ %y = xor i1 %x , true
19
+ ; This br_if's operand (%y) is stackified in RegStackify. But this terminator
20
+ ; will be removed in CFGSort after that. We need to make sure we unstackify %y
21
+ ; so that it can be dropped in ExplicitLocals.
22
+ br i1 %y , label %exit , label %exit
23
+
24
+ exit:
25
+ ret void
26
+ }
You can’t perform that action at this time.
0 commit comments