From b81848272dc60d6ada098e6efe004140533ea277 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 22 May 2018 04:58:36 +0000 Subject: [WebAssembly] Fix fast-isel lowering illegal argument and return types. For both argument and return types, promote illegal types like i24 to i32, and if a type can't be easily promoted, clear out the signature before bailing out, so avoid leaving it in a partially complete state. Fixes PR37546. llvm-svn: 332947 --- llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp') diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp index fe821ced672..7b5eab42f87 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp @@ -700,14 +700,22 @@ bool WebAssemblyFastISel::fastLowerArguments() { MRI.addLiveIn(WebAssembly::ARGUMENTS); auto *MFI = MF->getInfo(); - for (auto const &Arg : F->args()) - MFI->addParam(getLegalType(getSimpleType(Arg.getType()))); + for (auto const &Arg : F->args()) { + MVT::SimpleValueType ArgTy = getLegalType(getSimpleType(Arg.getType())); + if (ArgTy == MVT::INVALID_SIMPLE_VALUE_TYPE) { + MFI->clearParamsAndResults(); + return false; + } + MFI->addParam(ArgTy); + } if (!F->getReturnType()->isVoidTy()) { - MVT::SimpleValueType RetTy = getSimpleType(F->getReturnType()); - if (RetTy == MVT::INVALID_SIMPLE_VALUE_TYPE) + MVT::SimpleValueType RetTy = getLegalType(getSimpleType(F->getReturnType())); + if (RetTy == MVT::INVALID_SIMPLE_VALUE_TYPE) { + MFI->clearParamsAndResults(); return false; - MFI->addResult(getLegalType(RetTy)); + } + MFI->addResult(RetTy); } return true; -- cgit v1.2.3