forked from OSchip/llvm-project
lazily allocate the GCMetadataPrinters map and remove DenseMap
from the AsmPrinter interface. llvm-svn: 100331
This commit is contained in:
parent
9b9dc4d4c6
commit
2cf5f9ec05
|
@ -19,7 +19,6 @@
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/Support/DebugLoc.h"
|
#include "llvm/Support/DebugLoc.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class BlockAddress;
|
class BlockAddress;
|
||||||
|
@ -60,11 +59,6 @@ namespace llvm {
|
||||||
class AsmPrinter : public MachineFunctionPass {
|
class AsmPrinter : public MachineFunctionPass {
|
||||||
static char ID;
|
static char ID;
|
||||||
|
|
||||||
// GCMetadataPrinters - The garbage collection metadata printer table.
|
|
||||||
typedef DenseMap<GCStrategy*,GCMetadataPrinter*> gcp_map_type;
|
|
||||||
typedef gcp_map_type::iterator gcp_iterator;
|
|
||||||
gcp_map_type GCMetadataPrinters;
|
|
||||||
|
|
||||||
/// If VerboseAsm is set, a pointer to the loop info for this
|
/// If VerboseAsm is set, a pointer to the loop info for this
|
||||||
/// function.
|
/// function.
|
||||||
///
|
///
|
||||||
|
@ -125,6 +119,11 @@ namespace llvm {
|
||||||
///
|
///
|
||||||
bool VerboseAsm;
|
bool VerboseAsm;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
// GCMetadataPrinters - The garbage collection metadata printer table.
|
||||||
|
void *GCMetadataPrinters; // Really a DenseMap.
|
||||||
|
|
||||||
/// Private state for PrintSpecial()
|
/// Private state for PrintSpecial()
|
||||||
// Assign a unique ID to this machine instruction.
|
// Assign a unique ID to this machine instruction.
|
||||||
mutable const MachineInstr *LastMI;
|
mutable const MachineInstr *LastMI;
|
||||||
|
|
|
@ -55,20 +55,34 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
||||||
|
|
||||||
char AsmPrinter::ID = 0;
|
char AsmPrinter::ID = 0;
|
||||||
|
|
||||||
|
typedef DenseMap<GCStrategy*,GCMetadataPrinter*> gcp_map_type;
|
||||||
|
static gcp_map_type &getGCMap(void *&P) {
|
||||||
|
if (P == 0)
|
||||||
|
P = new gcp_map_type();
|
||||||
|
return *(gcp_map_type*)P;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AsmPrinter::AsmPrinter(TargetMachine &tm, MCStreamer &Streamer)
|
AsmPrinter::AsmPrinter(TargetMachine &tm, MCStreamer &Streamer)
|
||||||
: MachineFunctionPass(&ID),
|
: MachineFunctionPass(&ID),
|
||||||
TM(tm), MAI(tm.getMCAsmInfo()), TRI(tm.getRegisterInfo()),
|
TM(tm), MAI(tm.getMCAsmInfo()), TRI(tm.getRegisterInfo()),
|
||||||
OutContext(Streamer.getContext()),
|
OutContext(Streamer.getContext()),
|
||||||
OutStreamer(Streamer),
|
OutStreamer(Streamer),
|
||||||
LastMI(0), LastFn(0), Counter(~0U), SetCounter(0) {
|
LastMI(0), LastFn(0), Counter(~0U), SetCounter(0) {
|
||||||
DW = 0; MMI = 0;
|
DW = 0; MMI = 0;
|
||||||
|
GCMetadataPrinters = 0;
|
||||||
VerboseAsm = Streamer.isVerboseAsm();
|
VerboseAsm = Streamer.isVerboseAsm();
|
||||||
}
|
}
|
||||||
|
|
||||||
AsmPrinter::~AsmPrinter() {
|
AsmPrinter::~AsmPrinter() {
|
||||||
for (gcp_iterator I = GCMetadataPrinters.begin(),
|
if (GCMetadataPrinters != 0) {
|
||||||
E = GCMetadataPrinters.end(); I != E; ++I)
|
gcp_map_type &GCMap = getGCMap(GCMetadataPrinters);
|
||||||
delete I->second;
|
|
||||||
|
for (gcp_map_type::iterator I = GCMap.begin(), E = GCMap.end(); I != E; ++I)
|
||||||
|
delete I->second;
|
||||||
|
delete &GCMap;
|
||||||
|
GCMetadataPrinters = 0;
|
||||||
|
}
|
||||||
|
|
||||||
delete &OutStreamer;
|
delete &OutStreamer;
|
||||||
}
|
}
|
||||||
|
@ -1829,8 +1843,8 @@ void AsmPrinter::printOffset(int64_t Offset, raw_ostream &OS) const {
|
||||||
/// isBlockOnlyReachableByFallthough - Return true if the basic block has
|
/// isBlockOnlyReachableByFallthough - Return true if the basic block has
|
||||||
/// exactly one predecessor and the control transfer mechanism between
|
/// exactly one predecessor and the control transfer mechanism between
|
||||||
/// the predecessor and this block is a fall-through.
|
/// the predecessor and this block is a fall-through.
|
||||||
bool AsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB)
|
bool AsmPrinter::
|
||||||
const {
|
isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const {
|
||||||
// If this is a landing pad, it isn't a fall through. If it has no preds,
|
// If this is a landing pad, it isn't a fall through. If it has no preds,
|
||||||
// then nothing falls through to it.
|
// then nothing falls through to it.
|
||||||
if (MBB->isLandingPad() || MBB->pred_empty())
|
if (MBB->isLandingPad() || MBB->pred_empty())
|
||||||
|
@ -1862,9 +1876,10 @@ bool AsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB)
|
||||||
GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
|
GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
|
||||||
if (!S->usesMetadata())
|
if (!S->usesMetadata())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
gcp_iterator GCPI = GCMetadataPrinters.find(S);
|
gcp_map_type &GCMap = getGCMap(GCMetadataPrinters);
|
||||||
if (GCPI != GCMetadataPrinters.end())
|
gcp_map_type::iterator GCPI = GCMap.find(S);
|
||||||
|
if (GCPI != GCMap.end())
|
||||||
return GCPI->second;
|
return GCPI->second;
|
||||||
|
|
||||||
const char *Name = S->getName().c_str();
|
const char *Name = S->getName().c_str();
|
||||||
|
@ -1875,7 +1890,7 @@ GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
|
||||||
if (strcmp(Name, I->getName()) == 0) {
|
if (strcmp(Name, I->getName()) == 0) {
|
||||||
GCMetadataPrinter *GMP = I->instantiate();
|
GCMetadataPrinter *GMP = I->instantiate();
|
||||||
GMP->S = S;
|
GMP->S = S;
|
||||||
GCMetadataPrinters.insert(std::make_pair(S, GMP));
|
GCMap.insert(std::make_pair(S, GMP));
|
||||||
return GMP;
|
return GMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue