Skip to content

Commit 8506a63

Browse files
committed
Revert "[WebAssembly] Disable multivalue emission temporarily (#82714)"
This reverts commit 6e6bf9f. It turned out the multivalue feature had active outside users and it could cause some disruptions to them, so I'd like to investigate more about the workarounds before doing this.
1 parent 062cfad commit 8506a63

9 files changed

+24
-43
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ using namespace llvm;
4343

4444
#define DEBUG_TYPE "wasm-lower"
4545

46-
extern cl::opt<bool> WasmEmitMultiValue;
47-
4846
WebAssemblyTargetLowering::WebAssemblyTargetLowering(
4947
const TargetMachine &TM, const WebAssemblySubtarget &STI)
5048
: TargetLowering(TM), Subtarget(&STI) {
@@ -1290,16 +1288,15 @@ bool WebAssemblyTargetLowering::CanLowerReturn(
12901288
const SmallVectorImpl<ISD::OutputArg> &Outs,
12911289
LLVMContext & /*Context*/) const {
12921290
// WebAssembly can only handle returning tuples with multivalue enabled
1293-
return (Subtarget->hasMultivalue() && WasmEmitMultiValue) || Outs.size() <= 1;
1291+
return Subtarget->hasMultivalue() || Outs.size() <= 1;
12941292
}
12951293

12961294
SDValue WebAssemblyTargetLowering::LowerReturn(
12971295
SDValue Chain, CallingConv::ID CallConv, bool /*IsVarArg*/,
12981296
const SmallVectorImpl<ISD::OutputArg> &Outs,
12991297
const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
13001298
SelectionDAG &DAG) const {
1301-
assert(((Subtarget->hasMultivalue() && WasmEmitMultiValue) ||
1302-
Outs.size() <= 1) &&
1299+
assert((Subtarget->hasMultivalue() || Outs.size() <= 1) &&
13031300
"MVP WebAssembly can only return up to one value");
13041301
if (!callingConvSupported(CallConv))
13051302
fail(DL, DAG, "WebAssembly doesn't support non-C calling conventions");

llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "llvm/Target/TargetMachine.h"
2323
using namespace llvm;
2424

25-
extern cl::opt<bool> WasmEmitMultiValue;
26-
2725
WebAssemblyFunctionInfo::~WebAssemblyFunctionInfo() = default; // anchor.
2826

2927
MachineFunctionInfo *WebAssemblyFunctionInfo::clone(
@@ -73,8 +71,7 @@ void llvm::computeSignatureVTs(const FunctionType *Ty,
7371

7472
MVT PtrVT = MVT::getIntegerVT(TM.createDataLayout().getPointerSizeInBits());
7573
if (Results.size() > 1 &&
76-
(!TM.getSubtarget<WebAssemblySubtarget>(ContextFunc).hasMultivalue() ||
77-
!WasmEmitMultiValue)) {
74+
!TM.getSubtarget<WebAssemblySubtarget>(ContextFunc).hasMultivalue()) {
7875
// WebAssembly can't lower returns of multiple values without demoting to
7976
// sret unless multivalue is enabled (see
8077
// WebAssemblyTargetLowering::CanLowerReturn). So replace multiple return

llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp

+12-14
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
using namespace llvm;
2626

27-
extern cl::opt<bool> WasmEmitMultiValue;
28-
2927
namespace {
3028

3129
enum RuntimeLibcallSignature {
@@ -696,7 +694,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
696694
Params.push_back(PtrTy);
697695
break;
698696
case i64_i64_func_f32:
699-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
697+
if (Subtarget.hasMultivalue()) {
700698
Rets.push_back(wasm::ValType::I64);
701699
Rets.push_back(wasm::ValType::I64);
702700
} else {
@@ -705,7 +703,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
705703
Params.push_back(wasm::ValType::F32);
706704
break;
707705
case i64_i64_func_f64:
708-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
706+
if (Subtarget.hasMultivalue()) {
709707
Rets.push_back(wasm::ValType::I64);
710708
Rets.push_back(wasm::ValType::I64);
711709
} else {
@@ -714,7 +712,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
714712
Params.push_back(wasm::ValType::F64);
715713
break;
716714
case i16_i16_func_i16_i16:
717-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
715+
if (Subtarget.hasMultivalue()) {
718716
Rets.push_back(wasm::ValType::I32);
719717
Rets.push_back(wasm::ValType::I32);
720718
} else {
@@ -724,7 +722,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
724722
Params.push_back(wasm::ValType::I32);
725723
break;
726724
case i32_i32_func_i32_i32:
727-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
725+
if (Subtarget.hasMultivalue()) {
728726
Rets.push_back(wasm::ValType::I32);
729727
Rets.push_back(wasm::ValType::I32);
730728
} else {
@@ -734,7 +732,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
734732
Params.push_back(wasm::ValType::I32);
735733
break;
736734
case i64_i64_func_i64_i64:
737-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
735+
if (Subtarget.hasMultivalue()) {
738736
Rets.push_back(wasm::ValType::I64);
739737
Rets.push_back(wasm::ValType::I64);
740738
} else {
@@ -744,7 +742,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
744742
Params.push_back(wasm::ValType::I64);
745743
break;
746744
case i64_i64_func_i64_i64_i64_i64:
747-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
745+
if (Subtarget.hasMultivalue()) {
748746
Rets.push_back(wasm::ValType::I64);
749747
Rets.push_back(wasm::ValType::I64);
750748
} else {
@@ -756,7 +754,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
756754
Params.push_back(wasm::ValType::I64);
757755
break;
758756
case i64_i64_func_i64_i64_i64_i64_iPTR:
759-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
757+
if (Subtarget.hasMultivalue()) {
760758
Rets.push_back(wasm::ValType::I64);
761759
Rets.push_back(wasm::ValType::I64);
762760
} else {
@@ -769,7 +767,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
769767
Params.push_back(PtrTy);
770768
break;
771769
case i64_i64_i64_i64_func_i64_i64_i64_i64:
772-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
770+
if (Subtarget.hasMultivalue()) {
773771
Rets.push_back(wasm::ValType::I64);
774772
Rets.push_back(wasm::ValType::I64);
775773
Rets.push_back(wasm::ValType::I64);
@@ -783,7 +781,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
783781
Params.push_back(wasm::ValType::I64);
784782
break;
785783
case i64_i64_func_i64_i64_i32:
786-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
784+
if (Subtarget.hasMultivalue()) {
787785
Rets.push_back(wasm::ValType::I64);
788786
Rets.push_back(wasm::ValType::I64);
789787
} else {
@@ -853,7 +851,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
853851
Params.push_back(wasm::ValType::I64);
854852
break;
855853
case i64_i64_func_i64_i64_i64_i64_i64_i64:
856-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
854+
if (Subtarget.hasMultivalue()) {
857855
Rets.push_back(wasm::ValType::I64);
858856
Rets.push_back(wasm::ValType::I64);
859857
} else {
@@ -867,7 +865,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
867865
Params.push_back(wasm::ValType::I64);
868866
break;
869867
case i64_i64_func_i32:
870-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
868+
if (Subtarget.hasMultivalue()) {
871869
Rets.push_back(wasm::ValType::I64);
872870
Rets.push_back(wasm::ValType::I64);
873871
} else {
@@ -876,7 +874,7 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
876874
Params.push_back(wasm::ValType::I32);
877875
break;
878876
case i64_i64_func_i64:
879-
if (Subtarget.hasMultivalue() && WasmEmitMultiValue) {
877+
if (Subtarget.hasMultivalue()) {
880878
Rets.push_back(wasm::ValType::I64);
881879
Rets.push_back(wasm::ValType::I64);
882880
} else {

llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ static cl::opt<bool> WasmDisableFixIrreducibleControlFlowPass(
5454
" irreducible control flow optimization pass"),
5555
cl::init(false));
5656

57-
// A temporary option to control emission of multivalue until multivalue
58-
// implementation is stable enough. We currently don't emit multivalue by
59-
// default even if the feature section allows it.
60-
// TODO Stabilize multivalue and delete this option
61-
cl::opt<bool>
62-
WasmEmitMultiValue("wasm-emit-multivalue", cl::Hidden,
63-
cl::desc("WebAssembly: Emit multivalue in the backend"),
64-
cl::init(false));
65-
6657
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() {
6758
// Register the target.
6859
RegisterTargetMachine<WebAssemblyTargetMachine> X(

llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-multi-return.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -mattr=+multivalue -wasm-emit-multivalue 2>&1 | FileCheck %s --check-prefix=EH
2-
; RUN: not --crash llc < %s -enable-emscripten-sjlj -mattr=+multivalue 2>&1 -wasm-emit-multivalue | FileCheck %s --check-prefix=SJLJ
1+
; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -mattr=+multivalue 2>&1 | FileCheck %s --check-prefix=EH
2+
; RUN: not --crash llc < %s -enable-emscripten-sjlj -mattr=+multivalue 2>&1 | FileCheck %s --check-prefix=SJLJ
33

44
; Currently multivalue returning functions are not supported in Emscripten EH /
55
; SjLj. Make sure they error out.

llvm/test/CodeGen/WebAssembly/multivalue-dont-move-def-past-use.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
# RUN: llc -mtriple=wasm32-unknown-unknown -mattr=+multivalue -wasm-emit-multivalue -run-pass=wasm-reg-stackify -verify-machineinstrs %s -o - | FileCheck %s
2+
# RUN: llc -mtriple=wasm32-unknown-unknown -mattr=+multivalue -run-pass=wasm-reg-stackify -verify-machineinstrs %s -o - | FileCheck %s
33

44
--- |
55
target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"

llvm/test/CodeGen/WebAssembly/multivalue-stackify.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; NOTE: Test functions have been generated by multivalue-stackify.py.
33

4-
; RUN: llc < %s -verify-machineinstrs -mattr=+multivalue -wasm-emit-multivalue | FileCheck %s
4+
; RUN: llc < %s -verify-machineinstrs -mattr=+multivalue | FileCheck %s
55

66
; Test that the multivalue stackification works
77

llvm/test/CodeGen/WebAssembly/multivalue.ll

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -mcpu=mvp -mattr=+multivalue,+tail-call -wasm-emit-multivalue | FileCheck %s
2-
; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -mcpu=mvp -mattr=+reference-types,+multivalue,+tail-call -wasm-emit-multivalue | FileCheck --check-prefix REF %s
3-
; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mcpu=mvp -mattr=+multivalue,+tail-call -wasm-emit-multivalue | FileCheck %s --check-prefix REGS
4-
; RUN: llc < %s --filetype=obj -mcpu=mvp -mattr=+multivalue,+tail-call -wasm-emit-multivalue | obj2yaml | FileCheck %s --check-prefix OBJ
5-
; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -mcpu=mvp -mattr=+multivalue,+tail-call | FileCheck %s --check-prefix NO-MULTIVALUE
1+
; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -mcpu=mvp -mattr=+multivalue,+tail-call | FileCheck %s
2+
; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -mcpu=mvp -mattr=+reference-types,+multivalue,+tail-call | FileCheck --check-prefix REF %s
3+
; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mcpu=mvp -mattr=+multivalue,+tail-call | FileCheck %s --check-prefix REGS
4+
; RUN: llc < %s --filetype=obj -mcpu=mvp -mattr=+multivalue,+tail-call | obj2yaml | FileCheck %s --check-prefix OBJ
65

76
; Test that the multivalue calls, returns, function types, and block
87
; types work as expected.
@@ -20,7 +19,6 @@ declare void @use_i64(i64)
2019
; CHECK-NEXT: i32.const 42{{$}}
2120
; CHECK-NEXT: i64.const 42{{$}}
2221
; CHECK-NEXT: end_function{{$}}
23-
; NO-MULTIVALUE-NOT: .functype pair_const () -> (i32, i64)
2422
define %pair @pair_const() {
2523
ret %pair { i32 42, i64 42 }
2624
}

llvm/test/CodeGen/WebAssembly/multivalue_libcall.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2-
; RUN: llc < %s -verify-machineinstrs -mcpu=mvp -mattr=+multivalue -wasm-emit-multivalue | FileCheck %s --check-prefix=MULTIVALUE
2+
; RUN: llc < %s -verify-machineinstrs -mcpu=mvp -mattr=+multivalue | FileCheck %s --check-prefix=MULTIVALUE
33
; RUN: llc < %s -verify-machineinstrs -mcpu=mvp | FileCheck %s --check-prefix=NO_MULTIVALUE
44

55
; Test libcall signatures when multivalue is enabled and disabled

0 commit comments

Comments
 (0)