Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 870123003: Make use of BSS more explicit in global initializers (vs a local .comm). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: local by default Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/globalinit.pnacl.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the TargetLoweringX8632 class, which 10 // This file implements the TargetLoweringX8632 class, which
(...skipping 4645 matching lines...) Expand 10 before | Expand all | Expand 10 after
4656 IceString SectionSuffix = ""; 4656 IceString SectionSuffix = "";
4657 if (Ctx->getFlags().DataSections) 4657 if (Ctx->getFlags().DataSections)
4658 SectionSuffix = "." + MangledName; 4658 SectionSuffix = "." + MangledName;
4659 4659
4660 Str << "\t.type\t" << MangledName << ",@object\n"; 4660 Str << "\t.type\t" << MangledName << ",@object\n";
4661 4661
4662 if (IsConstant) 4662 if (IsConstant)
4663 Str << "\t.section\t.rodata" << SectionSuffix << ",\"a\",@progbits\n"; 4663 Str << "\t.section\t.rodata" << SectionSuffix << ",\"a\",@progbits\n";
4664 else if (HasNonzeroInitializer) 4664 else if (HasNonzeroInitializer)
4665 Str << "\t.section\t.data" << SectionSuffix << ",\"aw\",@progbits\n"; 4665 Str << "\t.section\t.data" << SectionSuffix << ",\"aw\",@progbits\n";
4666 else if (IsExternal) 4666 else
4667 Str << "\t.section\t.bss" << SectionSuffix << ",\"aw\",@nobits\n"; 4667 Str << "\t.section\t.bss" << SectionSuffix << ",\"aw\",@nobits\n";
4668 // No .section for non-constant + zeroinitializer + internal
4669 4668
4670 if (IsExternal) 4669 if (IsExternal)
4671 Str << "\t.globl\t" << MangledName << "\n"; 4670 Str << "\t.globl\t" << MangledName << "\n";
4672 else if (!IsConstant && !HasNonzeroInitializer)
4673 Str << "\t.local\t" << MangledName << "\n";
4674 // Internal symbols only get .local when using .comm.
4675 4671
4676 if ((IsConstant || HasNonzeroInitializer || IsExternal) && Align > 1) 4672 if (Align > 1)
4677 Str << "\t.align\t" << Align << "\n"; 4673 Str << "\t.align\t" << Align << "\n";
4678 // Alignment is part of .comm.
4679 4674
4680 if (IsConstant || HasNonzeroInitializer || IsExternal) 4675 Str << MangledName << ":\n";
4681 Str << MangledName << ":\n";
4682 else
4683 Str << "\t.comm\t" << MangledName << "," << Size << "," << Align << "\n";
4684 4676
4685 if (HasNonzeroInitializer) { 4677 if (HasNonzeroInitializer) {
4686 for (VariableDeclaration::Initializer *Init : Initializers) { 4678 for (VariableDeclaration::Initializer *Init : Initializers) {
4687 switch (Init->getKind()) { 4679 switch (Init->getKind()) {
4688 case VariableDeclaration::Initializer::DataInitializerKind: { 4680 case VariableDeclaration::Initializer::DataInitializerKind: {
4689 const auto Data = llvm::cast<VariableDeclaration::DataInitializer>(Init) 4681 const auto Data = llvm::cast<VariableDeclaration::DataInitializer>(Init)
4690 ->getContents(); 4682 ->getContents();
4691 for (SizeT i = 0; i < Init->getNumBytes(); ++i) { 4683 for (SizeT i = 0; i < Init->getNumBytes(); ++i) {
4692 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 4684 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
4693 } 4685 }
(...skipping 11 matching lines...) Expand all
4705 if (Offset >= 0 || (Offset == INT32_MIN)) 4697 if (Offset >= 0 || (Offset == INT32_MIN))
4706 Str << " + " << Offset; 4698 Str << " + " << Offset;
4707 else 4699 else
4708 Str << " - " << -Offset; 4700 Str << " - " << -Offset;
4709 } 4701 }
4710 Str << "\n"; 4702 Str << "\n";
4711 break; 4703 break;
4712 } 4704 }
4713 } 4705 }
4714 } 4706 }
4715 } else if (IsConstant || IsExternal) 4707 } else
4708 // NOTE: for non-constant zero initializers, this is BSS (no bits),
4709 // so an ELF writer would not write to the file, and only track
4710 // virtual offsets, but the .s writer still needs this .zero and
4711 // cannot simply use the .size to advance offsets.
4716 Str << "\t.zero\t" << Size << "\n"; 4712 Str << "\t.zero\t" << Size << "\n";
4717 // Size is part of .comm.
4718 4713
4719 if (IsConstant || HasNonzeroInitializer || IsExternal) 4714 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4720 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4721 // Size is part of .comm.
4722 } 4715 }
4723 4716
4724 } // end of namespace Ice 4717 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/globalinit.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698