eliminate AsmPrinter::SwitchToSection and just have clients
talk to the MCStreamer directly instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79405 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 6de6f2b..1762859 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -80,13 +80,6 @@
return TM.getTargetLowering()->getObjFileLowering();
}
-/// SwitchToSection - Switch to the specified section of the executable if we
-/// are not already in it!
-void AsmPrinter::SwitchToSection(const MCSection *NS) {
- assert(NS != 0 && "Must specify a section to switch to");
- OutStreamer.SwitchSection(NS);
-}
-
/// getCurrentSection() - Return the current section we are emitting to.
const MCSection *AsmPrinter::getCurrentSection() const {
return OutStreamer.getCurrentSection();
@@ -300,7 +293,7 @@
// Now print stuff into the calculated sections.
for (unsigned i = 0, e = CPSections.size(); i != e; ++i) {
- SwitchToSection(CPSections[i].S);
+ OutStreamer.SwitchSection(CPSections[i].S);
EmitAlignment(Log2_32(CPSections[i].Alignment));
unsigned Offset = 0;
@@ -354,12 +347,13 @@
// function body itself, otherwise the label differences won't make sense.
// We should also do if the section name is NULL or function is declared in
// discardable section.
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
+ OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang,
+ TM));
} else {
// Otherwise, drop it in the readonly section.
const MCSection *ReadOnlySection =
getObjFileLowering().getSectionForConstant(SectionKind::getReadOnly());
- SwitchToSection(ReadOnlySection);
+ OutStreamer.SwitchSection(ReadOnlySection);
JTInDiffSection = true;
}
@@ -458,14 +452,14 @@
const TargetData *TD = TM.getTargetData();
unsigned Align = Log2_32(TD->getPointerPrefAlignment());
if (GV->getName() == "llvm.global_ctors") {
- SwitchToSection(getObjFileLowering().getStaticCtorSection());
+ OutStreamer.SwitchSection(getObjFileLowering().getStaticCtorSection());
EmitAlignment(Align, 0);
EmitXXStructorList(GV->getInitializer());
return true;
}
if (GV->getName() == "llvm.global_dtors") {
- SwitchToSection(getObjFileLowering().getStaticDtorSection());
+ OutStreamer.SwitchSection(getObjFileLowering().getStaticDtorSection());
EmitAlignment(Align, 0);
EmitXXStructorList(GV->getInitializer());
return true;
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index be92fbd..eedf5c1 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -15,6 +15,7 @@
#include "llvm/Module.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCStreamer.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetFrameInfo.h"
@@ -787,9 +788,10 @@
std::string LinkageName;
GV.getLinkageName(LinkageName);
if (!LinkageName.empty()) {
- // Skip special LLVM prefix that is used to inform the asm printer to not emit
- // usual symbol prefix before the symbol name. This happens for Objective-C
- // symbol names and symbol whose name is replaced using GCC's __asm__ attribute.
+ // Skip special LLVM prefix that is used to inform the asm printer to not
+ // emit usual symbol prefix before the symbol name. This happens for
+ // Objective-C symbol names and symbol whose name is replaced using GCC's
+ // __asm__ attribute.
if (LinkageName[0] == 1)
LinkageName = &LinkageName[1];
AddString(GVDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string,
@@ -1362,14 +1364,14 @@
DebugTimer->startTimer();
// Standard sections final addresses.
- Asm->SwitchToSection(Asm->getObjFileLowering().getTextSection());
+ Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getTextSection());
EmitLabel("text_end", 0);
- Asm->SwitchToSection(Asm->getObjFileLowering().getDataSection());
+ Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getDataSection());
EmitLabel("data_end", 0);
// End text sections.
for (unsigned i = 1, N = SectionMap.size(); i <= N; ++i) {
- Asm->SwitchToSection(SectionMap[i]);
+ Asm->OutStreamer.SwitchSection(SectionMap[i]);
EmitLabel("section_end", i);
}
@@ -1863,39 +1865,40 @@
if (didInitial) return;
didInitial = true;
+ const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
+
// Dwarf sections base addresses.
if (TAI->doesDwarfRequireFrameSection()) {
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfFrameSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDwarfFrameSection());
EmitLabel("section_debug_frame", 0);
}
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfInfoSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDwarfInfoSection());
EmitLabel("section_info", 0);
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfAbbrevSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDwarfAbbrevSection());
EmitLabel("section_abbrev", 0);
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfARangesSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDwarfARangesSection());
EmitLabel("section_aranges", 0);
- if (const MCSection *LineInfoDirective =
- Asm->getObjFileLowering().getDwarfMacroInfoSection()) {
- Asm->SwitchToSection(LineInfoDirective);
+ if (const MCSection *LineInfoDirective = TLOF.getDwarfMacroInfoSection()) {
+ Asm->OutStreamer.SwitchSection(LineInfoDirective);
EmitLabel("section_macinfo", 0);
}
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfLineSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDwarfLineSection());
EmitLabel("section_line", 0);
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfLocSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDwarfLocSection());
EmitLabel("section_loc", 0);
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfPubNamesSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDwarfPubNamesSection());
EmitLabel("section_pubnames", 0);
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfStrSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDwarfStrSection());
EmitLabel("section_str", 0);
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfRangesSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDwarfRangesSection());
EmitLabel("section_ranges", 0);
- Asm->SwitchToSection(Asm->getObjFileLowering().getTextSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getTextSection());
EmitLabel("text_begin", 0);
- Asm->SwitchToSection(Asm->getObjFileLowering().getDataSection());
+ Asm->OutStreamer.SwitchSection(TLOF.getDataSection());
EmitLabel("data_begin", 0);
}
@@ -1997,7 +2000,8 @@
void DwarfDebug::EmitDebugInfo() {
// Start debug info section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfInfoSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfInfoSection());
EmitDebugInfoPerCU(ModuleCU);
}
@@ -2008,7 +2012,8 @@
// Check to see if it is worth the effort.
if (!Abbreviations.empty()) {
// Start the debug abbrev section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfAbbrevSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfAbbrevSection());
EmitLabel("abbrev_begin", 0);
@@ -2065,7 +2070,8 @@
const int MaxLineDelta = 255 + MinLineDelta;
// Start the dwarf line section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfLineSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfLineSection());
// Construct the section header.
EmitDifference("line_end", 0, "line_begin", 0, true);
@@ -2224,7 +2230,8 @@
TD->getPointerSize() : -TD->getPointerSize();
// Start the dwarf frame section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfFrameSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfFrameSection());
EmitLabel("debug_frame_common", 0);
EmitDifference("debug_frame_common_end", 0,
@@ -2264,7 +2271,8 @@
return;
// Start the dwarf frame section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfFrameSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfFrameSection());
EmitDifference("debug_frame_end", DebugFrameInfo.Number,
"debug_frame_begin", DebugFrameInfo.Number, true);
@@ -2328,7 +2336,8 @@
///
void DwarfDebug::EmitDebugPubNames() {
// Start the dwarf pubnames section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfPubNamesSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfPubNamesSection());
EmitDebugPubNamesPerCU(ModuleCU);
}
@@ -2339,7 +2348,8 @@
// Check to see if it is worth the effort.
if (!StringPool.empty()) {
// Start the dwarf str section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfStrSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfStrSection());
// For each of strings in the string pool.
for (unsigned StringID = 1, N = StringPool.size();
@@ -2360,7 +2370,8 @@
///
void DwarfDebug::EmitDebugLoc() {
// Start the dwarf loc section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfLocSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfLocSection());
Asm->EOL();
}
@@ -2368,7 +2379,8 @@
///
void DwarfDebug::EmitDebugARanges() {
// Start the dwarf aranges section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfARangesSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfARangesSection());
// FIXME - Mock up
#if 0
@@ -2404,7 +2416,8 @@
///
void DwarfDebug::EmitDebugRanges() {
// Start the dwarf ranges section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfRangesSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfRangesSection());
Asm->EOL();
}
@@ -2414,7 +2427,7 @@
if (const MCSection *LineInfo =
Asm->getObjFileLowering().getDwarfMacroInfoSection()) {
// Start the dwarf macinfo section.
- Asm->SwitchToSection(LineInfo);
+ Asm->OutStreamer.SwitchSection(LineInfo);
Asm->EOL();
}
}
@@ -2444,7 +2457,8 @@
if (!ModuleCU)
return;
- Asm->SwitchToSection(Asm->getObjFileLowering().getDwarfDebugInlineSection());
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfDebugInlineSection());
Asm->EOL();
EmitDifference("debug_inlined_end", 1,
"debug_inlined_begin", 1, true);
@@ -2469,9 +2483,10 @@
if (LName.empty())
Asm->EmitString(Name);
else {
- // Skip special LLVM prefix that is used to inform the asm printer to not emit
- // usual symbol prefix before the symbol name. This happens for Objective-C
- // symbol names and symbol whose name is replaced using GCC's __asm__ attribute.
+ // Skip special LLVM prefix that is used to inform the asm printer to not
+ // emit usual symbol prefix before the symbol name. This happens for
+ // Objective-C symbol names and symbol whose name is replaced using GCC's
+ // __asm__ attribute.
if (LName[0] == 1)
LName = &LName[1];
Asm->EmitString(LName);
diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp
index 06dfac4..aacb33b 100644
--- a/lib/CodeGen/AsmPrinter/DwarfException.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp
@@ -16,15 +16,16 @@
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineLocation.h"
-#include "llvm/Support/Dwarf.h"
-#include "llvm/Support/Timer.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/MC/MCStreamer.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegisterInfo.h"
+#include "llvm/Support/Dwarf.h"
+#include "llvm/Support/Timer.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/StringExtras.h"
using namespace llvm;
@@ -56,7 +57,7 @@
TD->getPointerSize() : -TD->getPointerSize();
// Begin eh frame section.
- Asm->SwitchToSection(Asm->getObjFileLowering().getEHFrameSection());
+ Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getEHFrameSection());
if (TAI->is_EHSymbolPrivate())
O << TAI->getPrivateGlobalPrefix();
@@ -150,7 +151,7 @@
const Function *TheFunc = EHFrameInfo.function;
- Asm->SwitchToSection(Asm->getObjFileLowering().getEHFrameSection());
+ Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getEHFrameSection());
// Externally visible entry into the functions eh frame info. If the
// corresponding function is static, this should not be externally visible.
@@ -555,7 +556,7 @@
// Begin the exception table.
const MCSection *LSDASection = Asm->getObjFileLowering().getLSDASection();
- Asm->SwitchToSection(LSDASection);
+ Asm->OutStreamer.SwitchSection(LSDASection);
Asm->EmitAlignment(2, 0, 0, false);
O << "GCC_except_table" << SubprogramCount << ":\n";
diff --git a/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp b/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
index a87fa9e..af3bbc9 100644
--- a/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
@@ -15,13 +15,14 @@
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/GCMetadataPrinter.h"
#include "llvm/Module.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/MC/MCStreamer.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
@@ -64,10 +65,10 @@
void OcamlGCMetadataPrinter::beginAssembly(raw_ostream &OS, AsmPrinter &AP,
const TargetAsmInfo &TAI) {
- AP.SwitchToSection(AP.getObjFileLowering().getTextSection());
+ AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "code_begin");
- AP.SwitchToSection(AP.getObjFileLowering().getDataSection());
+ AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "data_begin");
}
@@ -99,16 +100,16 @@
AddressAlignLog = 3;
}
- AP.SwitchToSection(AP.getObjFileLowering().getTextSection());
+ AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "code_end");
- AP.SwitchToSection(AP.getObjFileLowering().getDataSection());
+ AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "data_end");
OS << AddressDirective << 0; // FIXME: Why does ocaml emit this??
AP.EOL();
- AP.SwitchToSection(AP.getObjFileLowering().getDataSection());
+ AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "frametable");
for (iterator I = begin(), IE = end(); I != IE; ++I) {