Simplify the logic for deciding when to initialize the sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199971 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2014-01-24 03:54:40 +00:00
parent b385559db9
commit a1f7c26cc8
8 changed files with 17 additions and 24 deletions

View File

@ -45,7 +45,7 @@ public:
/// @name MCStreamer Interface
/// @{
virtual void InitSections();
virtual void InitSections(bool Force);
virtual void ChangeSection(const MCSection *Section,
const MCExpr *Subsection);
virtual void EmitLabel(MCSymbol *Symbol);

View File

@ -157,8 +157,6 @@ class MCStreamer {
/// values saved by PushSection.
SmallVector<std::pair<MCSectionSubPair, MCSectionSubPair>, 4> SectionStack;
bool AutoInitSections;
protected:
MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer);
@ -330,19 +328,11 @@ public:
SectionStack.back().first = MCSectionSubPair(Section, Subsection);
}
/// Initialize the streamer.
void InitStreamer() {
if (AutoInitSections)
InitSections();
}
/// Tell this MCStreamer to call InitSections upon initialization.
void setAutoInitSections(bool AutoInitSections) {
this->AutoInitSections = AutoInitSections;
}
/// InitSections - Create the default sections and set the initial one.
virtual void InitSections();
/// Create the default sections and set the initial one.
///
/// @param Force - If false, a text streamer implementation can be a nop.
/// Used by CodeGen to avoid starting every file with '.text'.
virtual void InitSections(bool Force = true);
/// AssignSection - Sets the symbol's section.
///

View File

@ -163,7 +163,7 @@ bool AsmPrinter::doInitialization(Module &M) {
const_cast<TargetLoweringObjectFile&>(getObjFileLowering())
.Initialize(OutContext, TM);
OutStreamer.InitStreamer();
OutStreamer.InitSections(false);
Mang = new Mangler(TM.getDataLayout());

View File

@ -208,7 +208,6 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
*Context, *MAB, Out,
MCE, hasMCRelaxAll(),
hasMCNoExecStack()));
AsmStreamer.get()->setAutoInitSections(true);
break;
}
case CGFT_Null:

View File

@ -128,6 +128,11 @@ public:
virtual void ChangeSection(const MCSection *Section,
const MCExpr *Subsection);
virtual void InitSections(bool Force) {
if (Force)
SwitchSection(getContext().getObjectFileInfo()->getTextSection());
}
virtual void EmitLabel(MCSymbol *Symbol);
virtual void EmitDebugLabel(MCSymbol *Symbol);

View File

@ -38,7 +38,7 @@ using namespace llvm;
MCELFStreamer::~MCELFStreamer() {
}
void MCELFStreamer::InitSections() {
void MCELFStreamer::InitSections(bool Force) {
// This emulates the same behavior of GNU as. This makes it easier
// to compare the output as the major sections are in the same order.
SwitchSection(getContext().getObjectFileInfo()->getTextSection());

View File

@ -29,8 +29,7 @@ void MCTargetStreamer::emitLabel(MCSymbol *Symbol) {}
MCStreamer::MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer)
: Context(Ctx), TargetStreamer(TargetStreamer), EmitEHFrame(true),
EmitDebugFrame(false), CurrentW64UnwindInfo(0), LastSymbol(0),
AutoInitSections(false) {
EmitDebugFrame(false), CurrentW64UnwindInfo(0), LastSymbol(0) {
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
if (TargetStreamer)
TargetStreamer->setStreamer(this);
@ -201,7 +200,7 @@ void MCStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
MCSymbol *EHSymbol) {
}
void MCStreamer::InitSections() {
void MCStreamer::InitSections(bool Force) {
SwitchSection(getContext().getObjectFileInfo()->getTextSection());
}

View File

@ -50,7 +50,7 @@ public:
// MCStreamer interface
virtual void InitSections();
virtual void InitSections(bool Force);
virtual void EmitLabel(MCSymbol *Symbol);
virtual void EmitDebugLabel(MCSymbol *Symbol);
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
@ -123,7 +123,7 @@ void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size,
// MCStreamer interface
void WinCOFFStreamer::InitSections() {
void WinCOFFStreamer::InitSections(bool Force) {
// FIXME: this is identical to the ELF one.
// This emulates the same behavior of GNU as. This makes it easier
// to compare the output as the major sections are in the same order.