Chromium Code Reviews| Index: src/IceELFObjectWriter.cpp |
| diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp |
| index 05497548c99fdcb080ccdd7b47420defa8ff7de1..21bd77795aeff931669289e2e3554eec8a72ff84 100644 |
| --- a/src/IceELFObjectWriter.cpp |
| +++ b/src/IceELFObjectWriter.cpp |
| @@ -390,8 +390,9 @@ void ELFObjectWriter::writeDataOfType(SectionType ST, |
| Var->getInitializers()) { |
| switch (Init->getKind()) { |
| case VariableDeclaration::Initializer::DataInitializerKind: { |
| - const auto Data = llvm::cast<VariableDeclaration::DataInitializer>( |
| - Init.get())->getContents(); |
| + const auto Data = |
|
John
2015/06/24 00:24:00
please change this to
const auto& Data,
or this
qining
2015/06/24 01:20:40
Done.
|
| + llvm::cast<VariableDeclaration::DataInitializer>(Init.get()) |
| + ->getContents(); |
| Section->appendData(Str, llvm::StringRef(Data.data(), Data.size())); |
| break; |
| } |
| @@ -507,6 +508,13 @@ template <typename ConstType> void ELFObjectWriter::writeConstantPool(Type Ty) { |
| const SizeT SymbolSize = 0; |
| Section->setFileOffset(alignFileOffset(Align)); |
| + // If the -reorder-pooled-constant option is set to true, we should shuffle |
| + // the constants before we emit them. |
| + if (Ctx.getFlags().shouldReorderPooledConstants()) |
| + RandomShuffle(Pool.begin(), Pool.end(), [this](uint64_t N) { |
|
John
2015/06/24 00:24:00
Can you capture [Ctx] instead of [this]?
qining
2015/06/24 01:20:40
Done. But it seems I can't capture Ctx or its refe
John
2015/06/24 08:15:54
Oh, I was genuinely asking whether capturing [Ctx]
|
| + return (uint32_t)Ctx.getRNG().next(N); |
| + }); |
| + |
| // Write the data. |
| for (Constant *C : Pool) { |
| if (!C->getShouldBePooled()) |