[llvm-commits] COFF MCSectionCOFF & TLOF patch
Aaron Gray
aaronngray.lists at googlemail.com
Thu Apr 1 05:25:22 PDT 2010
Hi Chris,
Here's a patch to fix MCSectionCOFF, removing IsDirective and the tabs from
MCSectionCOFF and fixing TLOF calls to MCSectionCOFF.
Its been tested with 'make TESTSUITE=CodeGen/X86 check'.
Patch attached and inline.
Aaron
Index: include/llvm/MC/MCSection.h
===================================================================
--- include/llvm/MC/MCSection.h (revision 100074)
+++ include/llvm/MC/MCSection.h (working copy)
@@ -45,23 +45,13 @@
// The memory for this string is stored in the same MCContext as *this.
StringRef Name;
- /// IsDirective - This is true if the section name is a directive, not
- /// something that should be printed with ".section".
- ///
- /// FIXME: This is a hack. Switch to a semantic view of the section
instead
- /// of a syntactic one.
- bool IsDirective;
-
- MCSectionCOFF(StringRef name, bool isDirective, SectionKind K)
- : MCSection(K), Name(name), IsDirective(isDirective) {
- }
+ MCSectionCOFF(StringRef name, SectionKind K) : MCSection(K), Name(name)
{}
public:
- static MCSectionCOFF *Create(StringRef Name, bool IsDirective,
+ static MCSectionCOFF *Create(StringRef Name,
SectionKind K, MCContext &Ctx);
StringRef getName() const { return Name; }
- bool isDirective() const { return IsDirective; }
virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
raw_ostream &OS) const;
Index: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
===================================================================
--- include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (revision 100074)
+++ include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (working copy)
@@ -200,8 +200,7 @@
/// getCOFFSection - Return the MCSection for the specified COFF section.
/// FIXME: Switch this to a semantic view eventually.
- const MCSection *getCOFFSection(StringRef Name, bool isDirective,
- SectionKind K) const;
+ const MCSection *getCOFFSection(StringRef Name, SectionKind K) const;
};
} // end namespace llvm
Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp (revision 100074)
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp (working copy)
@@ -803,7 +803,7 @@
const MCSection *TargetLoweringObjectFileCOFF::
-getCOFFSection(StringRef Name, bool isDirective, SectionKind Kind) const {
+getCOFFSection(StringRef Name, SectionKind Kind) const {
// Create the map if it doesn't already exist.
if (UniquingMap == 0)
UniquingMap = new MachOUniqueMapTy();
@@ -813,7 +813,7 @@
const MCSectionCOFF *&Entry = Map[Name];
if (Entry) return Entry;
- return Entry = MCSectionCOFF::Create(Name, isDirective, Kind,
getContext());
+ return Entry = MCSectionCOFF::Create(Name, Kind, getContext());
}
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
@@ -821,63 +821,51 @@
if (UniquingMap != 0)
((COFFUniqueMapTy*)UniquingMap)->clear();
TargetLoweringObjectFile::Initialize(Ctx, TM);
- TextSection = getCOFFSection("\t.text", true, SectionKind::getText());
- DataSection = getCOFFSection("\t.data", true, SectionKind::getDataRel());
+ TextSection = getCOFFSection(".text", SectionKind::getText());
+ DataSection = getCOFFSection(".data", SectionKind::getDataRel());
StaticCtorSection =
- getCOFFSection(".ctors", false, SectionKind::getDataRel());
+ getCOFFSection(".ctors", SectionKind::getDataRel());
StaticDtorSection =
- getCOFFSection(".dtors", false, SectionKind::getDataRel());
+ getCOFFSection(".dtors", SectionKind::getDataRel());
// FIXME: We're emitting LSDA info into a readonly section on COFF, even
// though it contains relocatable pointers. In PIC mode, this is
probably a
// big runtime hit for C++ apps. Either the contents of the LSDA need to
be
// adjusted or this should be a data section.
LSDASection =
- getCOFFSection(".gcc_except_table", false, SectionKind::getReadOnly());
+ getCOFFSection(".gcc_except_table", SectionKind::getReadOnly());
EHFrameSection =
- getCOFFSection(".eh_frame", false, SectionKind::getDataRel());
+ getCOFFSection(".eh_frame", SectionKind::getDataRel());
// Debug info.
- // FIXME: Don't use 'directive' mode here.
DwarfAbbrevSection =
- getCOFFSection("\t.section\t.debug_abbrev,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_abbrev", SectionKind::getMetadata());
DwarfInfoSection =
- getCOFFSection("\t.section\t.debug_info,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_info", SectionKind::getMetadata());
DwarfLineSection =
- getCOFFSection("\t.section\t.debug_line,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_line", SectionKind::getMetadata());
DwarfFrameSection =
- getCOFFSection("\t.section\t.debug_frame,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_frame", SectionKind::getMetadata());
DwarfPubNamesSection =
- getCOFFSection("\t.section\t.debug_pubnames,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_pubnames", SectionKind::getMetadata());
DwarfPubTypesSection =
- getCOFFSection("\t.section\t.debug_pubtypes,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_pubtypes", SectionKind::getMetadata());
DwarfStrSection =
- getCOFFSection("\t.section\t.debug_str,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_str", SectionKind::getMetadata());
DwarfLocSection =
- getCOFFSection("\t.section\t.debug_loc,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_loc", SectionKind::getMetadata());
DwarfARangesSection =
- getCOFFSection("\t.section\t.debug_aranges,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_aranges", SectionKind::getMetadata());
DwarfRangesSection =
- getCOFFSection("\t.section\t.debug_ranges,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_ranges", SectionKind::getMetadata());
DwarfMacroInfoSection =
- getCOFFSection("\t.section\t.debug_macinfo,\"dr\"",
- true, SectionKind::getMetadata());
+ getCOFFSection(".debug_macinfo", SectionKind::getMetadata());
}
const MCSection *TargetLoweringObjectFileCOFF::
getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const {
- return getCOFFSection(GV->getSection(), false, Kind);
+ return getCOFFSection(GV->getSection(), Kind);
}
static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) {
@@ -901,7 +889,7 @@
SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
MCSymbol *Sym = Mang->getSymbol(GV);
Name.append(Sym->getName().begin(), Sym->getName().end());
- return getCOFFSection(Name.str(), false, Kind);
+ return getCOFFSection(Name.str(), Kind);
}
if (Kind.isText())
Index: lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
===================================================================
--- lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (revision 100074)
+++ lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (working copy)
@@ -594,8 +594,7 @@
// Output linker support code for dllexported globals on windows.
if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) {
- OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section
.drectve",
- true,
+ OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".drectve",
SectionKind::getMetadata()));
for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i)
O << "\t.ascii \" -export:" << *DLLExportedGlobals[i] <<
",data\"\n";
Index: lib/MC/MCSection.cpp
===================================================================
--- lib/MC/MCSection.cpp (revision 100074)
+++ lib/MC/MCSection.cpp (working copy)
@@ -25,19 +25,17 @@
//===----------------------------------------------------------------------===//
MCSectionCOFF *MCSectionCOFF::
-Create(StringRef Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
+Create(StringRef Name, SectionKind K, MCContext &Ctx) {
char *NameCopy = static_cast<char*>(
Ctx.Allocate(Name.size(), /*Alignment=*/1));
memcpy(NameCopy, Name.data(), Name.size());
- return new (Ctx) MCSectionCOFF(StringRef(NameCopy, Name.size()),
- IsDirective, K);
+ return new (Ctx) MCSectionCOFF(StringRef(NameCopy, Name.size()), K);
}
void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
raw_ostream &OS) const {
-
- if (isDirective()) {
- OS << getName() << '\n';
+ if (getName() == StringRef(".text") || getName() == StringRef(".data")) {
+ OS << "\t" << getName() << '\n';
return;
}
OS << "\t.section\t" << getName() << ",\"";
@@ -45,5 +43,7 @@
OS << 'x';
if (getKind().isWriteable())
OS << 'w';
+ if (getKind().isMetadata())
+ OS << "dr";
OS << "\"\n";
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100401/6dbba8de/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-coff-mai-tlof.patch
Type: application/octet-stream
Size: 9293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100401/6dbba8de/attachment.obj>
More information about the llvm-commits
mailing list