| 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 |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 360 } |
| 361 | 361 |
| 362 void GlobalContext::translateFunctions() { | 362 void GlobalContext::translateFunctions() { |
| 363 TimerMarker Timer(TimerStack::TT_translateFunctions, this); | 363 TimerMarker Timer(TimerStack::TT_translateFunctions, this); |
| 364 while (std::unique_ptr<OptWorkItem> OptItem = optQueueBlockingPop()) { | 364 while (std::unique_ptr<OptWorkItem> OptItem = optQueueBlockingPop()) { |
| 365 auto Func = OptItem->getParsedCfg(); | 365 auto Func = OptItem->getParsedCfg(); |
| 366 // Install Func in TLS for Cfg-specific container allocators. | 366 // Install Func in TLS for Cfg-specific container allocators. |
| 367 CfgLocalAllocatorScope _(Func.get()); | 367 CfgLocalAllocatorScope _(Func.get()); |
| 368 // Reset per-function stats being accumulated in TLS. | 368 // Reset per-function stats being accumulated in TLS. |
| 369 resetStats(); | 369 resetStats(); |
| 370 // Set verbose level to none if the current function does NOT | 370 // Set verbose level to none if the current function does NOT match the |
| 371 // match the -verbose-focus command-line option. | 371 // -verbose-focus command-line option. |
| 372 if (!matchSymbolName(Func->getFunctionName(), | 372 if (!getFlags().matchVerboseFocusOn(Func->getFunctionName(), |
| 373 getFlags().getVerboseFocusOn())) | 373 Func->getSequenceNumber())) |
| 374 Func->setVerbose(IceV_None); | 374 Func->setVerbose(IceV_None); |
| 375 // Disable translation if -notranslate is specified, or if the | 375 // Disable translation if -notranslate is specified, or if the current |
| 376 // current function matches the -translate-only option. If | 376 // function matches the -translate-only option. If translation is disabled, |
| 377 // translation is disabled, just dump the high-level IR and | 377 // just dump the high-level IR and continue. |
| 378 // continue. | |
| 379 if (getFlags().getDisableTranslation() || | 378 if (getFlags().getDisableTranslation() || |
| 380 !matchSymbolName(Func->getFunctionName(), | 379 !getFlags().matchTranslateOnly(Func->getFunctionName(), |
| 381 getFlags().getTranslateOnly())) { | 380 Func->getSequenceNumber())) { |
| 382 Func->dump(); | 381 Func->dump(); |
| 383 continue; // Func goes out of scope and gets deleted | 382 continue; // Func goes out of scope and gets deleted |
| 384 } | 383 } |
| 385 | 384 |
| 386 Func->translate(); | 385 Func->translate(); |
| 387 std::unique_ptr<EmitterWorkItem> Item; | 386 std::unique_ptr<EmitterWorkItem> Item; |
| 388 if (Func->hasError()) { | 387 if (Func->hasError()) { |
| 389 getErrorStatus()->assign(EC_Translation); | 388 getErrorStatus()->assign(EC_Translation); |
| 390 OstreamLocker L(this); | 389 OstreamLocker L(this); |
| 391 getStrError() << "ICE translation error: " << Func->getFunctionName() | 390 getStrError() << "ICE translation error: " << Func->getFunctionName() |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 if (Cfg::isProfileGlobal(*Global)) { | 459 if (Cfg::isProfileGlobal(*Global)) { |
| 461 ProfileBlockInfos.push_back(Global); | 460 ProfileBlockInfos.push_back(Global); |
| 462 } | 461 } |
| 463 } | 462 } |
| 464 } | 463 } |
| 465 | 464 |
| 466 void GlobalContext::lowerGlobals(const std::string &SectionSuffix) { | 465 void GlobalContext::lowerGlobals(const std::string &SectionSuffix) { |
| 467 TimerMarker T(TimerStack::TT_emitGlobalInitializers, this); | 466 TimerMarker T(TimerStack::TT_emitGlobalInitializers, this); |
| 468 const bool DumpGlobalVariables = | 467 const bool DumpGlobalVariables = |
| 469 BuildDefs::dump() && (getFlags().getVerbose() & IceV_GlobalInit) && | 468 BuildDefs::dump() && (getFlags().getVerbose() & IceV_GlobalInit) && |
| 470 getFlags().getVerboseFocusOn().empty(); | 469 getFlags().matchVerboseFocusOn("", 0); |
| 471 if (DumpGlobalVariables) { | 470 if (DumpGlobalVariables) { |
| 472 OstreamLocker L(this); | 471 OstreamLocker L(this); |
| 473 Ostream &Stream = getStrDump(); | 472 Ostream &Stream = getStrDump(); |
| 474 for (const Ice::VariableDeclaration *Global : Globals) { | 473 for (const Ice::VariableDeclaration *Global : Globals) { |
| 475 Global->dump(Stream); | 474 Global->dump(Stream); |
| 476 } | 475 } |
| 477 } | 476 } |
| 478 if (getFlags().getDisableTranslation()) | 477 if (getFlags().getDisableTranslation()) |
| 479 return; | 478 return; |
| 480 | 479 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 // architectures this will waste 4 bytes. | 524 // architectures this will waste 4 bytes. |
| 526 const SizeT Sizeof64BitNullPtr = typeWidthInBytes(IceType_i64); | 525 const SizeT Sizeof64BitNullPtr = typeWidthInBytes(IceType_i64); |
| 527 ProfileBlockInfoVarDecl->addInitializer( | 526 ProfileBlockInfoVarDecl->addInitializer( |
| 528 VariableDeclaration::ZeroInitializer::create(GlobalVariablePool.get(), | 527 VariableDeclaration::ZeroInitializer::create(GlobalVariablePool.get(), |
| 529 Sizeof64BitNullPtr)); | 528 Sizeof64BitNullPtr)); |
| 530 Globals.push_back(ProfileBlockInfoVarDecl); | 529 Globals.push_back(ProfileBlockInfoVarDecl); |
| 531 constexpr char ProfileDataSection[] = "$sz_profiler$"; | 530 constexpr char ProfileDataSection[] = "$sz_profiler$"; |
| 532 lowerGlobals(ProfileDataSection); | 531 lowerGlobals(ProfileDataSection); |
| 533 } | 532 } |
| 534 | 533 |
| 535 bool GlobalContext::matchSymbolName(const GlobalString &SymbolName, | |
| 536 const std::string &Match) { | |
| 537 return Match.empty() || Match == SymbolName.toString(); | |
| 538 } | |
| 539 | |
| 540 void GlobalContext::emitItems() { | 534 void GlobalContext::emitItems() { |
| 541 const bool Threaded = !getFlags().isSequential(); | 535 const bool Threaded = !getFlags().isSequential(); |
| 542 // Pending is a vector containing the reassembled, ordered list of | 536 // Pending is a vector containing the reassembled, ordered list of |
| 543 // work items. When we're ready for the next item, we first check | 537 // work items. When we're ready for the next item, we first check |
| 544 // whether it's in the Pending list. If not, we take an item from | 538 // whether it's in the Pending list. If not, we take an item from |
| 545 // the work queue, and if it's not the item we're waiting for, we | 539 // the work queue, and if it's not the item we're waiting for, we |
| 546 // insert it into Pending and repeat. The work item is deleted | 540 // insert it into Pending and repeat. The work item is deleted |
| 547 // after it is processed. | 541 // after it is processed. |
| 548 std::vector<std::unique_ptr<EmitterWorkItem>> Pending; | 542 std::vector<std::unique_ptr<EmitterWorkItem>> Pending; |
| 549 uint32_t DesiredSequenceNumber = getFirstSequenceNumber(); | 543 uint32_t DesiredSequenceNumber = getFirstSequenceNumber(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 OstreamLocker _(this); | 677 OstreamLocker _(this); |
| 684 Ostream &Str = getStrDump(); | 678 Ostream &Str = getStrDump(); |
| 685 Str << "GlobalContext strings:\n"; | 679 Str << "GlobalContext strings:\n"; |
| 686 getStrings()->dump(Str); | 680 getStrings()->dump(Str); |
| 687 } | 681 } |
| 688 | 682 |
| 689 void GlobalContext::dumpConstantLookupCounts() { | 683 void GlobalContext::dumpConstantLookupCounts() { |
| 690 if (!BuildDefs::dump()) | 684 if (!BuildDefs::dump()) |
| 691 return; | 685 return; |
| 692 const bool DumpCounts = (getFlags().getVerbose() & IceV_ConstPoolStats) && | 686 const bool DumpCounts = (getFlags().getVerbose() & IceV_ConstPoolStats) && |
| 693 getFlags().getVerboseFocusOn().empty(); | 687 getFlags().matchVerboseFocusOn("", 0); |
| 694 if (!DumpCounts) | 688 if (!DumpCounts) |
| 695 return; | 689 return; |
| 696 | 690 |
| 697 OstreamLocker _(this); | 691 OstreamLocker _(this); |
| 698 Ostream &Str = getStrDump(); | 692 Ostream &Str = getStrDump(); |
| 699 Str << "Constant pool use stats: count+value+type\n"; | 693 Str << "Constant pool use stats: count+value+type\n"; |
| 700 #define X(WhichPool) \ | 694 #define X(WhichPool) \ |
| 701 for (auto *C : getConstPool()->WhichPool.getConstantPool()) { \ | 695 for (auto *C : getConstPool()->WhichPool.getConstantPool()) { \ |
| 702 Str << C->getLookupCount() << " "; \ | 696 Str << C->getLookupCount() << " "; \ |
| 703 C->dump(Str); \ | 697 C->dump(Str); \ |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 return 0; | 1011 return 0; |
| 1018 if (!getFlags().getTimeEachFunction()) | 1012 if (!getFlags().getTimeEachFunction()) |
| 1019 return 0; | 1013 return 0; |
| 1020 return Ctx->getTimerID(GlobalContext::TSK_Funcs, FuncName); | 1014 return Ctx->getTimerID(GlobalContext::TSK_Funcs, FuncName); |
| 1021 } | 1015 } |
| 1022 | 1016 |
| 1023 void TimerMarker::push() { | 1017 void TimerMarker::push() { |
| 1024 switch (StackID) { | 1018 switch (StackID) { |
| 1025 case GlobalContext::TSK_Default: | 1019 case GlobalContext::TSK_Default: |
| 1026 Active = getFlags().getSubzeroTimingEnabled() || | 1020 Active = getFlags().getSubzeroTimingEnabled() || |
| 1027 !getFlags().getTimingFocusOn().empty(); | 1021 !getFlags().getTimingFocusOnString().empty(); |
| 1028 break; | 1022 break; |
| 1029 case GlobalContext::TSK_Funcs: | 1023 case GlobalContext::TSK_Funcs: |
| 1030 Active = getFlags().getTimeEachFunction(); | 1024 Active = getFlags().getTimeEachFunction(); |
| 1031 break; | 1025 break; |
| 1032 default: | 1026 default: |
| 1033 break; | 1027 break; |
| 1034 } | 1028 } |
| 1035 if (Active) | 1029 if (Active) |
| 1036 Ctx->pushTimer(ID, StackID); | 1030 Ctx->pushTimer(ID, StackID); |
| 1037 } | 1031 } |
| 1038 | 1032 |
| 1039 void TimerMarker::pushCfg(const Cfg *Func) { | 1033 void TimerMarker::pushCfg(const Cfg *Func) { |
| 1040 Ctx = Func->getContext(); | 1034 Ctx = Func->getContext(); |
| 1041 Active = Func->getFocusedTiming() || getFlags().getSubzeroTimingEnabled(); | 1035 Active = Func->getFocusedTiming() || getFlags().getSubzeroTimingEnabled(); |
| 1042 if (Active) | 1036 if (Active) |
| 1043 Ctx->pushTimer(ID, StackID); | 1037 Ctx->pushTimer(ID, StackID); |
| 1044 } | 1038 } |
| 1045 | 1039 |
| 1046 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 1040 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
| 1047 | 1041 |
| 1048 } // end of namespace Ice | 1042 } // end of namespace Ice |
| OLD | NEW |