From e762562b343abe725aef2f9af26ceaa678e6152f Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 26 Mar 2019 17:46:14 +0000 Subject: [PATCH] [WebAssembly] Add CFGStacikfied field to WebAssemblyFunctionInfo Summary: This adds `CFGStackified` field and its serialization to WebAssemblyFunctionInfo. Reviewers: dschuff Subscribers: sunfish, sbc100, jgravelle-google, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59747 llvm-svn: 357011 --- lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp | 1 + .../WebAssembly/WebAssemblyMachineFunctionInfo.cpp | 7 +++++-- .../WebAssembly/WebAssemblyMachineFunctionInfo.h | 12 +++++++++++- test/CodeGen/WebAssembly/function-info.mir | 3 ++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp index 7a7838adb97..39641b414cb 100644 --- a/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp +++ b/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp @@ -880,5 +880,6 @@ bool WebAssemblyCFGStackify::runOnMachineFunction(MachineFunction &MF) { .isOSBinFormatELF()) appendEndToFunction(MF, TII); + MF.getInfo()->setCFGStackified(); return true; } diff --git a/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp b/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp index b7fc73380e7..d31c1226bfd 100644 --- a/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp +++ b/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp @@ -79,11 +79,14 @@ llvm::signatureFromMVTs(const SmallVectorImpl &Results, } yaml::WebAssemblyFunctionInfo::WebAssemblyFunctionInfo( - const llvm::WebAssemblyFunctionInfo &MFI) {} + const llvm::WebAssemblyFunctionInfo &MFI) + : CFGStackified(MFI.isCFGStackified()) {} void yaml::WebAssemblyFunctionInfo::mappingImpl(yaml::IO &YamlIO) { MappingTraits::mapping(YamlIO, *this); } void WebAssemblyFunctionInfo::initializeBaseYamlFields( - const yaml::WebAssemblyFunctionInfo &YamlMFI) {} + const yaml::WebAssemblyFunctionInfo &YamlMFI) { + CFGStackified = YamlMFI.CFGStackified; +} diff --git a/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h b/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h index 6844656b75e..4b9ba491dee 100644 --- a/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h +++ b/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h @@ -56,6 +56,9 @@ class WebAssemblyFunctionInfo final : public MachineFunctionInfo { // overaligned values on the user stack. unsigned BasePtrVreg = -1U; + // Function properties. + bool CFGStackified = false; + public: explicit WebAssemblyFunctionInfo(MachineFunction &MF) : MF(MF) {} ~WebAssemblyFunctionInfo() override; @@ -123,6 +126,9 @@ public: assert(Reg & INT32_MIN); return Reg & INT32_MAX; } + + bool isCFGStackified() const { return CFGStackified; } + void setCFGStackified(bool Value = true) { CFGStackified = Value; } }; void computeLegalValueVTs(const Function &F, const TargetMachine &TM, Type *Ty, @@ -144,6 +150,8 @@ signatureFromMVTs(const SmallVectorImpl &Results, namespace yaml { struct WebAssemblyFunctionInfo final : public yaml::MachineFunctionInfo { + bool CFGStackified = false; + WebAssemblyFunctionInfo() = default; WebAssemblyFunctionInfo(const llvm::WebAssemblyFunctionInfo &MFI); @@ -152,7 +160,9 @@ struct WebAssemblyFunctionInfo final : public yaml::MachineFunctionInfo { }; template <> struct MappingTraits { - static void mapping(IO &YamlIO, WebAssemblyFunctionInfo &MFI) {} + static void mapping(IO &YamlIO, WebAssemblyFunctionInfo &MFI) { + YamlIO.mapOptional("isCFGStackified", MFI.CFGStackified, false); + } }; } // end namespace yaml diff --git a/test/CodeGen/WebAssembly/function-info.mir b/test/CodeGen/WebAssembly/function-info.mir index bb3630461f7..e40bda5ebff 100644 --- a/test/CodeGen/WebAssembly/function-info.mir +++ b/test/CodeGen/WebAssembly/function-info.mir @@ -1,7 +1,8 @@ # RUN: llc -mtriple=wasm32-unknown-unknown -run-pass wasm-cfg-stackify %s -o - | FileCheck %s # CHECK-LABEL: function_property_test -# CHECK: machineFunctionInfo: {} +# CHECK: machineFunctionInfo: +# CHECK: isCFGStackified: true name: function_property_test liveins: - { reg: '$arguments' }