diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index f4545bef224..626b34d609e 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -152,9 +152,8 @@ namespace llvm { /// @param Symbol - The common symbol to emit. /// @param Size - The size of the common symbol. /// @param Pow2Alignment - The alignment of the common symbol if non-zero. - /// @param IsLocal - If true, then the symbol is to be a local common virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, - unsigned Pow2Alignment, bool IsLocal) = 0; + unsigned Pow2Alignment) = 0; /// EmitZerofill - Emit a the zerofill section and possiblity a symbol, if /// @param Symbol is non-NULL, for @param Size and with the @param diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 4c2f128b1da..fa7c7cf09a4 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -56,7 +56,7 @@ public: virtual void EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value); virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, - unsigned Pow2Alignment, bool IsLocal); + unsigned Pow2Alignment); virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned Pow2Alignment = 0); @@ -178,11 +178,8 @@ void MCAsmStreamer::EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value) { } void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, - unsigned Pow2Alignment, bool IsLocal) { - if (IsLocal) - OS << ".lcomm"; - else - OS << ".comm"; + unsigned Pow2Alignment) { + OS << ".comm"; OS << ' ' << Symbol << ',' << Size; if (Pow2Alignment != 0) OS << ',' << Pow2Alignment; diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index 7e8a715eaaf..e89f7d8dbd3 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -105,7 +105,7 @@ public: virtual void EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value); virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, - unsigned Pow2Alignment, bool IsLocal); + unsigned Pow2Alignment); virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned Pow2Alignment = 0); @@ -268,8 +268,7 @@ void MCMachOStreamer::EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value) { } void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, - unsigned Pow2Alignment, - bool IsLocal) { + unsigned Pow2Alignment) { llvm_unreachable("FIXME: Not yet implemented!"); } diff --git a/lib/MC/MCNullStreamer.cpp b/lib/MC/MCNullStreamer.cpp index 14534ed01b1..fa2aec392dc 100644 --- a/lib/MC/MCNullStreamer.cpp +++ b/lib/MC/MCNullStreamer.cpp @@ -44,7 +44,7 @@ namespace { virtual void EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value) {} virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, - unsigned Pow2Alignment, bool IsLocal) {} + unsigned Pow2Alignment) {} virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned Pow2Alignment = 0) {} diff --git a/test/MC/AsmParser/directive_lcomm.s b/test/MC/AsmParser/directive_lcomm.s index afc61216c4f..d38805fc479 100644 --- a/test/MC/AsmParser/directive_lcomm.s +++ b/test/MC/AsmParser/directive_lcomm.s @@ -1,9 +1,9 @@ # RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s # CHECK: TEST0: -# CHECK: .lcomm a,7,4 -# CHECK: .lcomm b,8 -# CHECK: .lcomm c,0 +# CHECK: .zerofill __DATA,__bss,a,7,4 +# CHECK: .zerofill __DATA,__bss,b,8 +# CHECK: .zerofill __DATA,__bss,c,0 TEST0: .lcomm a, 8-1, 4 .lcomm b,8 diff --git a/test/MC/AsmParser/labels.s b/test/MC/AsmParser/labels.s index f3066852568..30daeb76428 100644 --- a/test/MC/AsmParser/labels.s +++ b/test/MC/AsmParser/labels.s @@ -44,7 +44,7 @@ foo: // CHECK: .comm "a 6",1 .comm "a 6", 1 -// CHECK: .lcomm "a 7",1 +// CHECK: .zerofill __DATA,__bss,"a 7",1 .lcomm "a 7", 1 // CHECK: .lsym "a 8",1 diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index 9f219925b0f..74512ca9353 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -1258,7 +1258,13 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) { return Error(IDLoc, "invalid symbol redefinition"); // Create the Symbol as a common or local common with Size and Pow2Alignment - Out.EmitCommonSymbol(Sym, Size, Pow2Alignment, IsLocal); + if (IsLocal) + Out.EmitZerofill(getMachOSection("__DATA", "__bss", + MCSectionMachO::S_ZEROFILL, 0, + SectionKind()), + Sym, Size, Pow2Alignment); + else + Out.EmitCommonSymbol(Sym, Size, Pow2Alignment); return false; }