From e45ab8a0a90e4f3a59d8c38038ae3e495ee1fef3 Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Tue, 19 Jan 2010 18:31:11 +0000 Subject: For aligned load/store instructions, it's only required to know whether a function can support dynamic stack realignment. That's a much easier question to answer at instruction selection stage than whether the function actually will have dynamic alignment prologue. This allows the removal of the stack alignment heuristic pass, and improves code quality for cases where the heuristic would result in dynamic alignment code being generated when it was not strictly necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93885 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MaxStackAlignment.cpp | 70 --------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 lib/CodeGen/MaxStackAlignment.cpp (limited to 'lib/CodeGen/MaxStackAlignment.cpp') diff --git a/lib/CodeGen/MaxStackAlignment.cpp b/lib/CodeGen/MaxStackAlignment.cpp deleted file mode 100644 index d327cfa882..0000000000 --- a/lib/CodeGen/MaxStackAlignment.cpp +++ /dev/null @@ -1,70 +0,0 @@ -//===-- MaxStackAlignment.cpp - Compute the required stack alignment -- ---===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This pass looks for vector register usage and aligned local objects to -// calculate the maximum required alignment for a function. This is used by -// targets which support it to determine if dynamic stack realignment is -// necessary. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineFrameInfo.h" -#include "llvm/CodeGen/MachineRegisterInfo.h" -#include "llvm/CodeGen/Passes.h" - -using namespace llvm; - -namespace { - struct MaximalStackAlignmentCalculator : public MachineFunctionPass { - static char ID; - MaximalStackAlignmentCalculator() : MachineFunctionPass(&ID) {} - - virtual bool runOnMachineFunction(MachineFunction &MF) { - MachineFrameInfo *FFI = MF.getFrameInfo(); - MachineRegisterInfo &RI = MF.getRegInfo(); - - // Calculate max stack alignment of all already allocated stack objects. - FFI->calculateMaxStackAlignment(); - unsigned MaxAlign = FFI->getMaxAlignment(); - - // Be over-conservative: scan over all vreg defs and find whether vector - // registers are used. If yes, there is probability that vector registers - // will be spilled and thus the stack needs to be aligned properly. - // FIXME: It would be better to only do this if a spill actually - // happens rather than conseratively aligning the stack regardless. - for (unsigned RegNum = TargetRegisterInfo::FirstVirtualRegister; - RegNum < RI.getLastVirtReg(); ++RegNum) - MaxAlign = std::max(MaxAlign, RI.getRegClass(RegNum)->getAlignment()); - - if (FFI->getMaxAlignment() == MaxAlign) - return false; - - FFI->setMaxAlignment(MaxAlign); - return true; - } - - virtual const char *getPassName() const { - return "Stack Alignment Requirements Auto-Detector"; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesCFG(); - MachineFunctionPass::getAnalysisUsage(AU); - } - }; - - char MaximalStackAlignmentCalculator::ID = 0; -} - -FunctionPass* -llvm::createMaxStackAlignmentCalculatorPass() { - return new MaximalStackAlignmentCalculator(); -} - -- cgit v1.2.3-18-g5258