[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Feb 14 14:18:35 PST 2006
Changes in directory llvm/lib/Target/PowerPC:
PPCAsmPrinter.cpp updated: 1.150 -> 1.151
---
Log message:
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.
---
Diffs of the changes: (+11 -4)
PPCAsmPrinter.cpp | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.150 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.151
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.150 Tue Feb 14 14:42:33 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Tue Feb 14 16:18:23 2006
@@ -539,13 +539,20 @@
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()) {
More information about the llvm-commits
mailing list