| 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 /// \file | 10 /// \file |
| 11 /// \brief Defines aspects of the compilation that persist across multiple | 11 /// \brief Defines aspects of the compilation that persist across multiple |
| 12 /// functions. | 12 /// functions. |
| 13 /// | 13 /// |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #include "IceGlobalContext.h" | 16 #include "IceGlobalContext.h" |
| 17 | 17 |
| 18 #include "IceCfg.h" | 18 #include "IceCfg.h" |
| 19 #include "IceCfgNode.h" | 19 #include "IceCfgNode.h" |
| 20 #include "IceClFlags.h" | 20 #include "IceClFlags.h" |
| 21 #include "IceClFlagsExtra.h" | |
| 22 #include "IceDefs.h" | 21 #include "IceDefs.h" |
| 23 #include "IceELFObjectWriter.h" | 22 #include "IceELFObjectWriter.h" |
| 24 #include "IceGlobalInits.h" | 23 #include "IceGlobalInits.h" |
| 25 #include "IceOperand.h" | 24 #include "IceOperand.h" |
| 26 #include "IceTargetLowering.h" | 25 #include "IceTargetLowering.h" |
| 27 #include "IceTimerTree.h" | 26 #include "IceTimerTree.h" |
| 28 #include "IceTypes.def" | 27 #include "IceTypes.def" |
| 29 #include "IceTypes.h" | 28 #include "IceTypes.h" |
| 30 | 29 |
| 31 #ifdef __clang__ | 30 #ifdef __clang__ |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 Ostream &Stream = getStrDump(); | 419 Ostream &Stream = getStrDump(); |
| 421 for (const Ice::VariableDeclaration *Global : Globals) { | 420 for (const Ice::VariableDeclaration *Global : Globals) { |
| 422 Global->dump(Stream); | 421 Global->dump(Stream); |
| 423 } | 422 } |
| 424 } | 423 } |
| 425 if (Flags.getDisableTranslation()) | 424 if (Flags.getDisableTranslation()) |
| 426 return; | 425 return; |
| 427 | 426 |
| 428 saveBlockInfoPtrs(); | 427 saveBlockInfoPtrs(); |
| 429 // If we need to shuffle the layout of global variables, shuffle them now. | 428 // If we need to shuffle the layout of global variables, shuffle them now. |
| 430 if (getFlags().shouldReorderGlobalVariables()) { | 429 if (getFlags().getReorderGlobalVariables()) { |
| 431 // Create a random number generator for global variable reordering. | 430 // Create a random number generator for global variable reordering. |
| 432 RandomNumberGenerator RNG(getFlags().getRandomSeed(), | 431 RandomNumberGenerator RNG(getFlags().getRandomSeed(), |
| 433 RPE_GlobalVariableReordering); | 432 RPE_GlobalVariableReordering); |
| 434 RandomShuffle(Globals.begin(), Globals.end(), | 433 RandomShuffle(Globals.begin(), Globals.end(), |
| 435 [&RNG](int N) { return (uint32_t)RNG.next(N); }); | 434 [&RNG](int N) { return (uint32_t)RNG.next(N); }); |
| 436 } | 435 } |
| 437 DataLowering->lowerGlobals(Globals, SectionSuffix); | 436 DataLowering->lowerGlobals(Globals, SectionSuffix); |
| 438 if (ProfileBlockInfos.empty() && DisposeGlobalVariablesAfterLowering) { | 437 if (ProfileBlockInfos.empty() && DisposeGlobalVariablesAfterLowering) { |
| 439 Globals.clearAndPurge(); | 438 Globals.clearAndPurge(); |
| 440 } else { | 439 } else { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 // the work queue, and if it's not the item we're waiting for, we | 486 // the work queue, and if it's not the item we're waiting for, we |
| 488 // insert it into Pending and repeat. The work item is deleted | 487 // insert it into Pending and repeat. The work item is deleted |
| 489 // after it is processed. | 488 // after it is processed. |
| 490 std::vector<std::unique_ptr<EmitterWorkItem>> Pending; | 489 std::vector<std::unique_ptr<EmitterWorkItem>> Pending; |
| 491 uint32_t DesiredSequenceNumber = getFirstSequenceNumber(); | 490 uint32_t DesiredSequenceNumber = getFirstSequenceNumber(); |
| 492 uint32_t ShuffleStartIndex = DesiredSequenceNumber; | 491 uint32_t ShuffleStartIndex = DesiredSequenceNumber; |
| 493 uint32_t ShuffleEndIndex = DesiredSequenceNumber; | 492 uint32_t ShuffleEndIndex = DesiredSequenceNumber; |
| 494 bool EmitQueueEmpty = false; | 493 bool EmitQueueEmpty = false; |
| 495 const uint32_t ShuffleWindowSize = | 494 const uint32_t ShuffleWindowSize = |
| 496 std::max(1u, getFlags().getReorderFunctionsWindowSize()); | 495 std::max(1u, getFlags().getReorderFunctionsWindowSize()); |
| 497 bool Shuffle = Threaded && getFlags().shouldReorderFunctions(); | 496 bool Shuffle = Threaded && getFlags().getReorderFunctions(); |
| 498 // Create a random number generator for function reordering. | 497 // Create a random number generator for function reordering. |
| 499 RandomNumberGenerator RNG(getFlags().getRandomSeed(), RPE_FunctionReordering); | 498 RandomNumberGenerator RNG(getFlags().getRandomSeed(), RPE_FunctionReordering); |
| 500 | 499 |
| 501 while (!EmitQueueEmpty) { | 500 while (!EmitQueueEmpty) { |
| 502 resizePending(&Pending, DesiredSequenceNumber); | 501 resizePending(&Pending, DesiredSequenceNumber); |
| 503 // See if Pending contains DesiredSequenceNumber. | 502 // See if Pending contains DesiredSequenceNumber. |
| 504 if (Pending[DesiredSequenceNumber] == nullptr) { | 503 if (Pending[DesiredSequenceNumber] == nullptr) { |
| 505 // We need to fetch an EmitterWorkItem from the queue. | 504 // We need to fetch an EmitterWorkItem from the queue. |
| 506 auto RawItem = emitQueueBlockingPop(); | 505 auto RawItem = emitQueueBlockingPop(); |
| 507 if (RawItem == nullptr) { | 506 if (RawItem == nullptr) { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 JumpTableDataList JumpTables(*getJumpTableList()); | 793 JumpTableDataList JumpTables(*getJumpTableList()); |
| 795 // Make order deterministic by sorting into functions and then ID of the jump | 794 // Make order deterministic by sorting into functions and then ID of the jump |
| 796 // table within that function. | 795 // table within that function. |
| 797 std::sort(JumpTables.begin(), JumpTables.end(), | 796 std::sort(JumpTables.begin(), JumpTables.end(), |
| 798 [](const JumpTableData &A, const JumpTableData &B) { | 797 [](const JumpTableData &A, const JumpTableData &B) { |
| 799 if (A.getFunctionName() != B.getFunctionName()) | 798 if (A.getFunctionName() != B.getFunctionName()) |
| 800 return A.getFunctionName() < B.getFunctionName(); | 799 return A.getFunctionName() < B.getFunctionName(); |
| 801 return A.getId() < B.getId(); | 800 return A.getId() < B.getId(); |
| 802 }); | 801 }); |
| 803 | 802 |
| 804 if (getFlags().shouldReorderPooledConstants()) { | 803 if (getFlags().getReorderPooledConstants()) { |
| 805 // If reorder-pooled-constants option is set to true, we also shuffle the | 804 // If reorder-pooled-constants option is set to true, we also shuffle the |
| 806 // jump tables before emitting them. | 805 // jump tables before emitting them. |
| 807 | 806 |
| 808 // Create a random number generator for jump tables reordering, considering | 807 // Create a random number generator for jump tables reordering, considering |
| 809 // jump tables as pooled constants. | 808 // jump tables as pooled constants. |
| 810 RandomNumberGenerator RNG(getFlags().getRandomSeed(), | 809 RandomNumberGenerator RNG(getFlags().getRandomSeed(), |
| 811 RPE_PooledConstantReordering); | 810 RPE_PooledConstantReordering); |
| 812 RandomShuffle(JumpTables.begin(), JumpTables.end(), | 811 RandomShuffle(JumpTables.begin(), JumpTables.end(), |
| 813 [&RNG](uint64_t N) { return (uint32_t)RNG.next(N); }); | 812 [&RNG](uint64_t N) { return (uint32_t)RNG.next(N); }); |
| 814 } | 813 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { | 911 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { |
| 913 if (!BuildDefs::timers()) | 912 if (!BuildDefs::timers()) |
| 914 return; | 913 return; |
| 915 auto Timers = getTimers(); | 914 auto Timers = getTimers(); |
| 916 assert(Timers->size() > StackID); | 915 assert(Timers->size() > StackID); |
| 917 OstreamLocker L(this); | 916 OstreamLocker L(this); |
| 918 Timers->at(StackID).dump(getStrDump(), DumpCumulative); | 917 Timers->at(StackID).dump(getStrDump(), DumpCumulative); |
| 919 } | 918 } |
| 920 | 919 |
| 921 ClFlags GlobalContext::Flags; | 920 ClFlags GlobalContext::Flags; |
| 922 ClFlagsExtra GlobalContext::ExtraFlags; | |
| 923 | 921 |
| 924 TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx, | 922 TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx, |
| 925 const IceString &FuncName) { | 923 const IceString &FuncName) { |
| 926 if (!BuildDefs::timers()) | 924 if (!BuildDefs::timers()) |
| 927 return 0; | 925 return 0; |
| 928 if (!Ctx->getFlags().getTimeEachFunction()) | 926 if (!Ctx->getFlags().getTimeEachFunction()) |
| 929 return 0; | 927 return 0; |
| 930 return Ctx->getTimerID(GlobalContext::TSK_Funcs, FuncName); | 928 return Ctx->getTimerID(GlobalContext::TSK_Funcs, FuncName); |
| 931 } | 929 } |
| 932 | 930 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 949 Ctx = Func->getContext(); | 947 Ctx = Func->getContext(); |
| 950 Active = | 948 Active = |
| 951 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); | 949 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); |
| 952 if (Active) | 950 if (Active) |
| 953 Ctx->pushTimer(ID, StackID); | 951 Ctx->pushTimer(ID, StackID); |
| 954 } | 952 } |
| 955 | 953 |
| 956 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 954 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
| 957 | 955 |
| 958 } // end of namespace Ice | 956 } // end of namespace Ice |
| OLD | NEW |