diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
| commit | 344a3780b2e33f6ca763666c380202b18aab72a3 (patch) | |
| tree | f0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp | |
| parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
vendor/llvm-project/llvmorg-13-init-16847-g88e66fa60ae5vendor/llvm-project/llvmorg-12.0.1-rc2-0-ge7dac564cd0evendor/llvm-project/llvmorg-12.0.1-0-gfed41342a82f
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp')
| -rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp index adee2f0553f9..00b11321fdb2 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp @@ -13,9 +13,12 @@ //===----------------------------------------------------------------------===// #include "WebAssemblyMachineFunctionInfo.h" +#include "MCTargetDesc/WebAssemblyInstPrinter.h" +#include "Utils/WebAssemblyTypeUtilities.h" #include "WebAssemblyISelLowering.h" #include "WebAssemblySubtarget.h" #include "llvm/CodeGen/Analysis.h" +#include "llvm/CodeGen/WasmEHFuncInfo.h" #include "llvm/Target/TargetMachine.h" using namespace llvm; @@ -104,7 +107,32 @@ llvm::signatureFromMVTs(const SmallVectorImpl<MVT> &Results, yaml::WebAssemblyFunctionInfo::WebAssemblyFunctionInfo( const llvm::WebAssemblyFunctionInfo &MFI) - : CFGStackified(MFI.isCFGStackified()) {} + : 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()) + Results.push_back(EVT(VT).getEVTString()); + + // MFI.getWasmEHFuncInfo() is non-null only for functions with the + // personality function. + if (EHInfo) { + // 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. + SmallPtrSet<const MachineBasicBlock *, 16> MBBs; + for (const auto &MBB : MF) + MBBs.insert(&MBB); + for (auto KV : EHInfo->SrcToUnwindDest) { + auto *SrcBB = KV.first.get<MachineBasicBlock *>(); + auto *DestBB = KV.second.get<MachineBasicBlock *>(); + if (MBBs.count(SrcBB) && MBBs.count(DestBB)) + SrcToUnwindDest[SrcBB->getNumber()] = DestBB->getNumber(); + } + } +} void yaml::WebAssemblyFunctionInfo::mappingImpl(yaml::IO &YamlIO) { MappingTraits<WebAssemblyFunctionInfo>::mapping(YamlIO, *this); @@ -113,4 +141,13 @@ void yaml::WebAssemblyFunctionInfo::mappingImpl(yaml::IO &YamlIO) { void WebAssemblyFunctionInfo::initializeBaseYamlFields( 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) { + for (auto KV : YamlMFI.SrcToUnwindDest) + WasmEHInfo->setUnwindDest(MF.getBlockNumbered(KV.first), + MF.getBlockNumbered(KV.second)); + } } |
