[PATCH] D11684: WebAssembly: handle unused function arguments.
JF Bastien
jfb at chromium.org
Fri Jul 31 11:14:10 PDT 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL243770: WebAssembly: handle unused function arguments. (authored by jfb).
Changed prior to commit:
http://reviews.llvm.org/D11684?vs=31141&id=31142#toc
Repository:
rL LLVM
http://reviews.llvm.org/D11684
Files:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/trunk/test/CodeGen/WebAssembly/unused-argument.ll
Index: llvm/trunk/test/CodeGen/WebAssembly/unused-argument.ll
===================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/unused-argument.ll
+++ llvm/trunk/test/CodeGen/WebAssembly/unused-argument.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+; Make sure that argument offsets are correct even if some arguments are unused.
+
+target datalayout = "e-p:32:32-i64:64-v128:8:128-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+; CHECK-LABEL: unused_first:
+; CHECK-NEXT: (setlocal @0 (argument 1))
+; CHECK-NEXT: (RETURN @0)
+define i32 @unused_first(i32 %x, i32 %y) {
+ ret i32 %y
+}
+
+; CHECK-LABEL: unused_second:
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (RETURN @0)
+define i32 @unused_second(i32 %x, i32 %y) {
+ ret i32 %x
+}
Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -191,11 +191,13 @@
fail(DL, DAG, "WebAssembly hasn't implemented split arguments");
if (In.VT != MVT::i32)
fail(DL, DAG, "WebAssembly hasn't implemented non-i32 arguments");
- if (!In.Used)
- fail(DL, DAG, "WebAssembly hasn't implemented unused arguments");
// FIXME Do something with In.getOrigAlign()?
- InVals.push_back(DAG.getNode(WebAssemblyISD::ARGUMENT, DL, In.VT,
- DAG.getTargetConstant(ArgNo++, DL, MVT::i32)));
+ InVals.push_back(
+ In.Used
+ ? DAG.getNode(WebAssemblyISD::ARGUMENT, DL, In.VT,
+ DAG.getTargetConstant(ArgNo, DL, MVT::i32))
+ : DAG.getNode(ISD::UNDEF, DL, In.VT));
+ ++ArgNo;
}
return Chain;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11684.31142.patch
Type: text/x-patch
Size: 1859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150731/3de17e72/attachment.bin>
More information about the llvm-commits
mailing list