diff options
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp | 8 | ||||
-rw-r--r-- | llvm/test/CodeGen/WebAssembly/fast-isel-i24.ll | 16 |
2 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp index f3ee6e70822..c13dd7a48a7 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp @@ -703,8 +703,12 @@ bool WebAssemblyFastISel::fastLowerArguments() { 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; } diff --git a/llvm/test/CodeGen/WebAssembly/fast-isel-i24.ll b/llvm/test/CodeGen/WebAssembly/fast-isel-i24.ll new file mode 100644 index 00000000000..d3823f9869b --- /dev/null +++ b/llvm/test/CodeGen/WebAssembly/fast-isel-i24.ll @@ -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 +} |