aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorAndy Wingo <wingo@igalia.com>2021-05-31 10:55:15 +0200
committerAndy Wingo <wingo@igalia.com>2021-05-31 10:55:15 +0200
commitbc1ad6e3c49dacea862ca6fa44297c64bb053ad8 (patch)
tree99e9964a1ba04be7b5de6949407cbb5b5d8e1ca8 /llvm/lib
parent818338add77411f5e9713247ea66142f332ef350 (diff)
downloadllvm-bc1ad6e3c49dacea862ca6fa44297c64bb053ad8.zip
llvm-bc1ad6e3c49dacea862ca6fa44297c64bb053ad8.tar.gz
llvm-bc1ad6e3c49dacea862ca6fa44297c64bb053ad8.tar.bz2
Revert "[WebAssembly][CodeGen] IR support for WebAssembly local variables"
This reverts commit bf35f4af51cddd743435bb6b94a45592c967891a. There was an error in a shared-library build.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/AMDGPU/SIFrameLowering.cpp1
-rw-r--r--llvm/lib/Target/RISCV/RISCVFrameLowering.cpp1
-rw-r--r--llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp48
-rw-r--r--llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h7
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp4
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp10
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h1
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyISD.def2
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp16
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp34
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td12
11 files changed, 1 insertions, 135 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
index ebbf940..963f58f 100644
--- a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
@@ -661,7 +661,6 @@ bool SIFrameLowering::isSupportedStackID(TargetStackID::Value ID) const {
case TargetStackID::SGPRSpill:
return true;
case TargetStackID::ScalableVector:
- case TargetStackID::WasmLocal:
return false;
}
llvm_unreachable("Invalid TargetStackID::Value");
diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index 6f8a80a..2417daf 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -1099,7 +1099,6 @@ bool RISCVFrameLowering::isSupportedStackID(TargetStackID::Value ID) const {
return true;
case TargetStackID::NoAlloc:
case TargetStackID::SGPRSpill:
- case TargetStackID::WasmLocal:
return false;
}
llvm_unreachable("Invalid TargetStackID::Value");
diff --git a/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp b/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
index 60e3d1a..824d336 100644
--- a/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
+++ b/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
@@ -13,12 +13,8 @@
#include "WebAssemblyUtilities.h"
#include "WebAssemblyMachineFunctionInfo.h"
-#include "WebAssemblySubtarget.h"
-#include "llvm/CodeGen/Analysis.h"
-#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
-#include "llvm/IR/Instructions.h"
#include "llvm/MC/MCContext.h"
using namespace llvm;
@@ -28,50 +24,6 @@ const char *const WebAssembly::StdTerminateFn = "_ZSt9terminatev";
const char *const WebAssembly::PersonalityWrapperFn =
"_Unwind_Wasm_CallPersonality";
-// In an ideal world, when objects are added to the MachineFrameInfo by
-// FunctionLoweringInfo::set, we could somehow hook into target-specific code to
-// ensure they are assigned the right stack ID. However there isn't a hook that
-// runs between then and DAG building time, though, so instead we hoist stack
-// objects lazily when they are first used, and comprehensively after the DAG is
-// built via the PreprocessISelDAG hook, called by the
-// SelectionDAGISel::runOnMachineFunction. We have to do it in two places
-// because we want to do it while building the selection DAG for uses of alloca,
-// but not all alloca instructions are used so we have to follow up afterwards.
-Optional<unsigned> WebAssembly::getLocalForStackObject(MachineFunction &MF,
- int FrameIndex) {
- auto &MFI = MF.getFrameInfo();
-
- // If already hoisted to a local, done.
- if (MFI.getStackID(FrameIndex) == TargetStackID::WasmLocal)
- return static_cast<unsigned>(MFI.getObjectOffset(FrameIndex));
-
- // If not allocated in the object address space, this object will be in
- // linear memory.
- const AllocaInst *AI = MFI.getObjectAllocation(FrameIndex);
- if (!AI || !isWasmVarAddressSpace(AI->getType()->getAddressSpace()))
- return None;
-
- // Otherwise, allocate this object in the named value stack, outside of linear
- // memory.
- SmallVector<EVT, 4> ValueVTs;
- const WebAssemblyTargetLowering &TLI =
- *MF.getSubtarget<WebAssemblySubtarget>().getTargetLowering();
- WebAssemblyFunctionInfo *FuncInfo = MF.getInfo<WebAssemblyFunctionInfo>();
- ComputeValueVTs(TLI, MF.getDataLayout(), AI->getAllocatedType(), ValueVTs);
- MFI.setStackID(FrameIndex, TargetStackID::WasmLocal);
- // Abuse SP offset to record the index of the first local in the object.
- unsigned Local = FuncInfo->getParams().size() + FuncInfo->getLocals().size();
- MFI.setObjectOffset(FrameIndex, Local);
- // Allocate WebAssembly locals for each non-aggregate component of the
- // allocation.
- for (EVT ValueVT : ValueVTs)
- FuncInfo->addLocal(ValueVT.getSimpleVT());
- // Abuse object size to record number of WebAssembly locals allocated to
- // this object.
- MFI.setObjectSize(FrameIndex, ValueVTs.size());
- return static_cast<unsigned>(Local);
-}
-
/// Test whether MI is a child of some other node in an expression tree.
bool WebAssembly::isChild(const MachineInstr &MI,
const WebAssemblyFunctionInfo &MFI) {
diff --git a/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h b/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
index ac84e8e..1ec1df5 100644
--- a/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
+++ b/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
@@ -15,13 +15,10 @@
#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WEBASSEMBLYUTILITIES_H
#define LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WEBASSEMBLYUTILITIES_H
-#include "llvm/ADT/Optional.h"
-
namespace llvm {
class MachineBasicBlock;
class MachineInstr;
-class MachineFunction;
class MachineOperand;
class MCContext;
class MCSymbolWasm;
@@ -51,10 +48,6 @@ inline bool isValidAddressSpace(unsigned AS) {
return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);
}
-// Returns the index of the WebAssembly local to which the stack object
-// FrameIndex in MF should be allocated, or None.
-Optional<unsigned> getLocalForStackObject(MachineFunction &MF, int FrameIndex);
-
bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI);
bool mayThrow(const MachineInstr &MI);
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
index 4a0738d..7ed224d 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
@@ -239,10 +239,8 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) {
Changed = true;
}
- // Start assigning local numbers after the last parameter and after any
- // already-assigned locals.
+ // Start assigning local numbers after the last parameter.
unsigned CurLocal = static_cast<unsigned>(MFI.getParams().size());
- CurLocal += static_cast<unsigned>(MFI.getLocals().size());
// Precompute the set of registers that are unused, so that we can insert
// drops to their defs.
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
index a91fa74..f139e87 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
@@ -314,16 +314,6 @@ void WebAssemblyFrameLowering::emitEpilogue(MachineFunction &MF,
writeSPToGlobal(SPReg, MF, MBB, InsertPt, DL);
}
-bool WebAssemblyFrameLowering::isSupportedStackID(
- TargetStackID::Value ID) const {
- // Use the Object stack for WebAssembly locals which can only be accessed
- // by name, not via an address in linear memory.
- if (ID == TargetStackID::WasmLocal)
- return true;
-
- return TargetFrameLowering::isSupportedStackID(ID);
-}
-
TargetFrameLowering::DwarfFrameBase
WebAssemblyFrameLowering::getDwarfFrameBase(const MachineFunction &MF) const {
DwarfFrameBase Loc;
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
index 6d9284d..e16f639 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
@@ -43,7 +43,6 @@ public:
bool hasFP(const MachineFunction &MF) const override;
bool hasReservedCallFrame(const MachineFunction &MF) const override;
- bool isSupportedStackID(TargetStackID::Value ID) const override;
DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const override;
bool needsPrologForEH(const MachineFunction &MF) const;
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISD.def b/llvm/lib/Target/WebAssembly/WebAssemblyISD.def
index 9e22945..e39e305 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISD.def
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISD.def
@@ -17,8 +17,6 @@ HANDLE_NODETYPE(CALL)
HANDLE_NODETYPE(RET_CALL)
HANDLE_NODETYPE(RETURN)
HANDLE_NODETYPE(ARGUMENT)
-HANDLE_NODETYPE(LOCAL_GET)
-HANDLE_NODETYPE(LOCAL_SET)
// A wrapper node for TargetExternalSymbol, TargetGlobalAddress, and MCSymbol
HANDLE_NODETYPE(Wrapper)
// A special wapper used in PIC code for __memory_base/__table_base relative
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
index 940c9d5..b9154b0 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
@@ -12,10 +12,8 @@
//===----------------------------------------------------------------------===//
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
-#include "Utils/WebAssemblyUtilities.h"
#include "WebAssembly.h"
#include "WebAssemblyTargetMachine.h"
-#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/SelectionDAGISel.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h" // To access function attributes.
@@ -58,8 +56,6 @@ public:
return SelectionDAGISel::runOnMachineFunction(MF);
}
- void PreprocessISelDAG() override;
-
void Select(SDNode *Node) override;
bool SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID,
@@ -73,18 +69,6 @@ private:
};
} // end anonymous namespace
-void WebAssemblyDAGToDAGISel::PreprocessISelDAG() {
- // Stack objects that should be allocated to locals are hoisted to WebAssembly
- // locals when they are first used. However for those without uses, we hoist
- // them here. It would be nice if there were some hook to do this when they
- // are added to the MachineFrameInfo, but that's not the case right now.
- MachineFrameInfo &FrameInfo = MF->getFrameInfo();
- for (int Idx = 0; Idx < FrameInfo.getObjectIndexEnd(); Idx++)
- WebAssembly::getLocalForStackObject(*MF, Idx);
-
- SelectionDAGISel::PreprocessISelDAG();
-}
-
void WebAssemblyDAGToDAGISel::Select(SDNode *Node) {
// If we have a custom node, we already have selected!
if (Node->isMachineOpcode()) {
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index 909521a..7cd7ab6 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1276,15 +1276,6 @@ static bool IsWebAssemblyGlobal(SDValue Op) {
return false;
}
-static Optional<unsigned> IsWebAssemblyLocal(SDValue Op, SelectionDAG &DAG) {
- const FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Op);
- if (!FI)
- return None;
-
- auto &MF = DAG.getMachineFunction();
- return WebAssembly::getLocalForStackObject(MF, FI->getIndex());
-}
-
SDValue WebAssemblyTargetLowering::LowerStore(SDValue Op,
SelectionDAG &DAG) const {
SDLoc DL(Op);
@@ -1304,17 +1295,6 @@ SDValue WebAssemblyTargetLowering::LowerStore(SDValue Op,
SN->getMemoryVT(), SN->getMemOperand());
}
- if (Optional<unsigned> Local = IsWebAssemblyLocal(Base, DAG)) {
- if (!Offset->isUndef())
- report_fatal_error("unexpected offset when storing to webassembly local",
- false);
-
- SDValue Idx = DAG.getTargetConstant(*Local, Base, MVT::i32);
- SDVTList Tys = DAG.getVTList(MVT::Other); // The chain.
- SDValue Ops[] = {SN->getChain(), Idx, Value};
- return DAG.getNode(WebAssemblyISD::LOCAL_SET, DL, Tys, Ops);
- }
-
return Op;
}
@@ -1336,20 +1316,6 @@ SDValue WebAssemblyTargetLowering::LowerLoad(SDValue Op,
LN->getMemoryVT(), LN->getMemOperand());
}
- if (Optional<unsigned> Local = IsWebAssemblyLocal(Base, DAG)) {
- if (!Offset->isUndef())
- report_fatal_error(
- "unexpected offset when loading from webassembly local", false);
-
- SDValue Idx = DAG.getTargetConstant(*Local, Base, MVT::i32);
- EVT LocalVT = LN->getValueType(0);
- SDValue LocalGet = DAG.getNode(WebAssemblyISD::LOCAL_GET, DL, LocalVT,
- {LN->getChain(), Idx});
- SDValue Result = DAG.getMergeValues({LocalGet, LN->getChain()}, DL);
- assert(Result->getNumValues() == 2 && "Loads must carry a chain!");
- return Result;
- }
-
return Op;
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
index ac8ad84..72efe7b 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
@@ -72,8 +72,6 @@ def SDT_WebAssemblyCallSeqEnd :
SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>;
def SDT_WebAssemblyBrTable : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
def SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>;
-def SDT_WebAssemblyLocalGet : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>;
-def SDT_WebAssemblyLocalSet : SDTypeProfile<0, 2, [SDTCisVT<0, i32>]>;
def SDT_WebAssemblyReturn : SDTypeProfile<0, -1, []>;
def SDT_WebAssemblyWrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
SDTCisPtrTy<0>]>;
@@ -116,12 +114,6 @@ def WebAssemblyglobal_get :
def WebAssemblyglobal_set :
SDNode<"WebAssemblyISD::GLOBAL_SET", SDT_WebAssemblyGlobalSet,
[SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
-def WebAssemblylocal_get :
- SDNode<"WebAssemblyISD::LOCAL_GET", SDT_WebAssemblyLocalGet,
- [SDNPHasChain, SDNPMayLoad]>;
-def WebAssemblylocal_set :
- SDNode<"WebAssemblyISD::LOCAL_SET", SDT_WebAssemblyLocalSet,
- [SDNPHasChain, SDNPMayStore]>;
//===----------------------------------------------------------------------===//
// WebAssembly-specific Operands.
@@ -340,10 +332,6 @@ multiclass LOCAL<WebAssemblyRegClass rc, Operand global_op> {
def : Pat<(WebAssemblyglobal_set
vt:$src, (WebAssemblywrapper tglobaladdr:$addr)),
(!cast<NI>("GLOBAL_SET_" # rc) tglobaladdr:$addr, vt:$src)>;
- def : Pat<(vt (WebAssemblylocal_get (i32 timm:$local))),
- (!cast<NI>("LOCAL_GET_" # rc) timm:$local)>;
- def : Pat<(WebAssemblylocal_set timm:$local, vt:$src),
- (!cast<NI>("LOCAL_SET_" # rc) timm:$local, vt:$src)>;
}
}
defm "" : LOCAL<I32, global_op32>;