mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-31 09:22:31 +00:00
Make the MCStreamer have a reset method and call that after finalization of the asm printer,
also changed MCContext to a single reset only method for simplicity as requested on the list git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170041 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5749801caa
commit
5399d2502a
@ -802,6 +802,10 @@ public:
|
||||
raw_ostream &OS);
|
||||
~MCAssembler();
|
||||
|
||||
/// Reuse an assembler instance
|
||||
///
|
||||
void reset();
|
||||
|
||||
MCContext &getContext() const { return Context; }
|
||||
|
||||
MCAsmBackend &getBackend() const { return Backend; }
|
||||
|
@ -137,16 +137,15 @@ namespace llvm {
|
||||
|
||||
void *MachOUniquingMap, *ELFUniquingMap, *COFFUniquingMap;
|
||||
|
||||
/// Do automatic initialization in constructor and finalization in
|
||||
/// destructor
|
||||
bool AutoInitializationFinalization;
|
||||
/// Do automatic reset in destructor
|
||||
bool AutoReset;
|
||||
|
||||
MCSymbol *CreateSymbol(StringRef Name);
|
||||
|
||||
public:
|
||||
explicit MCContext(const MCAsmInfo &MAI, const MCRegisterInfo &MRI,
|
||||
const MCObjectFileInfo *MOFI, const SourceMgr *Mgr = 0,
|
||||
bool AutoInitializationFinalization = true);
|
||||
bool DoAutoReset = true);
|
||||
~MCContext();
|
||||
|
||||
const SourceMgr *getSourceManager() const { return SrcMgr; }
|
||||
@ -162,11 +161,9 @@ namespace llvm {
|
||||
/// @name Module Lifetime Management
|
||||
/// @{
|
||||
|
||||
/// doInitialization - prepare to process a new module
|
||||
void doInitialization();
|
||||
|
||||
/// doFinalization - clean up state from the current module
|
||||
void doFinalization();
|
||||
/// reset - return object to right after construction state to prepare
|
||||
/// to process a new module
|
||||
void reset();
|
||||
|
||||
/// @}
|
||||
|
||||
|
@ -45,6 +45,11 @@ protected:
|
||||
MCAssembler *_Assembler);
|
||||
~MCObjectStreamer();
|
||||
|
||||
public:
|
||||
/// state management
|
||||
virtual void reset();
|
||||
|
||||
protected:
|
||||
MCSectionData *getCurrentSectionData() const {
|
||||
return CurSectionData;
|
||||
}
|
||||
|
@ -92,6 +92,10 @@ namespace llvm {
|
||||
public:
|
||||
virtual ~MCStreamer();
|
||||
|
||||
/// State management
|
||||
///
|
||||
virtual void reset();
|
||||
|
||||
MCContext &getContext() const { return Context; }
|
||||
|
||||
unsigned getNumFrameInfos() {
|
||||
|
@ -946,6 +946,8 @@ bool AsmPrinter::doFinalization(Module &M) {
|
||||
MMI = 0;
|
||||
|
||||
OutStreamer.Finish();
|
||||
OutStreamer.reset();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -270,8 +270,6 @@ MachineModuleInfo::~MachineModuleInfo() {
|
||||
}
|
||||
|
||||
bool MachineModuleInfo::doInitialization(Module &M) {
|
||||
|
||||
Context.doInitialization();
|
||||
|
||||
ObjFileMMI = 0;
|
||||
CompactUnwindEncoding = 0;
|
||||
@ -294,7 +292,7 @@ bool MachineModuleInfo::doFinalization(Module &M) {
|
||||
delete AddrLabelSymbols;
|
||||
AddrLabelSymbols = 0;
|
||||
|
||||
Context.doFinalization();
|
||||
Context.reset();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -221,6 +221,19 @@ MCAssembler::MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
|
||||
MCAssembler::~MCAssembler() {
|
||||
}
|
||||
|
||||
void MCAssembler::reset() {
|
||||
Sections.clear();
|
||||
Symbols.clear();
|
||||
SectionMap.clear();
|
||||
SymbolMap.clear();
|
||||
IndirectSymbols.clear();
|
||||
DataRegions.clear();
|
||||
ThumbFuncs.clear();
|
||||
RelaxAll = false;
|
||||
NoExecStack = false;
|
||||
SubsectionsViaSymbols = false;
|
||||
}
|
||||
|
||||
bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
|
||||
// Non-temporary labels should always be visible to the linker.
|
||||
if (!Symbol.isTemporary())
|
||||
|
@ -32,13 +32,14 @@ typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy;
|
||||
|
||||
MCContext::MCContext(const MCAsmInfo &mai, const MCRegisterInfo &mri,
|
||||
const MCObjectFileInfo *mofi, const SourceMgr *mgr,
|
||||
bool DoAutoInitializationFinalization ) :
|
||||
bool DoAutoReset ) :
|
||||
SrcMgr(mgr), MAI(mai), MRI(mri), MOFI(mofi),
|
||||
Allocator(), Symbols(Allocator), UsedNames(Allocator),
|
||||
NextUniqueID(0),
|
||||
CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0),
|
||||
AllowTemporaryLabels(true),
|
||||
AutoInitializationFinalization(DoAutoInitializationFinalization) {
|
||||
NextUniqueID(0),
|
||||
CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0),
|
||||
DwarfLocSeen(false), GenDwarfForAssembly(false), GenDwarfFileNumber(0),
|
||||
AllowTemporaryLabels(true), AutoReset(DoAutoReset) {
|
||||
|
||||
MachOUniquingMap = 0;
|
||||
ELFUniquingMap = 0;
|
||||
COFFUniquingMap = 0;
|
||||
@ -46,15 +47,12 @@ MCContext::MCContext(const MCAsmInfo &mai, const MCRegisterInfo &mri,
|
||||
SecureLogFile = getenv("AS_SECURE_LOG_FILE");
|
||||
SecureLog = 0;
|
||||
SecureLogUsed = false;
|
||||
|
||||
if (AutoInitializationFinalization)
|
||||
doInitialization();
|
||||
}
|
||||
|
||||
MCContext::~MCContext() {
|
||||
|
||||
if (AutoInitializationFinalization)
|
||||
doFinalization();
|
||||
if (AutoReset)
|
||||
reset();
|
||||
|
||||
// NOTE: The symbols are all allocated out of a bump pointer allocator,
|
||||
// we don't need to free them here.
|
||||
@ -67,15 +65,7 @@ MCContext::~MCContext() {
|
||||
// Module Lifetime Management
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void MCContext::doInitialization() {
|
||||
NextUniqueID = 0;
|
||||
AllowTemporaryLabels = true;
|
||||
DwarfLocSeen = false;
|
||||
GenDwarfForAssembly = false;
|
||||
GenDwarfFileNumber = 0;
|
||||
}
|
||||
|
||||
void MCContext::doFinalization() {
|
||||
void MCContext::reset() {
|
||||
UsedNames.clear();
|
||||
Symbols.clear();
|
||||
Allocator.Reset();
|
||||
@ -95,6 +85,12 @@ void MCContext::doFinalization() {
|
||||
MachOUniquingMap = 0;
|
||||
ELFUniquingMap = 0;
|
||||
COFFUniquingMap = 0;
|
||||
|
||||
NextUniqueID = 0;
|
||||
AllowTemporaryLabels = true;
|
||||
DwarfLocSeen = false;
|
||||
GenDwarfForAssembly = false;
|
||||
GenDwarfFileNumber = 0;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -44,6 +44,11 @@ MCObjectStreamer::~MCObjectStreamer() {
|
||||
delete Assembler;
|
||||
}
|
||||
|
||||
void MCObjectStreamer::reset() {
|
||||
Assembler->reset();
|
||||
MCStreamer::reset();
|
||||
}
|
||||
|
||||
MCFragment *MCObjectStreamer::getCurrentFragment() const {
|
||||
assert(getCurrentSectionData() && "No current section!");
|
||||
|
||||
|
@ -34,6 +34,19 @@ MCStreamer::~MCStreamer() {
|
||||
delete W64UnwindInfos[i];
|
||||
}
|
||||
|
||||
void MCStreamer::reset() {
|
||||
for (unsigned i = 0; i < getNumW64UnwindInfos(); ++i)
|
||||
delete W64UnwindInfos[i];
|
||||
EmitEHFrame = true;
|
||||
EmitDebugFrame = false;
|
||||
CurrentW64UnwindInfo = 0;
|
||||
LastSymbol = 0;
|
||||
AutoInitSections = false;
|
||||
const MCSection *section = NULL;
|
||||
SectionStack.clear();
|
||||
SectionStack.push_back(std::make_pair(section, section));
|
||||
}
|
||||
|
||||
const MCExpr *MCStreamer::BuildSymbolDiff(MCContext &Context,
|
||||
const MCSymbol *A,
|
||||
const MCSymbol *B) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user