[llvm] r330215 - [WebAssembly] Teach fast-isel to gracefully recover from illegal return types.

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 17 13:46:42 PDT 2018


Author: djg
Date: Tue Apr 17 13:46:42 2018
New Revision: 330215

URL: http://llvm.org/viewvc/llvm-project?rev=330215&view=rev
Log:
[WebAssembly] Teach fast-isel to gracefully recover from illegal return types.

Fixes PR36564.

Added:
    llvm/trunk/test/CodeGen/WebAssembly/fast-isel-i24.ll
Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp?rev=330215&r1=330214&r2=330215&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp Tue Apr 17 13:46:42 2018
@@ -703,8 +703,12 @@ bool WebAssemblyFastISel::fastLowerArgum
   for (auto const &Arg : F->args())
     MFI->addParam(getLegalType(getSimpleType(Arg.getType())));
 
-  if (!F->getReturnType()->isVoidTy())
-    MFI->addResult(getLegalType(getSimpleType(F->getReturnType())));
+  if (!F->getReturnType()->isVoidTy()) {
+    MVT::SimpleValueType RetTy = getSimpleType(F->getReturnType());
+    if (RetTy == MVT::INVALID_SIMPLE_VALUE_TYPE)
+      return false;
+    MFI->addResult(getLegalType(RetTy));
+  }
 
   return true;
 }

Added: llvm/trunk/test/CodeGen/WebAssembly/fast-isel-i24.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/fast-isel-i24.ll?rev=330215&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/fast-isel-i24.ll (added)
+++ llvm/trunk/test/CodeGen/WebAssembly/fast-isel-i24.ll Tue Apr 17 13:46:42 2018
@@ -0,0 +1,16 @@
+; RUN: llc < %s -O0
+; PR36564
+
+; Test that fast-isel properly copes with i24 arguments and return types.
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown-wasm"
+
+define i24 @add(i24 %x, i24 %y) {
+    %z = add i24 %x, %y
+    ret i24 %z
+}
+
+define i24 @return_zero() {
+    ret i24 0
+}




More information about the llvm-commits mailing list