change MCContext to work on the doInitialization/doFinalization model

reviewed by Evan Cheng <evan.cheng@apple.com>



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169456 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Pedro Artigas
2012-12-06 00:50:55 +00:00
parent 1c211640e5
commit 486a7ad94f
3 changed files with 48 additions and 7 deletions

View File

@@ -154,6 +154,17 @@ namespace llvm {
void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; } void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
/// @name Module Lifetime Management
/// @{
/// doInitialization - prepare to process a new module
void doInitialization();
/// doFinalization - clean up state from the current module
void doFinalization();
/// @}
/// @name Symbol Management /// @name Symbol Management
/// @{ /// @{

View File

@@ -270,6 +270,9 @@ MachineModuleInfo::~MachineModuleInfo() {
} }
bool MachineModuleInfo::doInitialization(Module &M) { bool MachineModuleInfo::doInitialization(Module &M) {
Context.doInitialization();
ObjFileMMI = 0; ObjFileMMI = 0;
CompactUnwindEncoding = 0; CompactUnwindEncoding = 0;
CurCallSite = 0; CurCallSite = 0;
@@ -291,6 +294,8 @@ bool MachineModuleInfo::doFinalization(Module &M) {
delete AddrLabelSymbols; delete AddrLabelSymbols;
AddrLabelSymbols = 0; AddrLabelSymbols = 0;
Context.doFinalization();
return false; return false;
} }

View File

@@ -44,23 +44,48 @@ MCContext::MCContext(const MCAsmInfo &mai, const MCRegisterInfo &mri,
SecureLogFile = getenv("AS_SECURE_LOG_FILE"); SecureLogFile = getenv("AS_SECURE_LOG_FILE");
SecureLog = 0; SecureLog = 0;
SecureLogUsed = false; SecureLogUsed = false;
DwarfLocSeen = false;
GenDwarfForAssembly = false;
GenDwarfFileNumber = 0;
} }
MCContext::~MCContext() { MCContext::~MCContext() {
// NOTE: The symbols are all allocated out of a bump pointer allocator, // NOTE: The symbols are all allocated out of a bump pointer allocator,
// we don't need to free them here. // we don't need to free them here.
// If the stream for the .secure_log_unique directive was created free it.
delete (raw_ostream*)SecureLog;
}
//===----------------------------------------------------------------------===//
// Module Lifetime Management
//===----------------------------------------------------------------------===//
void MCContext::doInitialization() {
NextUniqueID = 0;
AllowTemporaryLabels = true;
DwarfLocSeen = false;
GenDwarfForAssembly = false;
GenDwarfFileNumber = 0;
}
void MCContext::doFinalization() {
UsedNames.clear();
Symbols.clear();
Allocator.Reset();
Instances.clear();
MCDwarfFiles.clear();
MCDwarfDirs.clear();
MCGenDwarfLabelEntries.clear();
DwarfDebugFlags = StringRef();
MCLineSections.clear();
MCLineSectionOrder.clear();
CurrentDwarfLoc = MCDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0);
// If we have the MachO uniquing map, free it. // If we have the MachO uniquing map, free it.
delete (MachOUniqueMapTy*)MachOUniquingMap; delete (MachOUniqueMapTy*)MachOUniquingMap;
delete (ELFUniqueMapTy*)ELFUniquingMap; delete (ELFUniqueMapTy*)ELFUniquingMap;
delete (COFFUniqueMapTy*)COFFUniquingMap; delete (COFFUniqueMapTy*)COFFUniquingMap;
MachOUniquingMap = 0;
// If the stream for the .secure_log_unique directive was created free it. ELFUniquingMap = 0;
delete (raw_ostream*)SecureLog; COFFUniquingMap = 0;
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//