[llvm-commits] [llvm] r169456 - in /llvm/trunk: include/llvm/MC/MCContext.h lib/CodeGen/MachineModuleInfo.cpp lib/MC/MCContext.cpp
Pedro Artigas
partigas at apple.com
Wed Dec 5 16:50:56 PST 2012
Author: partigas
Date: Wed Dec 5 18:50:55 2012
New Revision: 169456
URL: http://llvm.org/viewvc/llvm-project?rev=169456&view=rev
Log:
change MCContext to work on the doInitialization/doFinalization model
reviewed by Evan Cheng <evan.cheng at apple.com>
Modified:
llvm/trunk/include/llvm/MC/MCContext.h
llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
llvm/trunk/lib/MC/MCContext.cpp
Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=169456&r1=169455&r2=169456&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Wed Dec 5 18:50:55 2012
@@ -154,6 +154,17 @@
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
/// @{
Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=169456&r1=169455&r2=169456&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Wed Dec 5 18:50:55 2012
@@ -270,6 +270,9 @@
}
bool MachineModuleInfo::doInitialization(Module &M) {
+
+ Context.doInitialization();
+
ObjFileMMI = 0;
CompactUnwindEncoding = 0;
CurCallSite = 0;
@@ -291,6 +294,8 @@
delete AddrLabelSymbols;
AddrLabelSymbols = 0;
+ Context.doFinalization();
+
return false;
}
Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=169456&r1=169455&r2=169456&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Wed Dec 5 18:50:55 2012
@@ -44,23 +44,48 @@
SecureLogFile = getenv("AS_SECURE_LOG_FILE");
SecureLog = 0;
SecureLogUsed = false;
+}
+MCContext::~MCContext() {
+ // NOTE: The symbols are all allocated out of a bump pointer allocator,
+ // 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;
}
-MCContext::~MCContext() {
- // NOTE: The symbols are all allocated out of a bump pointer allocator,
- // we don't need to free them here.
+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.
delete (MachOUniqueMapTy*)MachOUniquingMap;
delete (ELFUniqueMapTy*)ELFUniquingMap;
delete (COFFUniqueMapTy*)COFFUniquingMap;
-
- // If the stream for the .secure_log_unique directive was created free it.
- delete (raw_ostream*)SecureLog;
+ MachOUniquingMap = 0;
+ ELFUniquingMap = 0;
+ COFFUniquingMap = 0;
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list