[PATCH] D42534: [mips] Compute MaxCallFrame size early on

Stefan Maksimovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 06:35:56 PST 2018


smaksimovic created this revision.
smaksimovic added reviewers: zoran.jovanovic, sdardis.
Herald added a subscriber: arichardson.

Use computeMaxCallFrameSize() introduced in https://reviews.llvm.org/D32622
to calculate MaxCallFrameSize after instruction selection.

Test that the value is computed before the Prologue/Epilogue pass
after which MaxCallFrameSize will have been computed anyway.


https://reviews.llvm.org/D42534

Files:
  lib/Target/Mips/MipsISelLowering.cpp
  lib/Target/Mips/MipsISelLowering.h
  lib/Target/Mips/MipsRegisterInfo.cpp
  test/CodeGen/Mips/maxcallframesize.ll


Index: test/CodeGen/Mips/maxcallframesize.ll
===================================================================
--- test/CodeGen/Mips/maxcallframesize.ll
+++ test/CodeGen/Mips/maxcallframesize.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s -mtriple=mips-unknown-linux -stop-before=prologepilog | FileCheck %s
+
+# Test that maxCallFrameSize is being computed early on.
+
+ at glob = external global i32*
+
+declare void @bar(i32*, [20000 x i8]* byval)
+
+define void @foo([20000 x i8]* %addr) {
+  %tmp = alloca [4 x i32], align 32
+  %tmp0 = getelementptr [4 x i32], [4 x i32]* %tmp, i32 0, i32 0
+  call void @bar(i32* %tmp0, [20000 x i8]* byval %addr)
+  ret void
+}
+
+; CHECK: adjustsStack:    true
+; CHECK: maxCallFrameSize: 20008
Index: lib/Target/Mips/MipsRegisterInfo.cpp
===================================================================
--- lib/Target/Mips/MipsRegisterInfo.cpp
+++ lib/Target/Mips/MipsRegisterInfo.cpp
@@ -74,7 +74,9 @@
   case Mips::GPR64RegClassID:
   case Mips::DSPRRegClassID: {
     const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering();
-    return 28 - TFI->hasFP(MF);
+    bool HasFP = MF.getFrameInfo().isMaxCallFrameSizeComputed()
+                 ? TFI->hasFP(MF) : true;
+    return 28 - HasFP;
   }
   case Mips::FGR32RegClassID:
     return 32;
Index: lib/Target/Mips/MipsISelLowering.h
===================================================================
--- lib/Target/Mips/MipsISelLowering.h
+++ lib/Target/Mips/MipsISelLowering.h
@@ -370,6 +370,8 @@
     bool isJumpTableRelative() const override {
       return getTargetMachine().isPositionIndependent();
     }
+    
+    void finalizeLowering(MachineFunction &MF) const override;
 
   protected:
     SDValue getGlobalReg(SelectionDAG &DAG, EVT Ty) const;
Index: lib/Target/Mips/MipsISelLowering.cpp
===================================================================
--- lib/Target/Mips/MipsISelLowering.cpp
+++ lib/Target/Mips/MipsISelLowering.cpp
@@ -108,6 +108,11 @@
   return true;
 }
 
+void MipsTargetLowering::finalizeLowering(MachineFunction &MF) const {
+  MF.getFrameInfo().computeMaxCallFrameSize(MF);
+  TargetLoweringBase::finalizeLowering(MF);
+}
+
 // The MIPS MSA ABI passes vector arguments in the integer register set.
 // The number of integer registers used is dependant on the ABI used.
 MVT MipsTargetLowering::getRegisterTypeForCallingConv(MVT VT) const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42534.131431.patch
Type: text/x-patch
Size: 2386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180125/508e9beb/attachment.bin>


More information about the llvm-commits mailing list