Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: src/IceELFObjectWriter.cpp

Issue 1206723003: Function Layout, Global Variable Layout and Pooled Constants Layout Reordering (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceELFObjectWriter.cpp
diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp
index dd20dbc07145b8787c7bbb238e6ad49e754c9d42..eca340312a101edb9275a054a2b2d915d1e0c9f4 100644
--- a/src/IceELFObjectWriter.cpp
+++ b/src/IceELFObjectWriter.cpp
@@ -390,7 +390,7 @@ void ELFObjectWriter::writeDataOfType(SectionType ST,
Var->getInitializers()) {
switch (Init->getKind()) {
case VariableDeclaration::Initializer::DataInitializerKind: {
- const auto Data =
+ const auto &Data =
llvm::cast<VariableDeclaration::DataInitializer>(Init.get())
->getContents();
Section->appendData(Str, llvm::StringRef(Data.data(), Data.size()));
@@ -508,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.
+ 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())
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceGlobalContext.cpp » ('j') | src/IceGlobalContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698