Chromium Code Reviews| Index: src/IceELFObjectWriter.cpp |
| diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp |
| index f32a2b6671bb9b2857cfa77387f7f68c6edbd6e8..cb553a133be90d84643c97e59733137def5db3c8 100644 |
| --- a/src/IceELFObjectWriter.cpp |
| +++ b/src/IceELFObjectWriter.cpp |
| @@ -512,11 +512,17 @@ template <typename ConstType> void ELFObjectWriter::writeConstantPool(Type Ty) { |
| // 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); |
| - }); |
| + if (Ctx.getFlags().shouldReorderPooledConstants()) { |
| + 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.
|
| + // Use the constant's kind value as the salt for creating random number |
| + // generator. |
| + Operand::OperandKind K = (*Pool.begin())->getKind(); |
| + RandomNumberGenerator RNG(Ctx.getFlags().getRandomSeed(), |
| + RS_PooledConstantReordering, K); |
| + RandomShuffle(Pool.begin(), Pool.end(), |
| + [&RNG](uint64_t N) { return (uint32_t)RNG.next(N); }); |
| + } |
| + } |
| // Write the data. |
| for (Constant *C : Pool) { |
| if (!C->getShouldBePooled()) |