| Index: src/IceELFObjectWriter.cpp
|
| diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp
|
| index 05497548c99fdcb080ccdd7b47420defa8ff7de1..129bd57d65181401b9b3fd5631d049a65da5645e 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 =
|
| + llvm::cast<VariableDeclaration::DataInitializer>(Init.get())
|
| + ->getContents();
|
| Section->appendData(Str, llvm::StringRef(Data.data(), Data.size()));
|
| break;
|
| }
|
| @@ -507,6 +508,14 @@ 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.
|
| + auto* CtxPtr = &Ctx;
|
| + if (Ctx.getFlags().shouldReorderPooledConstants())
|
| + RandomShuffle(Pool.begin(), Pool.end(), [CtxPtr](uint64_t N) {
|
| + return (uint32_t)CtxPtr->getRNG().next(N);
|
| + });
|
| +
|
| // Write the data.
|
| for (Constant *C : Pool) {
|
| if (!C->getShouldBePooled())
|
|
|