summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp19
-rw-r--r--llvm/test/MC/Hexagon/lcomm.s19
2 files changed, 31 insertions, 7 deletions
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp
index eaa3550d07f..67dcb8fea73 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp
@@ -107,15 +107,20 @@ void HexagonMCELFStreamer::HexagonMCEmitCommonSymbol(MCSymbol *Symbol,
((AccessSize == 0) || (Size == 0) || (Size > GPSize))
? ".bss"
: sbss[(Log2_64(AccessSize))];
-
- MCSection *CrntSection = getCurrentSection().first;
- MCSection *Section = getAssembler().getContext().getELFSection(
+ MCSection &Section = *getAssembler().getContext().getELFSection(
SectionName, ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
- SwitchSection(Section);
- AssignFragment(Symbol, getCurrentFragment());
+ MCSectionSubPair P = getCurrentSection();
+ SwitchSection(&Section);
+
+ EmitValueToAlignment(ByteAlignment, 0, 1, 0);
+ EmitLabel(Symbol);
+ EmitZeros(Size);
+
+ // Update the maximum alignment of the section if necessary.
+ if (ByteAlignment > Section.getAlignment())
+ Section.setAlignment(ByteAlignment);
- MCELFStreamer::EmitCommonSymbol(Symbol, Size, ByteAlignment);
- SwitchSection(CrntSection);
+ SwitchSection(P.first, P.second);
} else {
if (ELFSymbol->declareCommon(Size, ByteAlignment))
report_fatal_error("Symbol: " + Symbol->getName() +
diff --git a/llvm/test/MC/Hexagon/lcomm.s b/llvm/test/MC/Hexagon/lcomm.s
new file mode 100644
index 00000000000..ba44bc842c7
--- /dev/null
+++ b/llvm/test/MC/Hexagon/lcomm.s
@@ -0,0 +1,19 @@
+# RUN: llvm-mc -filetype=obj -triple=hexagon %s | llvm-objdump -t - | FileCheck %s
+.lcomm dst1,1,1,1
+.lcomm dst2,2,2,2
+.lcomm dst4,4,4,4
+.lcomm dst8,8,8,8
+
+r0 = add(pc, ##dst1@PCREL)
+r0 = add(pc, ##dst2@PCREL)
+r0 = add(pc, ##dst4@PCREL)
+r0 = add(pc, ##dst8@PCREL)
+
+# CHECK: 00000000 l .sbss.1 00000001 dst1
+# CHECK: 00000000 l .sbss.2 00000002 dst2
+# CHECK: 00000000 l .sbss.4 00000004 dst4
+# CHECK: 00000000 l .sbss.8 00000008 dst8
+# CHECK: 00000000 l d .sbss.1 00000000 .sbss.1
+# CHECK: 00000000 l d .sbss.2 00000000 .sbss.2
+# CHECK: 00000000 l d .sbss.4 00000000 .sbss.4
+# CHECK: 00000000 l d .sbss.8 00000000 .sbss.8 \ No newline at end of file
OpenPOWER on IntegriCloud