[llvm-commits] [llvm] r56573 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/Alpha/AlphaAsmPrinter.cpp lib/Target/CellSPU/SPUAsmPrinter.cpp lib/Target/IA64/IA64AsmPrinter.cpp lib/Target/Mips/MipsAsmPrinter.cpp lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp lib/Target/Sparc/SparcAsmPrinter.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
Anton Korobeynikov
asl at math.spbu.ru
Wed Sep 24 15:14:23 PDT 2008
Author: asl
Date: Wed Sep 24 17:14:23 2008
New Revision: 56573
URL: http://llvm.org/viewvc/llvm-project?rev=56573&view=rev
Log:
Move actual section printing stuff to AsmPrinter from TAI reducing heap traffic.
Modified:
llvm/trunk/include/llvm/Target/TargetAsmInfo.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
llvm/trunk/lib/Target/Alpha/AlphaAsmPrinter.cpp
llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp
llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp
llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp
llvm/trunk/lib/Target/TargetAsmInfo.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Wed Sep 24 17:14:23 2008
@@ -113,6 +113,7 @@
public:
bool isNamed() const { return Flags & SectionFlags::Named; }
unsigned getEntitySize() const { return (Flags >> 24) & 0xFF; }
+
const std::string& getName() const { return Name; }
unsigned getFlags() const { return Flags; }
};
@@ -573,7 +574,7 @@
/// SectionForGlobal - This hooks returns proper section name for given
/// global with all necessary flags and marks.
- virtual std::string SectionForGlobal(const GlobalValue *GV) const;
+ virtual const Section* SectionForGlobal(const GlobalValue *GV) const;
// Helper methods for SectionForGlobal
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Sep 24 17:14:23 2008
@@ -115,8 +115,18 @@
// FIXME: Make CurrentSection a Section* in the future
CurrentSection = NewSection;
- if (!CurrentSection.empty())
- O << CurrentSection << TAI->getDataSectionStartSuffix() << '\n';
+ if (!CurrentSection.empty()) {
+ // If section is named we need to switch into it via special '.section'
+ // directive and also append funky flags. Otherwise - section name is just
+ // some magic assembler directive.
+ if (NS->isNamed())
+ O << TAI->getSwitchToSectionDirective()
+ << CurrentSection
+ << TAI->getSectionFlags(NS->getFlags());
+ else
+ O << CurrentSection;
+ O << TAI->getDataSectionStartSuffix() << '\n';
+ }
IsInTextSection = (NS->getFlags() & SectionFlags::Code);
}
@@ -326,7 +336,7 @@
// 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.
- SwitchToTextSection(TAI->SectionForGlobal(F).c_str(), F);
+ SwitchToSection(TAI->SectionForGlobal(F));
} else {
SwitchToDataSection(JumpTableDataSection);
}
Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Sep 24 17:14:23 2008
@@ -846,7 +846,6 @@
return;
}
- std::string SectionName = TAI->SectionForGlobal(GVar);
std::string name = Mang->getValueName(GVar);
Constant *C = GVar->getInitializer();
const Type *Type = C->getType();
@@ -858,7 +857,7 @@
if (Subtarget->isTargetELF())
O << "\t.type " << name << ",%object\n";
- SwitchToDataSection(SectionName.c_str());
+ SwitchToSection(TAI->SectionForGlobal(GVar));
if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal()) {
// FIXME: This seems to be pretty darwin-specific
Modified: llvm/trunk/lib/Target/Alpha/AlphaAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaAsmPrinter.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Alpha/AlphaAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Alpha/AlphaAsmPrinter.cpp Wed Sep 24 17:14:23 2008
@@ -149,7 +149,7 @@
// Print out labels for the function.
const Function *F = MF.getFunction();
- SwitchToTextSection(TAI->SectionForGlobal(F).c_str(), F);
+ SwitchToSection(TAI->SectionForGlobal(F));
EmitAlignment(4, F);
switch (F->getLinkage()) {
@@ -214,14 +214,13 @@
if (EmitSpecialLLVMGlobal(GVar))
return;
- std::string SectionName = TAI->SectionForGlobal(GVar);
std::string name = Mang->getValueName(GVar);
Constant *C = GVar->getInitializer();
unsigned Size = TD->getABITypeSize(C->getType());
unsigned Align = TD->getPreferredAlignmentLog(GVar);
// 0: Switch to section
- SwitchToDataSection(SectionName.c_str());
+ SwitchToSection(TAI->SectionForGlobal(GVar));
// 1: Check visibility
printVisibility(name, GVar->getVisibility());
Modified: llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp Wed Sep 24 17:14:23 2008
@@ -418,7 +418,7 @@
// Print out labels for the function.
const Function *F = MF.getFunction();
- SwitchToTextSection(TAI->SectionForGlobal(F).c_str(), F);
+ SwitchToSection(TAI->SectionForGlobal(F));
EmitAlignment(3, F);
switch (F->getLinkage()) {
Modified: llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp Wed Sep 24 17:14:23 2008
@@ -130,7 +130,7 @@
EmitConstantPool(MF.getConstantPool());
const Function *F = MF.getFunction();
- SwitchToTextSection(TAI->SectionForGlobal(F).c_str(), F);
+ SwitchToSection(TAI->SectionForGlobal(F));
// Print out labels for the function.
EmitAlignment(5);
@@ -264,7 +264,6 @@
return;
O << "\n\n";
- std::string SectionName = TAI->SectionForGlobal(GVar);
std::string name = Mang->getValueName(GVar);
Constant *C = GVar->getInitializer();
unsigned Size = TD->getABITypeSize(C->getType());
@@ -272,7 +271,7 @@
printVisibility(name, GVar->getVisibility());
- SwitchToDataSection(SectionName.c_str());
+ SwitchToSection(TAI->SectionForGlobal(GVar));
if (C->isNullValue() && !GVar->hasSection()) {
if (!GVar->isThreadLocal() &&
Modified: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp Wed Sep 24 17:14:23 2008
@@ -224,7 +224,7 @@
{
// Print out the label for the function.
const Function *F = MF.getFunction();
- SwitchToTextSection(TAI->SectionForGlobal(F).c_str());
+ SwitchToSection(TAI->SectionForGlobal(F));
// 2 bits aligned
EmitAlignment(2, F);
@@ -479,7 +479,6 @@
return;
O << "\n\n";
- std::string SectionName = TAI->SectionForGlobal(GVar);
std::string name = Mang->getValueName(GVar);
Constant *C = GVar->getInitializer();
const Type *CTy = C->getType();
@@ -501,7 +500,7 @@
printVisibility(name, GVar->getVisibility());
- SwitchToDataSection(SectionName.c_str());
+ SwitchToSection(TAI->SectionForGlobal(GVar));
if (C->isNullValue() && !GVar->hasSection()) {
if (!GVar->isThreadLocal() &&
Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Sep 24 17:14:23 2008
@@ -571,7 +571,7 @@
// Print out labels for the function.
const Function *F = MF.getFunction();
- SwitchToTextSection(TAI->SectionForGlobal(F).c_str(), F);
+ SwitchToSection(TAI->SectionForGlobal(F));
switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!");
@@ -662,7 +662,6 @@
return;
std::string name = Mang->getValueName(GVar);
- std::string SectionName = TAI->SectionForGlobal(GVar);
printVisibility(name, GVar->getVisibility());
@@ -671,7 +670,7 @@
unsigned Size = TD->getABITypeSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar);
- SwitchToDataSection(SectionName.c_str());
+ SwitchToSection(TAI->SectionForGlobal(GVar));
if (C->isNullValue() && /* FIXME: Verify correct */
!GVar->hasSection() &&
@@ -759,7 +758,7 @@
// Print out labels for the function.
const Function *F = MF.getFunction();
- SwitchToTextSection(TAI->SectionForGlobal(F).c_str(), F);
+ SwitchToSection(TAI->SectionForGlobal(F));
switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!");
@@ -888,7 +887,6 @@
}
std::string name = Mang->getValueName(GVar);
- std::string SectionName = TAI->SectionForGlobal(GVar);
printVisibility(name, GVar->getVisibility());
@@ -897,7 +895,7 @@
unsigned Size = TD->getABITypeSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar);
- SwitchToDataSection(SectionName.c_str());
+ SwitchToSection(TAI->SectionForGlobal(GVar));
if (C->isNullValue() && /* FIXME: Verify correct */
!GVar->hasSection() &&
Modified: llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp Wed Sep 24 17:14:23 2008
@@ -99,7 +99,7 @@
// Print out the label for the function.
const Function *F = MF.getFunction();
- SwitchToTextSection(TAI->SectionForGlobal(F).c_str(), F);
+ SwitchToSection(TAI->SectionForGlobal(F));
EmitAlignment(4, F);
O << "\t.globl\t" << CurrentFnName << '\n';
@@ -242,7 +242,6 @@
return;
O << "\n\n";
- std::string SectionName = TAI->SectionForGlobal(GVar);
std::string name = Mang->getValueName(GVar);
Constant *C = GVar->getInitializer();
unsigned Size = TD->getABITypeSize(C->getType());
@@ -250,7 +249,7 @@
printVisibility(name, GVar->getVisibility());
- SwitchToDataSection(SectionName.c_str());
+ SwitchToSection(TAI->SectionForGlobal(GVar));
if (C->isNullValue() && !GVar->hasSection()) {
if (!GVar->isThreadLocal() &&
Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Wed Sep 24 17:14:23 2008
@@ -272,7 +272,7 @@
return Flags;
}
-std::string
+const Section*
TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
const Section* S;
// Select section name
@@ -286,13 +286,7 @@
S = SelectSectionForGlobal(GV);
}
- if (!S->isNamed())
- return S->Name;
-
- // If section is named we need to switch into it via special '.section'
- // directive and also append funky flags. Otherwise - section name is just
- // some magic assembler directive.
- return getSwitchToSectionDirective() + S->Name + getSectionFlags(S->Flags);
+ return S;
}
// Lame default implementation. Calculate the section name for global.
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=56573&r1=56572&r2=56573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Wed Sep 24 17:14:23 2008
@@ -148,11 +148,10 @@
void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
const Function *F = MF.getFunction();
- std::string SectionName = TAI->SectionForGlobal(F);
decorateName(CurrentFnName, F);
- SwitchToTextSection(SectionName.c_str());
+ SwitchToSection(TAI->SectionForGlobal(F));
unsigned FnAlign = OptimizeForSize ? 1 : 4;
if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
@@ -766,7 +765,6 @@
return;
}
- std::string SectionName = TAI->SectionForGlobal(GVar);
std::string name = Mang->getValueName(GVar);
Constant *C = GVar->getInitializer();
const Type *Type = C->getType();
@@ -778,7 +776,7 @@
if (Subtarget->isTargetELF())
O << "\t.type\t" << name << ", at object\n";
- SwitchToDataSection(SectionName.c_str());
+ SwitchToSection(TAI->SectionForGlobal(GVar));
if (C->isNullValue() && !GVar->hasSection()) {
// FIXME: This seems to be pretty darwin-specific
More information about the llvm-commits
mailing list