Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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. | |
| 271 if (Flags.getRandomizeAndPoolImmediatesOption() != RPI_None) | |
|
qining
2015/06/20 23:32:37
Add this flag to avoid using RNG. This keeps the r
Jim Stichnoth
2015/06/21 00:05:27
Good, but please add a comment briefly explaining
qining
2015/06/21 00:30:47
Done.
| |
| 272 RandomizationCookie = | |
| 273 (uint32_t)RNG.next((uint64_t)std::numeric_limits<uint32_t>::max + 1); | |
| 268 } | 274 } |
| 269 | 275 |
| 270 void GlobalContext::translateFunctions() { | 276 void GlobalContext::translateFunctions() { |
| 271 while (std::unique_ptr<Cfg> Func = optQueueBlockingPop()) { | 277 while (std::unique_ptr<Cfg> Func = optQueueBlockingPop()) { |
| 272 // Install Func in TLS for Cfg-specific container allocators. | 278 // Install Func in TLS for Cfg-specific container allocators. |
| 273 Cfg::setCurrentCfg(Func.get()); | 279 Cfg::setCurrentCfg(Func.get()); |
| 274 // Reset per-function stats being accumulated in TLS. | 280 // Reset per-function stats being accumulated in TLS. |
| 275 resetStats(); | 281 resetStats(); |
| 276 // Set verbose level to none if the current function does NOT | 282 // Set verbose level to none if the current function does NOT |
| 277 // match the -verbose-focus command-line option. | 283 // match the -verbose-focus command-line option. |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 case IceType_NUM: | 752 case IceType_NUM: |
| 747 break; | 753 break; |
| 748 } | 754 } |
| 749 llvm_unreachable("Unknown type"); | 755 llvm_unreachable("Unknown type"); |
| 750 } | 756 } |
| 751 | 757 |
| 752 ConstantList GlobalContext::getConstantPool(Type Ty) { | 758 ConstantList GlobalContext::getConstantPool(Type Ty) { |
| 753 switch (Ty) { | 759 switch (Ty) { |
| 754 case IceType_i1: | 760 case IceType_i1: |
| 755 case IceType_i8: | 761 case IceType_i8: |
| 762 return getConstPool()->Integers8.getConstantPool(); | |
| 756 case IceType_i16: | 763 case IceType_i16: |
| 764 return getConstPool()->Integers16.getConstantPool(); | |
| 757 case IceType_i32: | 765 case IceType_i32: |
| 758 return getConstPool()->Integers32.getConstantPool(); | 766 return getConstPool()->Integers32.getConstantPool(); |
| 759 case IceType_i64: | 767 case IceType_i64: |
| 760 return getConstPool()->Integers64.getConstantPool(); | 768 return getConstPool()->Integers64.getConstantPool(); |
| 761 case IceType_f32: | 769 case IceType_f32: |
| 762 return getConstPool()->Floats.getConstantPool(); | 770 return getConstPool()->Floats.getConstantPool(); |
| 763 case IceType_f64: | 771 case IceType_f64: |
| 764 return getConstPool()->Doubles.getConstantPool(); | 772 return getConstPool()->Doubles.getConstantPool(); |
| 765 case IceType_v4i1: | 773 case IceType_v4i1: |
| 766 case IceType_v8i1: | 774 case IceType_v8i1: |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 892 Ctx = Func->getContext(); | 900 Ctx = Func->getContext(); |
| 893 Active = | 901 Active = |
| 894 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); | 902 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); |
| 895 if (Active) | 903 if (Active) |
| 896 Ctx->pushTimer(ID, StackID); | 904 Ctx->pushTimer(ID, StackID); |
| 897 } | 905 } |
| 898 | 906 |
| 899 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 907 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
| 900 | 908 |
| 901 } // end of namespace Ice | 909 } // end of namespace Ice |
| OLD | NEW |