Skip to content

Commit 6d60d3d

Browse files
authored
Revert "[WebAssembly] Implement addrspacecast to funcref" (#170785)
Reverts #166820 There was a failure in the ENABLE_EXPENSIVE_CHECKS configuration.
1 parent b75e564 commit 6d60d3d

File tree

4 files changed

+1
-120
lines changed

4 files changed

+1
-120
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,6 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
411411
setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::Other, Custom);
412412
setOperationAction(ISD::INTRINSIC_VOID, MVT::Other, Custom);
413413

414-
// Allow converting function ptrs in address space 0 to Wasm funcref (address
415-
// space 20)
416-
setOperationAction(ISD::ADDRSPACECAST, MVT::funcref, Custom);
417-
418414
setMaxAtomicSizeInBitsSupported(64);
419415

420416
// Always convert switches to br_tables unless there is only one case, which
@@ -1760,8 +1756,6 @@ SDValue WebAssemblyTargetLowering::LowerOperation(SDValue Op,
17601756
return LowerMUL_LOHI(Op, DAG);
17611757
case ISD::UADDO:
17621758
return LowerUADDO(Op, DAG);
1763-
case ISD::ADDRSPACECAST:
1764-
return LowerADDRSPACECAST(Op, DAG);
17651759
}
17661760
}
17671761

@@ -1905,58 +1899,6 @@ SDValue WebAssemblyTargetLowering::LowerUADDO(SDValue Op,
19051899
return DAG.getMergeValues(Ops, DL);
19061900
}
19071901

1908-
SDValue WebAssemblyTargetLowering::LowerADDRSPACECAST(SDValue Op,
1909-
SelectionDAG &DAG) const {
1910-
SDLoc DL(Op);
1911-
1912-
AddrSpaceCastSDNode *ACN = cast<AddrSpaceCastSDNode>(Op.getNode());
1913-
1914-
if (ACN->getSrcAddressSpace() !=
1915-
WebAssembly::WasmAddressSpace::WASM_ADDRESS_SPACE_DEFAULT ||
1916-
ACN->getDestAddressSpace() !=
1917-
WebAssembly::WasmAddressSpace::WASM_ADDRESS_SPACE_FUNCREF)
1918-
return SDValue();
1919-
1920-
if (ACN->getValueType(0) != MVT::funcref) {
1921-
reportFatalInternalError("Cannot addrspacecast to funcref addrspace with "
1922-
"results other than MVT::funcref");
1923-
}
1924-
1925-
SDValue Src = ACN->getOperand(0);
1926-
1927-
// Lower addrspacecasts of direct/constant function ptrs to ref.func
1928-
if (auto *GA = dyn_cast<GlobalAddressSDNode>(
1929-
Src->getOpcode() == WebAssemblyISD::Wrapper ? Src->getOperand(0)
1930-
: Src)) {
1931-
auto *GV = GA->getGlobal();
1932-
1933-
if (const Function *F = dyn_cast<Function>(GV)) {
1934-
SDValue FnAddress = DAG.getTargetGlobalAddress(F, DL, MVT::i32);
1935-
1936-
SDValue RefFuncNode =
1937-
DAG.getNode(WebAssemblyISD::REF_FUNC, DL, MVT::funcref, FnAddress);
1938-
return RefFuncNode;
1939-
}
1940-
}
1941-
1942-
// Lower everything else to a table.get from the indirect function table
1943-
const MachineFunction &MF = DAG.getMachineFunction();
1944-
1945-
MVT PtrVT = getPointerTy(MF.getDataLayout());
1946-
1947-
MCSymbolWasm *Table =
1948-
WebAssembly::getOrCreateFunctionTableSymbol(MF.getContext(), Subtarget);
1949-
SDValue TableSym = DAG.getMCSymbol(Table, PtrVT);
1950-
1951-
SDValue TableSlot = Op.getOperand(0);
1952-
1953-
SDValue Result(DAG.getMachineNode(WebAssembly::TABLE_GET_FUNCREF, DL,
1954-
MVT::funcref, TableSym, TableSlot),
1955-
0);
1956-
1957-
return Result;
1958-
}
1959-
19601902
SDValue WebAssemblyTargetLowering::Replace128Op(SDNode *N,
19611903
SelectionDAG &DAG) const {
19621904
assert(Subtarget->hasWideArithmetic());

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ class WebAssemblyTargetLowering final : public TargetLowering {
121121
SDValue LowerMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
122122
SDValue Replace128Op(SDNode *N, SelectionDAG &DAG) const;
123123
SDValue LowerUADDO(SDValue Op, SelectionDAG &DAG) const;
124-
SDValue LowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const;
125124

126125
// Custom DAG combine hooks
127126
SDValue

llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
///
1212
//===----------------------------------------------------------------------===//
1313

14-
def WebAssemblyRefFunc_t : SDTypeProfile<1, 1, [SDTCisVT<0, funcref>, SDTCisPtrTy<1>]>;
15-
def WebAssemblyRefFunc :
16-
SDNode<"WebAssemblyISD::REF_FUNC", WebAssemblyRefFunc_t,
17-
[]>;
18-
1914
multiclass REF_I<WebAssemblyRegClass rc, ValueType vt, string ht> {
2015
defm REF_NULL_#rc : I<(outs rc:$dst), (ins),
2116
(outs), (ins),
@@ -47,7 +42,7 @@ defm REF_TEST_FUNCREF : I<(outs I32:$res), (ins TypeIndex:$type, FUNCREF:$ref),
4742
Requires<[HasGC]>;
4843

4944
defm REF_FUNC : I<(outs FUNCREF:$res), (ins function32_op:$func),
50-
(outs), (ins function32_op:$func), [(set FUNCREF:$res, (WebAssemblyRefFunc tglobaladdr:$func))],
45+
(outs), (ins function32_op:$func), [],
5146
"ref.func\t$func", "ref.func $func", 0xd2>,
5247
Requires<[HasReferenceTypes]>;
5348

llvm/test/CodeGen/WebAssembly/addrspacecast-funcref.ll

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)