summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/MC/MCAsmInfo.h7
-rw-r--r--lib/MC/MCAsmInfo.cpp1
-rw-r--r--lib/MC/MCAsmInfoDarwin.cpp1
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp12
-rw-r--r--lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp4
-rw-r--r--lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp7
6 files changed, 21 insertions, 11 deletions
diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h
index 1368e1f424..a340a12138 100644
--- a/include/llvm/MC/MCAsmInfo.h
+++ b/include/llvm/MC/MCAsmInfo.h
@@ -202,6 +202,10 @@ namespace llvm {
/// argument that specifies the alignment of the declaration.
bool COMMDirectiveTakesAlignment; // Defaults to true.
+ /// LCOMMDirectiveTakesAlignment - True if LCOMMDirective takes a third
+ /// argument that specifies the alignment of the declaration.
+ bool LCOMMDirectiveTakesAlignment; // Defaults to false.
+
/// HasDotTypeDotSizeDirective - True if the target has .type and .size
/// directives, this is true for most ELF targets.
bool HasDotTypeDotSizeDirective; // Defaults to true.
@@ -410,6 +414,9 @@ namespace llvm {
bool getCOMMDirectiveTakesAlignment() const {
return COMMDirectiveTakesAlignment;
}
+ bool getLCOMMDirectiveTakesAlignment() const {
+ return LCOMMDirectiveTakesAlignment;
+ }
bool hasDotTypeDotSizeDirective() const {
return HasDotTypeDotSizeDirective;
}
diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp
index 277a09e9e9..4c53d7a284 100644
--- a/lib/MC/MCAsmInfo.cpp
+++ b/lib/MC/MCAsmInfo.cpp
@@ -56,6 +56,7 @@ MCAsmInfo::MCAsmInfo() {
LCOMMDirective = 0;
COMMDirective = "\t.comm\t";
COMMDirectiveTakesAlignment = true;
+ LCOMMDirectiveTakesAlignment = false;
HasDotTypeDotSizeDirective = true;
HasSingleParameterDotFile = true;
UsedDirective = 0;
diff --git a/lib/MC/MCAsmInfoDarwin.cpp b/lib/MC/MCAsmInfoDarwin.cpp
index 5de86e0c90..a1f6051990 100644
--- a/lib/MC/MCAsmInfoDarwin.cpp
+++ b/lib/MC/MCAsmInfoDarwin.cpp
@@ -37,6 +37,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
HasMachoZeroFillDirective = true; // Uses .zerofill
HasStaticCtorDtorReferenceInStaticMode = true;
+ LCOMMDirectiveTakesAlignment = true;
SetDirective = "\t.set";
ProtectedDirective = "\t.globl\t";
HasDotTypeDotSizeDirective = false;
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
index b1c1f55f17..4485ad75ef 100644
--- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
@@ -1202,14 +1202,12 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (GVKind.isBSSLocal()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
- if (isDarwin) {
- O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size
- << ',' << Align;
- } else if (MAI->getLCOMMDirective() != NULL) {
- O << MAI->getLCOMMDirective() << *GVarSym << "," << Size;
+ if (const char *LCOMM = MAI->getLCOMMDirective()) {
+ O << LCOMM << *GVarSym << "," << Size;
+ if (MAI->getLCOMMDirectiveTakesAlignment())
+ O << ',' << Align;
} else {
- if (GVar->hasLocalLinkage())
- O << "\t.local\t" << *GVarSym << '\n';
+ O << "\t.local\t" << *GVarSym << '\n';
O << MAI->getCOMMDirective() << *GVarSym << "," << Size;
if (MAI->getCOMMDirectiveTakesAlignment())
O << "," << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
index 6b8408f08a..3698949ca4 100644
--- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
@@ -951,7 +951,9 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
if (GVKind.isBSSLocal()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
- O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align;
+ O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size;
+ if (MAI->getLCOMMDirectiveTakesAlignment())
+ O << ',' << Align;
if (VerboseAsm) {
O << "\t\t" << MAI->getCommentString() << " '";
diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
index 22e2573c1c..14deafe65a 100644
--- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
@@ -647,17 +647,18 @@ void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
}
void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
- const TargetData *TD = TM.getTargetData();
MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
Constant *C = GVar->getInitializer();
const Type *Type = C->getType();
+
+ const TargetData *TD = TM.getTargetData();
unsigned Size = TD->getTypeAllocSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar);
printVisibility(GVarSym, GVar->getVisibility());
- if (Subtarget->isTargetELF())
+ if (MAI->hasDotTypeDotSizeDirective())
O << "\t.type\t" << *GVarSym << ",@object\n";
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM);
@@ -685,7 +686,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (const char *LComm = MAI->getLCOMMDirective()) {
if (GVar->hasLocalLinkage()) {
O << LComm << *GVarSym << ',' << Size;
- if (Subtarget->isTargetDarwin())
+ if (MAI->getLCOMMDirectiveTakesAlignment())
O << ',' << Align;
}
} else {