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

Side by Side Diff: src/IceGlobalContext.cpp

Issue 1185703004: Add constant blinding/pooling option for X8632 code translation (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: change the default sz-seed back to 1. 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 unified diff | Download patch
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceInstX8632.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===//
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 // This file defines aspects of the compilation that persist across 10 // This file defines aspects of the compilation that persist across
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 ELFStreamer *ELFStr, const ClFlags &Flags) 218 ELFStreamer *ELFStr, const ClFlags &Flags)
219 : ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump), 219 : ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump),
220 StrEmit(OsEmit), StrError(OsError), Flags(Flags), 220 StrEmit(OsEmit), StrError(OsError), Flags(Flags),
221 RNG(Flags.getRandomSeed()), ObjectWriter(), 221 RNG(Flags.getRandomSeed()), ObjectWriter(),
222 OptQ(/*Sequential=*/Flags.isSequential(), 222 OptQ(/*Sequential=*/Flags.isSequential(),
223 /*MaxSize=*/Flags.getNumTranslationThreads()), 223 /*MaxSize=*/Flags.getNumTranslationThreads()),
224 // EmitQ is allowed unlimited size. 224 // EmitQ is allowed unlimited size.
225 EmitQ(/*Sequential=*/Flags.isSequential()), 225 EmitQ(/*Sequential=*/Flags.isSequential()),
226 DataLowering(TargetDataLowering::createLowering(this)), 226 DataLowering(TargetDataLowering::createLowering(this)),
227 HasSeenCode(false), 227 HasSeenCode(false),
228 ProfileBlockInfoVarDecl(VariableDeclaration::create()) { 228 ProfileBlockInfoVarDecl(VariableDeclaration::create()),
229 RandomizationCookie(0) {
229 assert(OsDump && "OsDump is not defined for GlobalContext"); 230 assert(OsDump && "OsDump is not defined for GlobalContext");
230 assert(OsEmit && "OsEmit is not defined for GlobalContext"); 231 assert(OsEmit && "OsEmit is not defined for GlobalContext");
231 assert(OsError && "OsError is not defined for GlobalContext"); 232 assert(OsError && "OsError is not defined for GlobalContext");
232 // Make sure thread_local fields are properly initialized before any 233 // Make sure thread_local fields are properly initialized before any
233 // accesses are made. Do this here instead of at the start of 234 // accesses are made. Do this here instead of at the start of
234 // main() so that all clients (e.g. unit tests) can benefit for 235 // main() so that all clients (e.g. unit tests) can benefit for
235 // free. 236 // free.
236 GlobalContext::TlsInit(); 237 GlobalContext::TlsInit();
237 Cfg::TlsInit(); 238 Cfg::TlsInit();
238 // Create a new ThreadContext for the current thread. No need to 239 // Create a new ThreadContext for the current thread. No need to
(...skipping 19 matching lines...) Expand all
258 break; 259 break;
259 } 260 }
260 ProfileBlockInfoVarDecl->setAlignment(typeWidthInBytes(IceType_i64)); 261 ProfileBlockInfoVarDecl->setAlignment(typeWidthInBytes(IceType_i64));
261 ProfileBlockInfoVarDecl->setIsConstant(true); 262 ProfileBlockInfoVarDecl->setIsConstant(true);
262 263
263 // Note: if you change this symbol, make sure to update 264 // Note: if you change this symbol, make sure to update
264 // runtime/szrt_profiler.c as well. 265 // runtime/szrt_profiler.c as well.
265 ProfileBlockInfoVarDecl->setName("__Sz_block_profile_info"); 266 ProfileBlockInfoVarDecl->setName("__Sz_block_profile_info");
266 ProfileBlockInfoVarDecl->setSuppressMangling(); 267 ProfileBlockInfoVarDecl->setSuppressMangling();
267 ProfileBlockInfoVarDecl->setLinkage(llvm::GlobalValue::ExternalLinkage); 268 ProfileBlockInfoVarDecl->setLinkage(llvm::GlobalValue::ExternalLinkage);
269
270 // Initialize the randomization cookie for constant blinding only if constant
271 // blinding or pooling is turned on.
272 // TODO(stichnot): Using RNG for constant blinding will affect the random
273 // number to be used in nop-insertion and randomize-regalloc.
274 if (Flags.getRandomizeAndPoolImmediatesOption() != RPI_None)
275 RandomizationCookie =
276 (uint32_t)RNG.next((uint64_t)std::numeric_limits<uint32_t>::max + 1);
268 } 277 }
269 278
270 void GlobalContext::translateFunctions() { 279 void GlobalContext::translateFunctions() {
271 while (std::unique_ptr<Cfg> Func = optQueueBlockingPop()) { 280 while (std::unique_ptr<Cfg> Func = optQueueBlockingPop()) {
272 // Install Func in TLS for Cfg-specific container allocators. 281 // Install Func in TLS for Cfg-specific container allocators.
273 Cfg::setCurrentCfg(Func.get()); 282 Cfg::setCurrentCfg(Func.get());
274 // Reset per-function stats being accumulated in TLS. 283 // Reset per-function stats being accumulated in TLS.
275 resetStats(); 284 resetStats();
276 // Set verbose level to none if the current function does NOT 285 // Set verbose level to none if the current function does NOT
277 // match the -verbose-focus command-line option. 286 // match the -verbose-focus command-line option.
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 case IceType_NUM: 755 case IceType_NUM:
747 break; 756 break;
748 } 757 }
749 llvm_unreachable("Unknown type"); 758 llvm_unreachable("Unknown type");
750 } 759 }
751 760
752 ConstantList GlobalContext::getConstantPool(Type Ty) { 761 ConstantList GlobalContext::getConstantPool(Type Ty) {
753 switch (Ty) { 762 switch (Ty) {
754 case IceType_i1: 763 case IceType_i1:
755 case IceType_i8: 764 case IceType_i8:
765 return getConstPool()->Integers8.getConstantPool();
756 case IceType_i16: 766 case IceType_i16:
767 return getConstPool()->Integers16.getConstantPool();
757 case IceType_i32: 768 case IceType_i32:
758 return getConstPool()->Integers32.getConstantPool(); 769 return getConstPool()->Integers32.getConstantPool();
759 case IceType_i64: 770 case IceType_i64:
760 return getConstPool()->Integers64.getConstantPool(); 771 return getConstPool()->Integers64.getConstantPool();
761 case IceType_f32: 772 case IceType_f32:
762 return getConstPool()->Floats.getConstantPool(); 773 return getConstPool()->Floats.getConstantPool();
763 case IceType_f64: 774 case IceType_f64:
764 return getConstPool()->Doubles.getConstantPool(); 775 return getConstPool()->Doubles.getConstantPool();
765 case IceType_v4i1: 776 case IceType_v4i1:
766 case IceType_v8i1: 777 case IceType_v8i1:
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 Ctx = Func->getContext(); 903 Ctx = Func->getContext();
893 Active = 904 Active =
894 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); 905 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled();
895 if (Active) 906 if (Active)
896 Ctx->pushTimer(ID, StackID); 907 Ctx->pushTimer(ID, StackID);
897 } 908 }
898 909
899 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); 910 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS);
900 911
901 } // end of namespace Ice 912 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceInstX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698