Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceELFObjectWriter.cpp - ELF object file writer --------===// | 1 //===- subzero/src/IceELFObjectWriter.cpp - ELF object file writer --------===// |
| 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 /// \file | 10 /// \file |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 SecStrBuf.str(), SHT_PROGBITS, ShFlags, Align, WriteAmt); | 505 SecStrBuf.str(), SHT_PROGBITS, ShFlags, Align, WriteAmt); |
| 506 RODataSections.push_back(Section); | 506 RODataSections.push_back(Section); |
| 507 SizeT OffsetInSection = 0; | 507 SizeT OffsetInSection = 0; |
| 508 // The symbol table entry doesn't need to know the defined symbol's | 508 // The symbol table entry doesn't need to know the defined symbol's |
| 509 // size since this is in a section with a fixed Entry Size. | 509 // size since this is in a section with a fixed Entry Size. |
| 510 const SizeT SymbolSize = 0; | 510 const SizeT SymbolSize = 0; |
| 511 Section->setFileOffset(alignFileOffset(Align)); | 511 Section->setFileOffset(alignFileOffset(Align)); |
| 512 | 512 |
| 513 // If the -reorder-pooled-constant option is set to true, we should shuffle | 513 // If the -reorder-pooled-constant option is set to true, we should shuffle |
| 514 // the constants before we emit them. | 514 // the constants before we emit them. |
| 515 auto *CtxPtr = &Ctx; | 515 if (Ctx.getFlags().shouldReorderPooledConstants()) { |
| 516 if (Ctx.getFlags().shouldReorderPooledConstants()) | 516 if (!Pool.empty()) { |
|
Jim Stichnoth
2015/08/19 19:03:04
Can combine this and the above condition, as noted
qining
2015/08/19 23:25:48
Done.
| |
| 517 RandomShuffle(Pool.begin(), Pool.end(), [CtxPtr](uint64_t N) { | 517 // Use the constant's kind value as the salt for creating random number |
| 518 return (uint32_t)CtxPtr->getRNG().next(N); | 518 // generator. |
| 519 }); | 519 Operand::OperandKind K = (*Pool.begin())->getKind(); |
| 520 RandomNumberGenerator RNG(Ctx.getFlags().getRandomSeed(), | |
| 521 RS_PooledConstantReordering, K); | |
| 522 RandomShuffle(Pool.begin(), Pool.end(), | |
| 523 [&RNG](uint64_t N) { return (uint32_t)RNG.next(N); }); | |
| 524 } | |
| 525 } | |
| 520 // Write the data. | 526 // Write the data. |
| 521 for (Constant *C : Pool) { | 527 for (Constant *C : Pool) { |
| 522 if (!C->getShouldBePooled()) | 528 if (!C->getShouldBePooled()) |
| 523 continue; | 529 continue; |
| 524 auto Const = llvm::cast<ConstType>(C); | 530 auto Const = llvm::cast<ConstType>(C); |
| 525 std::string SymBuffer; | 531 std::string SymBuffer; |
| 526 llvm::raw_string_ostream SymStrBuf(SymBuffer); | 532 llvm::raw_string_ostream SymStrBuf(SymBuffer); |
| 527 Const->emitPoolLabel(SymStrBuf); | 533 Const->emitPoolLabel(SymStrBuf); |
| 528 std::string &SymName = SymStrBuf.str(); | 534 std::string &SymName = SymStrBuf.str(); |
| 529 SymTab->createDefinedSym(SymName, STT_NOTYPE, STB_LOCAL, Section, | 535 SymTab->createDefinedSym(SymName, STT_NOTYPE, STB_LOCAL, Section, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 if (ELF64) { | 671 if (ELF64) { |
| 666 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), | 672 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), |
| 667 AllSections.size()); | 673 AllSections.size()); |
| 668 } else { | 674 } else { |
| 669 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), | 675 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), |
| 670 AllSections.size()); | 676 AllSections.size()); |
| 671 } | 677 } |
| 672 } | 678 } |
| 673 | 679 |
| 674 } // end of namespace Ice | 680 } // end of namespace Ice |
| OLD | NEW |