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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 557533003: Subzero: Make sure alloca with align=0 is handled correctly. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remap align=0 to align=1 in lowering Created 6 years, 3 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 | « src/IceInst.cpp ('k') | tests_lit/llvm2ice_tests/alloc.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 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 // aligned before the alloca. All the alloca code ensures that the 1111 // aligned before the alloca. All the alloca code ensures that the
1112 // stack alignment is preserved after the alloca. The stack alignment 1112 // stack alignment is preserved after the alloca. The stack alignment
1113 // restriction can be relaxed in some cases. 1113 // restriction can be relaxed in some cases.
1114 NeedsStackAlignment = true; 1114 NeedsStackAlignment = true;
1115 1115
1116 // TODO(sehr,stichnot): minimize the number of adjustments of esp, etc. 1116 // TODO(sehr,stichnot): minimize the number of adjustments of esp, etc.
1117 Variable *esp = getPhysicalRegister(Reg_esp); 1117 Variable *esp = getPhysicalRegister(Reg_esp);
1118 Operand *TotalSize = legalize(Inst->getSizeInBytes()); 1118 Operand *TotalSize = legalize(Inst->getSizeInBytes());
1119 Variable *Dest = Inst->getDest(); 1119 Variable *Dest = Inst->getDest();
1120 uint32_t AlignmentParam = Inst->getAlignInBytes(); 1120 uint32_t AlignmentParam = Inst->getAlignInBytes();
1121 // For default align=0, set it to the real value 1, to avoid any
1122 // bit-manipulation problems below.
1123 AlignmentParam = std::max(AlignmentParam, 1u);
1121 1124
1122 // LLVM enforces power of 2 alignment. 1125 // LLVM enforces power of 2 alignment.
1123 assert((AlignmentParam & (AlignmentParam - 1)) == 0); 1126 assert((AlignmentParam & (AlignmentParam - 1)) == 0);
1124 assert((X86_STACK_ALIGNMENT_BYTES & (X86_STACK_ALIGNMENT_BYTES - 1)) == 0); 1127 assert((X86_STACK_ALIGNMENT_BYTES & (X86_STACK_ALIGNMENT_BYTES - 1)) == 0);
1125 1128
1126 uint32_t Alignment = std::max(AlignmentParam, X86_STACK_ALIGNMENT_BYTES); 1129 uint32_t Alignment = std::max(AlignmentParam, X86_STACK_ALIGNMENT_BYTES);
1127 if (Alignment > X86_STACK_ALIGNMENT_BYTES) { 1130 if (Alignment > X86_STACK_ALIGNMENT_BYTES) {
1128 _and(esp, Ctx->getConstantInt(IceType_i32, -Alignment)); 1131 _and(esp, Ctx->getConstantInt(IceType_i32, -Alignment));
1129 } 1132 }
1130 if (ConstantInteger *ConstantTotalSize = 1133 if (ConstantInteger *ConstantTotalSize =
(...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after
4454 Str << "\t.align\t" << Align << "\n"; 4457 Str << "\t.align\t" << Align << "\n";
4455 Str << MangledName << ":\n"; 4458 Str << MangledName << ":\n";
4456 for (SizeT i = 0; i < Size; ++i) { 4459 for (SizeT i = 0; i < Size; ++i) {
4457 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 4460 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
4458 } 4461 }
4459 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4462 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4460 } 4463 }
4461 } 4464 }
4462 4465
4463 } // end of namespace Ice 4466 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInst.cpp ('k') | tests_lit/llvm2ice_tests/alloc.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698