[llvm-commits] [llvm] r168704 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/ARM/2010-12-15-elf-lcomm.ll test/CodeGen/ARM/elf-lcomm-align.ll
Rafael EspĂndola
rafael.espindola at gmail.com
Wed Nov 28 17:27:31 PST 2012
Any reason why the integrated assembler should not implement lcomm the
same way as the external assembler?
On 27 November 2012 11:11, Ulrich Weigand <ulrich.weigand at de.ibm.com> wrote:
> Author: uweigand
> Date: Tue Nov 27 10:11:16 2012
> New Revision: 168704
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168704&view=rev
> Log:
> Never use .lcomm on platforms where it does not accept an alignment
> argument. Instead, use a pair of .local and .comm directives.
>
> This avoids spurious differences between binaries built by the
> integrated assembler vs. those built by the external assembler,
> since the external assembler may impose alignment requirements
> on .lcomm symbols where the integrated assembler does not.
>
> Modified:
> llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll
> llvm/trunk/test/CodeGen/ARM/elf-lcomm-align.ll
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=168704&r1=168703&r2=168704&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Nov 27 10:11:16 2012
> @@ -308,8 +308,13 @@
> return;
> }
>
> - if (Align == 1 ||
> - MAI->getLCOMMDirectiveAlignmentType() != LCOMM::NoAlignment) {
> + // Use .lcomm only if it supports user-specified alignment.
> + // Otherwise, while it would still be correct to use .lcomm in some
> + // cases (e.g. when Align == 1), the external assembler might enfore
> + // some -unknown- default alignment behavior, which could cause
> + // spurious differences between external and integrated assembler.
> + // Prefer to simply fall back to .local / .comm in this case.
> + if (MAI->getLCOMMDirectiveAlignmentType() != LCOMM::NoAlignment) {
> // .lcomm _foo, 42
> OutStreamer.EmitLocalCommonSymbol(GVSym, Size, Align);
> return;
>
> Modified: llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll?rev=168704&r1=168703&r2=168704&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll (original)
> +++ llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll Tue Nov 27 10:11:16 2012
> @@ -10,7 +10,8 @@
> @STRIDE = internal global i32 8
>
> ; ASM: .type array00,%object @ @array00
> -; ASM-NEXT: .lcomm array00,80
> +; ASM-NEXT: .local array00
> +; ASM-NEXT: .comm array00,80,1
> ; ASM-NEXT: .type _MergedGlobals,%object @ @_MergedGlobals
>
>
>
> Modified: llvm/trunk/test/CodeGen/ARM/elf-lcomm-align.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/elf-lcomm-align.ll?rev=168704&r1=168703&r2=168704&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/ARM/elf-lcomm-align.ll (original)
> +++ llvm/trunk/test/CodeGen/ARM/elf-lcomm-align.ll Tue Nov 27 10:11:16 2012
> @@ -4,8 +4,9 @@
> @c = internal global i8 0, align 1
> @x = internal global i32 0, align 4
>
> -; CHECK: .lcomm c,1
> -; .lcomm doesn't support alignment.
> +; .lcomm doesn't support alignment, so we always use .local/.comm.
> +; CHECK: .local c
> +; CHECK-NEXT: .comm c,1,1
> ; CHECK: .local x
> ; CHECK-NEXT: .comm x,4,4
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list