// Keep track of the function section.
MCSection *Section = nullptr;
+ // Catchpad unwind destination info for wasm EH.
// Keeps track of Wasm exception handling related data. This will be null for
// functions that aren't using a wasm EH personality.
WasmEHFuncInfo *WasmEHInfo = nullptr;
BumpPtrAllocator &Allocator, MachineFunction &DestMF,
const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
const {
- WebAssemblyFunctionInfo *Clone =
- DestMF.cloneInfo<WebAssemblyFunctionInfo>(*this);
- Clone->MF = &DestMF;
- return Clone;
+ // TODO: Implement cloning for WasmEHFuncInfo. This will have invalid block
+ // references.
+ return DestMF.cloneInfo<WebAssemblyFunctionInfo>(*this);
}
void WebAssemblyFunctionInfo::initWARegs(MachineRegisterInfo &MRI) {
}
yaml::WebAssemblyFunctionInfo::WebAssemblyFunctionInfo(
- const llvm::WebAssemblyFunctionInfo &MFI)
+ const llvm::MachineFunction &MF, const llvm::WebAssemblyFunctionInfo &MFI)
: CFGStackified(MFI.isCFGStackified()) {
- auto *EHInfo = MFI.getWasmEHFuncInfo();
- const llvm::MachineFunction &MF = MFI.getMachineFunction();
-
for (auto VT : MFI.getParams())
Params.push_back(EVT(VT).getEVTString());
for (auto VT : MFI.getResults())
// MFI.getWasmEHFuncInfo() is non-null only for functions with the
// personality function.
- if (EHInfo) {
+
+ if (auto *EHInfo = MF.getWasmEHFuncInfo()) {
// SrcToUnwindDest can contain stale mappings in case BBs are removed in
// optimizations, in case, for example, they are unreachable. We should not
// include their info.
}
void WebAssemblyFunctionInfo::initializeBaseYamlFields(
- const yaml::WebAssemblyFunctionInfo &YamlMFI) {
+ MachineFunction &MF, const yaml::WebAssemblyFunctionInfo &YamlMFI) {
CFGStackified = YamlMFI.CFGStackified;
for (auto VT : YamlMFI.Params)
addParam(WebAssembly::parseMVT(VT.Value));
for (auto VT : YamlMFI.Results)
addResult(WebAssembly::parseMVT(VT.Value));
- if (WasmEHInfo) {
+
+ // FIXME: WasmEHInfo is defined in the MachineFunction, but serialized
+ // here. Either WasmEHInfo should be moved out of MachineFunction, or the
+ // serialization handling should be moved to MachineFunction.
+ if (WasmEHFuncInfo *WasmEHInfo = MF.getWasmEHFuncInfo()) {
for (auto KV : YamlMFI.SrcToUnwindDest)
- WasmEHInfo->setUnwindDest(MF->getBlockNumbered(KV.first),
- MF->getBlockNumbered(KV.second));
+ WasmEHInfo->setUnwindDest(MF.getBlockNumbered(KV.first),
+ MF.getBlockNumbered(KV.second));
}
}
/// This class is derived from MachineFunctionInfo and contains private
/// WebAssembly-specific information for each MachineFunction.
class WebAssemblyFunctionInfo final : public MachineFunctionInfo {
- const MachineFunction *MF;
-
std::vector<MVT> Params;
std::vector<MVT> Results;
std::vector<MVT> Locals;
// Function properties.
bool CFGStackified = false;
- // Catchpad unwind destination info for wasm EH.
- WasmEHFuncInfo *WasmEHInfo = nullptr;
-
public:
- explicit WebAssemblyFunctionInfo(MachineFunction &MF_)
- : MF(&MF_), WasmEHInfo(MF_.getWasmEHFuncInfo()) {}
+ explicit WebAssemblyFunctionInfo(MachineFunction &) {}
~WebAssemblyFunctionInfo() override;
MachineFunctionInfo *
const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
const override;
- const MachineFunction &getMachineFunction() const { return *MF; }
-
- void initializeBaseYamlFields(const yaml::WebAssemblyFunctionInfo &YamlMFI);
+ void initializeBaseYamlFields(MachineFunction &MF,
+ const yaml::WebAssemblyFunctionInfo &YamlMFI);
void addParam(MVT VT) { Params.push_back(VT); }
const std::vector<MVT> &getParams() const { return Params; }
bool isCFGStackified() const { return CFGStackified; }
void setCFGStackified(bool Value = true) { CFGStackified = Value; }
-
- WasmEHFuncInfo *getWasmEHFuncInfo() const { return WasmEHInfo; }
- void setWasmEHFuncInfo(WasmEHFuncInfo *Info) { WasmEHInfo = Info; }
};
void computeLegalValueVTs(const WebAssemblyTargetLowering &TLI,
BBNumberMap SrcToUnwindDest;
WebAssemblyFunctionInfo() = default;
- WebAssemblyFunctionInfo(const llvm::WebAssemblyFunctionInfo &MFI);
+ WebAssemblyFunctionInfo(const llvm::MachineFunction &MF,
+ const llvm::WebAssemblyFunctionInfo &MFI);
void mappingImpl(yaml::IO &YamlIO) override;
~WebAssemblyFunctionInfo() = default;
yaml::MachineFunctionInfo *WebAssemblyTargetMachine::convertFuncInfoToYAML(
const MachineFunction &MF) const {
const auto *MFI = MF.getInfo<WebAssemblyFunctionInfo>();
- return new yaml::WebAssemblyFunctionInfo(*MFI);
+ return new yaml::WebAssemblyFunctionInfo(MF, *MFI);
}
bool WebAssemblyTargetMachine::parseMachineFunctionInfo(
SMDiagnostic &Error, SMRange &SourceRange) const {
const auto &YamlMFI = static_cast<const yaml::WebAssemblyFunctionInfo &>(MFI);
MachineFunction &MF = PFS.MF;
- MF.getInfo<WebAssemblyFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
+ MF.getInfo<WebAssemblyFunctionInfo>()->initializeBaseYamlFields(MF, YamlMFI);
return false;
}