| 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() && !Pool.empty()) { |
| 516 if (Ctx.getFlags().shouldReorderPooledConstants()) | 516 // Use the constant's kind value as the salt for creating random number |
| 517 RandomShuffle(Pool.begin(), Pool.end(), [CtxPtr](uint64_t N) { | 517 // generator. |
| 518 return (uint32_t)CtxPtr->getRNG().next(N); | 518 Operand::OperandKind K = (*Pool.begin())->getKind(); |
| 519 }); | 519 RandomNumberGenerator RNG(Ctx.getFlags().getRandomSeed(), |
| 520 RPE_PooledConstantReordering, K); |
| 521 RandomShuffle(Pool.begin(), Pool.end(), |
| 522 [&RNG](uint64_t N) { return (uint32_t)RNG.next(N); }); |
| 523 } |
| 520 // Write the data. | 524 // Write the data. |
| 521 for (Constant *C : Pool) { | 525 for (Constant *C : Pool) { |
| 522 if (!C->getShouldBePooled()) | 526 if (!C->getShouldBePooled()) |
| 523 continue; | 527 continue; |
| 524 auto Const = llvm::cast<ConstType>(C); | 528 auto Const = llvm::cast<ConstType>(C); |
| 525 std::string SymBuffer; | 529 std::string SymBuffer; |
| 526 llvm::raw_string_ostream SymStrBuf(SymBuffer); | 530 llvm::raw_string_ostream SymStrBuf(SymBuffer); |
| 527 Const->emitPoolLabel(SymStrBuf); | 531 Const->emitPoolLabel(SymStrBuf); |
| 528 std::string &SymName = SymStrBuf.str(); | 532 std::string &SymName = SymStrBuf.str(); |
| 529 SymTab->createDefinedSym(SymName, STT_NOTYPE, STB_LOCAL, Section, | 533 SymTab->createDefinedSym(SymName, STT_NOTYPE, STB_LOCAL, Section, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 if (ELF64) { | 669 if (ELF64) { |
| 666 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), | 670 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), |
| 667 AllSections.size()); | 671 AllSections.size()); |
| 668 } else { | 672 } else { |
| 669 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), | 673 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), |
| 670 AllSections.size()); | 674 AllSections.size()); |
| 671 } | 675 } |
| 672 } | 676 } |
| 673 | 677 |
| 674 } // end of namespace Ice | 678 } // end of namespace Ice |
| OLD | NEW |