summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2012-11-27 16:11:16 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2012-11-27 16:11:16 +0000
commite5f9405842271e118ead8d5994cbc469560995b3 (patch)
treeb39e87aefe2a47d9c2140aa20d9d0c477d6d4d3a /llvm
parentb0448cd52a39223e2b626b6db92f5668a0c6fe90 (diff)
downloadbcm5719-llvm-e5f9405842271e118ead8d5994cbc469560995b3.tar.gz
bcm5719-llvm-e5f9405842271e118ead8d5994cbc469560995b3.zip
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. llvm-svn: 168704
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp9
-rw-r--r--llvm/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll3
-rw-r--r--llvm/test/CodeGen/ARM/elf-lcomm-align.ll5
3 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 52840faf7c3..72b2f0c62af 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -308,8 +308,13 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
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;
diff --git a/llvm/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll b/llvm/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll
index 5cfbb4f944f..1272a257931 100644
--- a/llvm/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll
+++ b/llvm/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll
@@ -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
diff --git a/llvm/test/CodeGen/ARM/elf-lcomm-align.ll b/llvm/test/CodeGen/ARM/elf-lcomm-align.ll
index 46792990e59..a98b3c06f5e 100644
--- a/llvm/test/CodeGen/ARM/elf-lcomm-align.ll
+++ b/llvm/test/CodeGen/ARM/elf-lcomm-align.ll
@@ -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
OpenPOWER on IntegriCloud