[llvm] r266882 - [Hexagon] Fix handling of lcomm directive
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 20 08:54:14 PDT 2016
Author: kparzysz
Date: Wed Apr 20 10:54:13 2016
New Revision: 266882
URL: http://llvm.org/viewvc/llvm-project?rev=266882&view=rev
Log:
[Hexagon] Fix handling of lcomm directive
Patch by Colin LeMahieu.
Added:
llvm/trunk/test/MC/Hexagon/lcomm.s
Modified:
llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp
Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp?rev=266882&r1=266881&r2=266882&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp Wed Apr 20 10:54:13 2016
@@ -107,15 +107,20 @@ void HexagonMCELFStreamer::HexagonMCEmit
((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() +
Added: llvm/trunk/test/MC/Hexagon/lcomm.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Hexagon/lcomm.s?rev=266882&view=auto
==============================================================================
--- llvm/trunk/test/MC/Hexagon/lcomm.s (added)
+++ llvm/trunk/test/MC/Hexagon/lcomm.s Wed Apr 20 10:54:13 2016
@@ -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 at PCREL)
+r0 = add(pc, ##dst2 at PCREL)
+r0 = add(pc, ##dst4 at PCREL)
+r0 = add(pc, ##dst8 at 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
More information about the llvm-commits
mailing list