blob: 895bd2e4b132e02d16d6b2f8e2a0afe745366db1 [file] [log] [blame]
Evan Cheng3f32d652008-06-04 09:18:41 +00001//===-- LiveStackAnalysis.cpp - Live Stack Slot Analysis ------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the live stack slot analysis pass. It is analogous to
11// live interval analysis except it's analyzing liveness of stack slots rather
12// than registers.
13//
14//===----------------------------------------------------------------------===//
15
16#define DEBUG_TYPE "livestacks"
17#include "llvm/CodeGen/LiveStackAnalysis.h"
Lang Hamesf41538d2009-06-02 16:53:25 +000018#include "llvm/CodeGen/LiveIntervalAnalysis.h"
Evan Cheng3f32d652008-06-04 09:18:41 +000019#include "llvm/CodeGen/Passes.h"
20#include "llvm/Target/TargetRegisterInfo.h"
21#include "llvm/Support/Debug.h"
Chris Lattnerc02497f2009-08-23 03:47:42 +000022#include "llvm/Support/raw_ostream.h"
Evan Cheng3f32d652008-06-04 09:18:41 +000023#include "llvm/ADT/Statistic.h"
Lang Hamesf41538d2009-06-02 16:53:25 +000024#include <limits>
Evan Cheng3f32d652008-06-04 09:18:41 +000025using namespace llvm;
26
27char LiveStacks::ID = 0;
Owen Andersond13db2c2010-07-21 22:09:45 +000028INITIALIZE_PASS(LiveStacks, "livestacks",
Owen Andersonce665bd2010-10-07 22:25:06 +000029 "Live Stack Slot Analysis", false, false)
Evan Cheng3f32d652008-06-04 09:18:41 +000030
Jakob Stoklund Olesen2d172932010-10-26 00:11:33 +000031char &llvm::LiveStacksID = LiveStacks::ID;
32
Evan Cheng3f32d652008-06-04 09:18:41 +000033void LiveStacks::getAnalysisUsage(AnalysisUsage &AU) const {
Evan Chengef901c52008-09-22 22:26:15 +000034 AU.setPreservesAll();
Lang Hames233a60e2009-11-03 23:52:08 +000035 AU.addPreserved<SlotIndexes>();
36 AU.addRequiredTransitive<SlotIndexes>();
Evan Chengbbeeb2a2008-09-22 20:58:04 +000037 MachineFunctionPass::getAnalysisUsage(AU);
Evan Cheng3f32d652008-06-04 09:18:41 +000038}
39
40void LiveStacks::releaseMemory() {
Benjamin Kramerce9a20b2010-06-26 11:30:59 +000041 // Release VNInfo memory regions, VNInfo objects don't need to be dtor'd.
42 VNInfoAllocator.Reset();
Evan Chengc781a242009-05-03 18:32:42 +000043 S2IMap.clear();
44 S2RCMap.clear();
Evan Cheng3f32d652008-06-04 09:18:41 +000045}
46
47bool LiveStacks::runOnMachineFunction(MachineFunction &) {
48 // FIXME: No analysis is being done right now. We are relying on the
49 // register allocators to provide the information.
50 return false;
51}
52
53/// print - Implement the dump method.
Chris Lattner45cfe542009-08-23 06:03:38 +000054void LiveStacks::print(raw_ostream &OS, const Module*) const {
Chris Lattnerc02497f2009-08-23 03:47:42 +000055
56 OS << "********** INTERVALS **********\n";
Evan Cheng3f32d652008-06-04 09:18:41 +000057 for (const_iterator I = begin(), E = end(); I != E; ++I) {
Chris Lattnerc02497f2009-08-23 03:47:42 +000058 I->second.print(OS);
Evan Chengc781a242009-05-03 18:32:42 +000059 int Slot = I->first;
60 const TargetRegisterClass *RC = getIntervalRegClass(Slot);
61 if (RC)
Chris Lattnerc02497f2009-08-23 03:47:42 +000062 OS << " [" << RC->getName() << "]\n";
Evan Chengc781a242009-05-03 18:32:42 +000063 else
Chris Lattnerc02497f2009-08-23 03:47:42 +000064 OS << " [Unknown]\n";
Evan Cheng3f32d652008-06-04 09:18:41 +000065 }
66}