[llvm] r340438 - [WebAssembly] Remove MachineFrameInfo arg from checking functions (NFC)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 22 11:53:48 PDT 2018


Author: aheejin
Date: Wed Aug 22 11:53:48 2018
New Revision: 340438

URL: http://llvm.org/viewvc/llvm-project?rev=340438&view=rev
Log:
[WebAssembly] Remove MachineFrameInfo arg from checking functions (NFC)

Summary:
There are several functions in the form of `has***` or `needs***` in
`WebAssemblyFrameLowering` and its `MachineFrameInfo` argument can be
obtained from `MachineFunction` so it is not necessarily has to be
passed from a caller. Also, it is more in line with other overriden
fuctions like `hasBP` or `hasReservedCallFrame`, which also take only
`MachineFunction` argument.

Reviewers: dschuff

Subscribers: sbc100, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D51116

Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.h

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp?rev=340438&r1=340437&r2=340438&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp Wed Aug 22 11:53:48 2018
@@ -92,8 +92,8 @@ bool WebAssemblyFrameLowering::needsProl
 /// Returns true if this function needs a local user-space stack pointer.
 /// Unlike a machine stack pointer, the wasm user stack pointer is a global
 /// variable, so it is loaded into a register in the prolog.
-bool WebAssemblyFrameLowering::needsSP(const MachineFunction &MF,
-                                       const MachineFrameInfo &MFI) const {
+bool WebAssemblyFrameLowering::needsSP(const MachineFunction &MF) const {
+  auto &MFI = MF.getFrameInfo();
   return MFI.getStackSize() || MFI.adjustsStack() || hasFP(MF) ||
          needsPrologForEH(MF);
 }
@@ -103,8 +103,9 @@ bool WebAssemblyFrameLowering::needsSP(c
 /// needsSP is false). If false, the stack red zone can be used and only a local
 /// SP is needed.
 bool WebAssemblyFrameLowering::needsSPWriteback(
-    const MachineFunction &MF, const MachineFrameInfo &MFI) const {
-  assert(needsSP(MF, MFI));
+    const MachineFunction &MF) const {
+  auto &MFI = MF.getFrameInfo();
+  assert(needsSP(MF));
   return MFI.getStackSize() > RedZoneSize || MFI.hasCalls() ||
          MF.getFunction().hasFnAttribute(Attribute::NoRedZone);
 }
@@ -129,7 +130,7 @@ WebAssemblyFrameLowering::eliminateCallF
          "Call frame pseudos should only be used for dynamic stack adjustment");
   const auto *TII = MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
   if (I->getOpcode() == TII->getCallFrameDestroyOpcode() &&
-      needsSPWriteback(MF, MF.getFrameInfo())) {
+      needsSPWriteback(MF)) {
     DebugLoc DL = I->getDebugLoc();
     writeSPToGlobal(WebAssembly::SP32, MF, MBB, I, DL);
   }
@@ -143,7 +144,7 @@ void WebAssemblyFrameLowering::emitProlo
   assert(MFI.getCalleeSavedInfo().empty() &&
          "WebAssembly should not have callee-saved registers");
 
-  if (!needsSP(MF, MFI)) return;
+  if (!needsSP(MF)) return;
   uint64_t StackSize = MFI.getStackSize();
 
   const auto *TII = MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
@@ -203,16 +204,15 @@ void WebAssemblyFrameLowering::emitProlo
             WebAssembly::FP32)
         .addReg(WebAssembly::SP32);
   }
-  if (StackSize && needsSPWriteback(MF, MFI)) {
+  if (StackSize && needsSPWriteback(MF)) {
     writeSPToGlobal(WebAssembly::SP32, MF, MBB, InsertPt, DL);
   }
 }
 
 void WebAssemblyFrameLowering::emitEpilogue(MachineFunction &MF,
                                             MachineBasicBlock &MBB) const {
-  auto &MFI = MF.getFrameInfo();
-  uint64_t StackSize = MFI.getStackSize();
-  if (!needsSP(MF, MFI) || !needsSPWriteback(MF, MFI)) return;
+  uint64_t StackSize = MF.getFrameInfo().getStackSize();
+  if (!needsSP(MF) || !needsSPWriteback(MF)) return;
   const auto *TII = MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
   auto &MRI = MF.getRegInfo();
   auto InsertPt = MBB.getFirstTerminator();

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.h?rev=340438&r1=340437&r2=340438&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.h (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.h Wed Aug 22 11:53:48 2018
@@ -56,9 +56,8 @@ class WebAssemblyFrameLowering final : p
 
 private:
   bool hasBP(const MachineFunction &MF) const;
-  bool needsSP(const MachineFunction &MF, const MachineFrameInfo &MFI) const;
-  bool needsSPWriteback(const MachineFunction &MF,
-                        const MachineFrameInfo &MFI) const;
+  bool needsSP(const MachineFunction &MF) const;
+  bool needsSPWriteback(const MachineFunction &MF) const;
 };
 
 }  // end namespace llvm




More information about the llvm-commits mailing list