From b97809c9a7a4ef681070ab1cbc7bd4fb18d34ba1 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 19 Oct 2006 13:30:40 +0000 Subject: [PATCH] print common symbols git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31048 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMAsmPrinter.cpp | 50 +++++++++++++++++++++----------- test/CodeGen/ARM/constants.ll | 5 +++- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index f67f39aa7d0..aa465cc24f8 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -278,26 +278,42 @@ bool ARMAsmPrinter::doFinalization(Module &M) { unsigned Size = TD->getTypeSize(C->getType()); unsigned Align = TD->getTypeAlignment(C->getType()); - switch (I->getLinkage()) { - default: - assert(0 && "Unknown linkage type!"); - break; - case GlobalValue::ExternalLinkage: - O << "\t.globl " << name << "\n"; - break; - case GlobalValue::InternalLinkage: - break; - } + if (C->isNullValue() && + (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || + I->hasWeakLinkage())) { + SwitchToDataSection(".data", I); + if (I->hasInternalLinkage()) + O << "\t.local " << name << "\n"; + + O << "\t.comm " << name << "," << TD->getTypeSize(C->getType()) + << "," << (unsigned)TD->getTypeAlignment(C->getType()); + O << "\t\t"; + O << TAI->getCommentString() << " "; + WriteAsOperand(O, I, true, true, &M); + O << "\n"; + } else { + switch (I->getLinkage()) { + default: + assert(0 && "Unknown linkage type!"); + break; + case GlobalValue::ExternalLinkage: + O << "\t.globl " << name << "\n"; + break; + case GlobalValue::InternalLinkage: + break; + } - assert (!C->isNullValue()); - SwitchToDataSection(".data", I); + assert (!C->isNullValue()); + SwitchToDataSection(".data", I); - EmitAlignment(Align, I); - O << "\t.type " << name << ", %object\n"; - O << "\t.size " << name << ", " << Size << "\n"; - O << name << ":\n"; - EmitGlobalConstant(C); + EmitAlignment(Align, I); + O << "\t.type " << name << ", %object\n"; + O << "\t.size " << name << ", " << Size << "\n"; + O << name << ":\n"; + EmitGlobalConstant(C); + } } + AsmPrinter::doFinalization(M); return false; // success } diff --git a/test/CodeGen/ARM/constants.ll b/test/CodeGen/ARM/constants.ll index 9d5fb8e637d..f161b9d070b 100644 --- a/test/CodeGen/ARM/constants.ll +++ b/test/CodeGen/ARM/constants.ll @@ -4,7 +4,10 @@ ; RUN: llvm-as < %s | llc -march=arm | grep "mov r0, #256" | wc -l | grep 1 && ; RUN: llvm-as < %s | llc -march=arm | grep ".word.*257" | wc -l | grep 1 && ; RUN: llvm-as < %s | llc -march=arm | grep "mov r0, #-1073741761" | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm | grep "mov r0, #1008" | wc -l | grep 1 +; RUN: llvm-as < %s | llc -march=arm | grep "mov r0, #1008" | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=arm | grep "\.comm.*a,4,4" | wc -l | grep 1 + +%a = internal global int 0 uint %f1() { ret uint 0 -- 2.34.1