2008-06-04 17:18:41 +08:00
|
|
|
//===-- LiveStackAnalysis.cpp - Live Stack Slot Analysis ------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the live stack slot analysis pass. It is analogous to
|
|
|
|
// live interval analysis except it's analyzing liveness of stack slots rather
|
|
|
|
// than registers.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/LiveStackAnalysis.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/ADT/Statistic.h"
|
2009-06-03 00:53:25 +08:00
|
|
|
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
2008-06-04 17:18:41 +08:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
|
|
|
#include "llvm/Support/Debug.h"
|
2009-08-23 11:47:42 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
2014-08-05 05:25:23 +08:00
|
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
2009-06-03 00:53:25 +08:00
|
|
|
#include <limits>
|
2008-06-04 17:18:41 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 10:02:50 +08:00
|
|
|
#define DEBUG_TYPE "livestacks"
|
|
|
|
|
2008-06-04 17:18:41 +08:00
|
|
|
char LiveStacks::ID = 0;
|
2012-09-22 04:04:28 +08:00
|
|
|
INITIALIZE_PASS_BEGIN(LiveStacks, "livestacks",
|
|
|
|
"Live Stack Slot Analysis", false, false)
|
|
|
|
INITIALIZE_PASS_DEPENDENCY(SlotIndexes)
|
|
|
|
INITIALIZE_PASS_END(LiveStacks, "livestacks",
|
2010-10-08 06:25:06 +08:00
|
|
|
"Live Stack Slot Analysis", false, false)
|
2008-06-04 17:18:41 +08:00
|
|
|
|
2010-10-26 08:11:33 +08:00
|
|
|
char &llvm::LiveStacksID = LiveStacks::ID;
|
|
|
|
|
2008-06-04 17:18:41 +08:00
|
|
|
void LiveStacks::getAnalysisUsage(AnalysisUsage &AU) const {
|
2008-09-23 06:26:15 +08:00
|
|
|
AU.setPreservesAll();
|
2009-11-04 07:52:08 +08:00
|
|
|
AU.addPreserved<SlotIndexes>();
|
|
|
|
AU.addRequiredTransitive<SlotIndexes>();
|
2008-09-23 04:58:04 +08:00
|
|
|
MachineFunctionPass::getAnalysisUsage(AU);
|
2008-06-04 17:18:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void LiveStacks::releaseMemory() {
|
2010-06-26 19:30:59 +08:00
|
|
|
// Release VNInfo memory regions, VNInfo objects don't need to be dtor'd.
|
|
|
|
VNInfoAllocator.Reset();
|
2009-05-04 02:32:42 +08:00
|
|
|
S2IMap.clear();
|
|
|
|
S2RCMap.clear();
|
2008-06-04 17:18:41 +08:00
|
|
|
}
|
|
|
|
|
2011-10-01 06:18:51 +08:00
|
|
|
bool LiveStacks::runOnMachineFunction(MachineFunction &MF) {
|
2014-08-05 10:39:49 +08:00
|
|
|
TRI = MF.getSubtarget().getRegisterInfo();
|
2008-06-04 17:18:41 +08:00
|
|
|
// FIXME: No analysis is being done right now. We are relying on the
|
|
|
|
// register allocators to provide the information.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-10 05:17:37 +08:00
|
|
|
LiveInterval &
|
|
|
|
LiveStacks::getOrCreateInterval(int Slot, const TargetRegisterClass *RC) {
|
|
|
|
assert(Slot >= 0 && "Spill slot indice must be >= 0");
|
|
|
|
SS2IntervalMap::iterator I = S2IMap.find(Slot);
|
|
|
|
if (I == S2IMap.end()) {
|
|
|
|
I = S2IMap.insert(I, std::make_pair(Slot,
|
|
|
|
LiveInterval(TargetRegisterInfo::index2StackSlot(Slot), 0.0F)));
|
|
|
|
S2RCMap.insert(std::make_pair(Slot, RC));
|
|
|
|
} else {
|
|
|
|
// Use the largest common subclass register class.
|
|
|
|
const TargetRegisterClass *OldRC = S2RCMap[Slot];
|
2011-10-01 06:18:51 +08:00
|
|
|
S2RCMap[Slot] = TRI->getCommonSubClass(OldRC, RC);
|
2011-01-10 05:17:37 +08:00
|
|
|
}
|
|
|
|
return I->second;
|
|
|
|
}
|
|
|
|
|
2008-06-04 17:18:41 +08:00
|
|
|
/// print - Implement the dump method.
|
2009-08-23 14:03:38 +08:00
|
|
|
void LiveStacks::print(raw_ostream &OS, const Module*) const {
|
2009-08-23 11:47:42 +08:00
|
|
|
|
|
|
|
OS << "********** INTERVALS **********\n";
|
2008-06-04 17:18:41 +08:00
|
|
|
for (const_iterator I = begin(), E = end(); I != E; ++I) {
|
2009-08-23 11:47:42 +08:00
|
|
|
I->second.print(OS);
|
2009-05-04 02:32:42 +08:00
|
|
|
int Slot = I->first;
|
|
|
|
const TargetRegisterClass *RC = getIntervalRegClass(Slot);
|
|
|
|
if (RC)
|
2014-11-17 13:50:14 +08:00
|
|
|
OS << " [" << TRI->getRegClassName(RC) << "]\n";
|
2009-05-04 02:32:42 +08:00
|
|
|
else
|
2009-08-23 11:47:42 +08:00
|
|
|
OS << " [Unknown]\n";
|
2008-06-04 17:18:41 +08:00
|
|
|
}
|
|
|
|
}
|