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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/globalinit.pnacl.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringX8632.cpp
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 501cdd733f2926220d130ecb879f546f6987f653..b092f7ffaa443534d69621800a6e325b5546a7a2 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -4663,24 +4663,16 @@ void TargetGlobalInitX8632::lower(const VariableDeclaration &Var) {
Str << "\t.section\t.rodata" << SectionSuffix << ",\"a\",@progbits\n";
else if (HasNonzeroInitializer)
Str << "\t.section\t.data" << SectionSuffix << ",\"aw\",@progbits\n";
- else if (IsExternal)
+ else
Str << "\t.section\t.bss" << SectionSuffix << ",\"aw\",@nobits\n";
- // No .section for non-constant + zeroinitializer + internal
if (IsExternal)
Str << "\t.globl\t" << MangledName << "\n";
- else if (!IsConstant && !HasNonzeroInitializer)
- Str << "\t.local\t" << MangledName << "\n";
- // Internal symbols only get .local when using .comm.
- if ((IsConstant || HasNonzeroInitializer || IsExternal) && Align > 1)
+ if (Align > 1)
Str << "\t.align\t" << Align << "\n";
- // Alignment is part of .comm.
- if (IsConstant || HasNonzeroInitializer || IsExternal)
- Str << MangledName << ":\n";
- else
- Str << "\t.comm\t" << MangledName << "," << Size << "," << Align << "\n";
+ Str << MangledName << ":\n";
if (HasNonzeroInitializer) {
for (VariableDeclaration::Initializer *Init : Initializers) {
@@ -4712,13 +4704,14 @@ void TargetGlobalInitX8632::lower(const VariableDeclaration &Var) {
}
}
}
- } else if (IsConstant || IsExternal)
+ } else
+ // NOTE: for non-constant zero initializers, this is BSS (no bits),
+ // so an ELF writer would not write to the file, and only track
+ // virtual offsets, but the .s writer still needs this .zero and
+ // cannot simply use the .size to advance offsets.
Str << "\t.zero\t" << Size << "\n";
- // Size is part of .comm.
- if (IsConstant || HasNonzeroInitializer || IsExternal)
- Str << "\t.size\t" << MangledName << ", " << Size << "\n";
- // Size is part of .comm.
+ Str << "\t.size\t" << MangledName << ", " << Size << "\n";
}
} // end of namespace Ice
« 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