[llvm] r250594 - WebAssembly: don't omit dead vregs from locals
JF Bastien via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 16 17:25:38 PDT 2015
Author: jfb
Date: Fri Oct 16 19:25:38 2015
New Revision: 250594
URL: http://llvm.org/viewvc/llvm-project?rev=250594&view=rev
Log:
WebAssembly: don't omit dead vregs from locals
Summary:
This is a temporary hack until we get around to remapping the vreg
numbers to local numbers. Dead vregs cause bad numbering and make
consumers sad.
We could also just look at debug info an use named locals instead, but
vregs have to work properly anyways so there!
Reviewers: binji, sunfish
Subscribers: jfb, llvm-commits, dschuff
Differential Revision: http://reviews.llvm.org/D13839
Added:
llvm/trunk/test/CodeGen/WebAssembly/dead-vreg.ll
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp?rev=250594&r1=250593&r2=250594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp Fri Oct 16 19:25:38 2015
@@ -226,14 +226,16 @@ void WebAssemblyAsmPrinter::EmitFunction
bool FirstVReg = true;
for (unsigned Idx = 0, IdxE = MRI->getNumVirtRegs(); Idx != IdxE; ++Idx) {
unsigned VReg = TargetRegisterInfo::index2VirtReg(Idx);
- if (!MRI->use_empty(VReg)) {
+ // FIXME: Don't skip dead virtual registers for now: that would require
+ // remapping all locals' numbers.
+ //if (!MRI->use_empty(VReg)) {
if (FirstVReg) {
OS << (First ? "" : "\n") << "\t.local ";
First = false;
}
OS << (FirstVReg ? "" : ", ") << getRegTypeName(VReg);
FirstVReg = false;
- }
+ //}
}
if (!First)
Added: llvm/trunk/test/CodeGen/WebAssembly/dead-vreg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/dead-vreg.ll?rev=250594&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/dead-vreg.ll (added)
+++ llvm/trunk/test/CodeGen/WebAssembly/dead-vreg.ll Fri Oct 16 19:25:38 2015
@@ -0,0 +1,58 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+; Check that unused vregs don't prevent locals from being numbered wrong.
+;
+; The test currently checks that the dead virtual registers still appear as
+; locals, which isn't what we want long term. Removing them from the list of
+; locals will require remapping the local numbers, and checking that the
+; get_/set_local have the right numbers.
+
+target datalayout = "e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+define void @foo(i32* nocapture %a, i32 %w, i32 %h) {
+; CHECK-LABEL: foo:
+; CHECK-NEXT: .param i32
+; CHECK-NEXT: .param i32
+; CHECK-NEXT: .param i32
+; CHECK-NEXT: .local i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32{{$}}
+entry:
+ %cmp.19 = icmp sgt i32 %h, 0
+ br i1 %cmp.19, label %for.cond.1.preheader.lr.ph, label %for.end.7
+
+for.cond.1.preheader.lr.ph:
+ %cmp2.17 = icmp sgt i32 %w, 0
+ br label %for.cond.1.preheader
+
+for.cond.1.preheader:
+ %y.020 = phi i32 [ 0, %for.cond.1.preheader.lr.ph ], [ %inc6, %for.inc.5 ]
+ br i1 %cmp2.17, label %for.body.3.lr.ph, label %for.inc.5
+
+for.body.3.lr.ph:
+ %mul4 = mul nsw i32 %y.020, %w
+ br label %for.body.3
+
+for.body.3:
+ %x.018 = phi i32 [ 0, %for.body.3.lr.ph ], [ %inc, %for.body.3 ]
+ %mul = mul nsw i32 %x.018, %y.020
+ %add = add nsw i32 %x.018, %mul4
+ %arrayidx = getelementptr inbounds i32, i32* %a, i32 %add
+ store i32 %mul, i32* %arrayidx, align 4
+ %inc = add nuw nsw i32 %x.018, 1
+ %exitcond = icmp eq i32 %inc, %w
+ br i1 %exitcond, label %for.inc.5.loopexit, label %for.body.3
+
+for.inc.5.loopexit:
+ br label %for.inc.5
+
+for.inc.5:
+ %inc6 = add nuw nsw i32 %y.020, 1
+ %exitcond22 = icmp eq i32 %inc6, %h
+ br i1 %exitcond22, label %for.end.7.loopexit, label %for.cond.1.preheader
+
+for.end.7.loopexit:
+ br label %for.end.7
+
+for.end.7:
+ ret void
+}
More information about the llvm-commits
mailing list