diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-08 17:12:57 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-08 17:12:57 +0000 | 
| commit | c46e6a5940c50058e00c0c5f9123fd82e338d29a (patch) | |
| tree | 89a719d723035c54a190b1f81d329834f1f93336 /lib/CodeGen/MachineFrameInfo.cpp | |
| parent | 148779df305667b6942fee7e758fdf81a6498f38 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/MachineFrameInfo.cpp')
| -rw-r--r-- | lib/CodeGen/MachineFrameInfo.cpp | 26 | 
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineFrameInfo.cpp b/lib/CodeGen/MachineFrameInfo.cpp index 7de8434df806..73d778ff3023 100644 --- a/lib/CodeGen/MachineFrameInfo.cpp +++ b/lib/CodeGen/MachineFrameInfo.cpp @@ -19,6 +19,7 @@  #include "llvm/Support/Debug.h"  #include "llvm/Support/raw_ostream.h"  #include "llvm/Target/TargetFrameLowering.h" +#include "llvm/Target/TargetInstrInfo.h"  #include "llvm/Target/TargetRegisterInfo.h"  #include "llvm/Target/TargetSubtargetInfo.h"  #include <cassert> @@ -175,6 +176,31 @@ unsigned MachineFrameInfo::estimateStackSize(const MachineFunction &MF) const {    return (unsigned)Offset;  } +void MachineFrameInfo::computeMaxCallFrameSize(const MachineFunction &MF) { +  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo(); +  unsigned FrameSetupOpcode = TII.getCallFrameSetupOpcode(); +  unsigned FrameDestroyOpcode = TII.getCallFrameDestroyOpcode(); +  assert(FrameSetupOpcode != ~0u && FrameDestroyOpcode != ~0u && +         "Can only compute MaxCallFrameSize if Setup/Destroy opcode are known"); + +  MaxCallFrameSize = 0; +  for (const MachineBasicBlock &MBB : MF) { +    for (const MachineInstr &MI : MBB) { +      unsigned Opcode = MI.getOpcode(); +      if (Opcode == FrameSetupOpcode || Opcode == FrameDestroyOpcode) { +        unsigned Size = TII.getFrameSize(MI); +        MaxCallFrameSize = std::max(MaxCallFrameSize, Size); +        AdjustsStack = true; +      } else if (MI.isInlineAsm()) { +        // Some inline asm's need a stack frame, as indicated by operand 1. +        unsigned ExtraInfo = MI.getOperand(InlineAsm::MIOp_ExtraInfo).getImm(); +        if (ExtraInfo & InlineAsm::Extra_IsAlignStack) +          AdjustsStack = true; +      } +    } +  } +} +  void MachineFrameInfo::print(const MachineFunction &MF, raw_ostream &OS) const{    if (Objects.empty()) return;  | 
