]> granicus.if.org Git - llvm/commitdiff
[WebAssembly] Add CFGStacikfied field to WebAssemblyFunctionInfo
authorHeejin Ahn <aheejin@gmail.com>
Tue, 26 Mar 2019 17:46:14 +0000 (17:46 +0000)
committerHeejin Ahn <aheejin@gmail.com>
Tue, 26 Mar 2019 17:46:14 +0000 (17:46 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357011 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
test/CodeGen/WebAssembly/function-info.mir

index 7a7838adb9747ea77ccc37544d03d23379d9854c..39641b414cb330fbb85859b2f6f53422fe1c7c83 100644 (file)
@@ -880,5 +880,6 @@ bool WebAssemblyCFGStackify::runOnMachineFunction(MachineFunction &MF) {
            .isOSBinFormatELF())
     appendEndToFunction(MF, TII);
 
+  MF.getInfo<WebAssemblyFunctionInfo>()->setCFGStackified();
   return true;
 }
index b7fc73380e7ce9400ec0589f53d07c9fb0f8ea75..d31c1226bfdb1546bde0901ea9479a179225771d 100644 (file)
@@ -79,11 +79,14 @@ llvm::signatureFromMVTs(const SmallVectorImpl<MVT> &Results,
 }
 
 yaml::WebAssemblyFunctionInfo::WebAssemblyFunctionInfo(
-    const llvm::WebAssemblyFunctionInfo &MFI) {}
+    const llvm::WebAssemblyFunctionInfo &MFI)
+    : CFGStackified(MFI.isCFGStackified()) {}
 
 void yaml::WebAssemblyFunctionInfo::mappingImpl(yaml::IO &YamlIO) {
   MappingTraits<WebAssemblyFunctionInfo>::mapping(YamlIO, *this);
 }
 
 void WebAssemblyFunctionInfo::initializeBaseYamlFields(
-    const yaml::WebAssemblyFunctionInfo &YamlMFI) {}
+    const yaml::WebAssemblyFunctionInfo &YamlMFI) {
+  CFGStackified = YamlMFI.CFGStackified;
+}
index 6844656b75ea3269b2cd857c9984da925b6691f3..4b9ba491dee6326b8a0613c84c63b19835db9810 100644 (file)
@@ -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<MVT> &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<WebAssemblyFunctionInfo> {
-  static void mapping(IO &YamlIO, WebAssemblyFunctionInfo &MFI) {}
+  static void mapping(IO &YamlIO, WebAssemblyFunctionInfo &MFI) {
+    YamlIO.mapOptional("isCFGStackified", MFI.CFGStackified, false);
+  }
 };
 
 } // end namespace yaml
index bb3630461f7edc789bdd434e5a62ff09958365b5..e40bda5ebff6a80951efd488d2a11aed1f8005ce 100644 (file)
@@ -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' }