summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-02-14 22:18:23 +0000
committerChris Lattner <sabre@nondot.org>2006-02-14 22:18:23 +0000
commitb134520b866a999711ef737849d1431c2028f866 (patch)
treec72a1f9a21a09e8d15bb6373a00cb856937776f3 /llvm/lib/Target
parentebb50a61d26e333c475b32d066d8824e5c60c551 (diff)
downloadbcm5719-llvm-b134520b866a999711ef737849d1431c2028f866.tar.gz
bcm5719-llvm-b134520b866a999711ef737849d1431c2028f866.zip
If we have zero initialized data with external linkage, use .zerofill to
emit it (instead of .space), saving a bit of space in the .o file. For example: int foo[100]; int bar[100] = {}; when compiled with C++ or -fno-common results in shrinkage from 1160 to 360 bytes of space. The X86 backend can also do this on darwin. llvm-svn: 26185
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index e66b0e86e26..9a3df608b43 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -539,13 +539,20 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
if (C->isNullValue() && /* FIXME: Verify correct */
(I->hasInternalLinkage() || I->hasWeakLinkage() ||
- I->hasLinkOnceLinkage())) {
- SwitchSection(".data", I);
+ I->hasLinkOnceLinkage() ||
+ (I->hasExternalLinkage() && !I->hasSection()))) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
- if (I->hasInternalLinkage())
+ if (I->hasExternalLinkage()) {
+ O << "\t.globl " << name << '\n';
+ O << "\t.zerofill __DATA, __common, " << name << ", "
+ << Size << ", " << Align;
+ } else if (I->hasInternalLinkage()) {
+ SwitchSection(".data", I);
O << LCOMMDirective << name << "," << Size << "," << Align;
- else
+ } else {
+ SwitchSection(".data", I);
O << ".comm " << name << "," << Size;
+ }
O << "\t\t; '" << I->getName() << "'\n";
} else {
switch (I->getLinkage()) {
OpenPOWER on IntegriCloud