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 /// \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 "IceDefs.h" | 21 #include "IceDefs.h" |
| 22 #include "IceELFObjectWriter.h" | 22 #include "IceELFObjectWriter.h" |
| 23 #include "IceGlobalInits.h" | 23 #include "IceGlobalInits.h" |
| 24 #include "IceLiveness.h" | 24 #include "IceLiveness.h" |
| 25 #include "IceOperand.h" | 25 #include "IceOperand.h" |
| 26 #include "IceRevision.h" | |
| 26 #include "IceTargetLowering.h" | 27 #include "IceTargetLowering.h" |
| 27 #include "IceTimerTree.h" | 28 #include "IceTimerTree.h" |
| 28 #include "IceTypes.def" | 29 #include "IceTypes.def" |
| 29 #include "IceTypes.h" | 30 #include "IceTypes.h" |
| 30 | 31 |
| 31 #ifdef __clang__ | 32 #ifdef __clang__ |
| 32 #pragma clang diagnostic push | 33 #pragma clang diagnostic push |
| 33 #pragma clang diagnostic ignored "-Wunused-parameter" | 34 #pragma clang diagnostic ignored "-Wunused-parameter" |
| 34 #endif // __clang__ | 35 #endif // __clang__ |
| 35 | 36 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 void GlobalContext::lowerJumpTables() { DataLowering->lowerJumpTables(); } | 460 void GlobalContext::lowerJumpTables() { DataLowering->lowerJumpTables(); } |
| 460 | 461 |
| 461 void GlobalContext::saveBlockInfoPtrs() { | 462 void GlobalContext::saveBlockInfoPtrs() { |
| 462 for (VariableDeclaration *Global : Globals) { | 463 for (VariableDeclaration *Global : Globals) { |
| 463 if (Cfg::isProfileGlobal(*Global)) { | 464 if (Cfg::isProfileGlobal(*Global)) { |
| 464 ProfileBlockInfos.push_back(Global); | 465 ProfileBlockInfos.push_back(Global); |
| 465 } | 466 } |
| 466 } | 467 } |
| 467 } | 468 } |
| 468 | 469 |
| 470 void GlobalContext::lowerGlobalsIfNoCodeHasBeenSeen() { | |
| 471 if (HasSeenCode) | |
| 472 return; | |
| 473 | |
| 474 if (getFlags().getEmitRevision()) { | |
|
John
2016/08/08 11:47:28
This method is supposed to emit globals, but it al
Jim Stichnoth
2016/08/08 14:46:18
A side effect of lowering globals is that Globals
John
2016/08/08 14:55:36
Or maybe just add the global in the GlobalContext'
Jim Stichnoth
2016/08/08 17:48:09
Brilliant! Done.
| |
| 475 // Embed the Subzero revision into the compiled binary by creating a special | |
| 476 // global variable initialized with the revision string. | |
| 477 auto *Revision = VariableDeclaration::create(&Globals, true); | |
| 478 Revision->setName(this, "__Sz_revision"); | |
| 479 Revision->setIsConstant(true); | |
| 480 const char *RevisionString = getSubzeroRevision(); | |
| 481 Revision->addInitializer(VariableDeclaration::DataInitializer::create( | |
| 482 &Globals, RevisionString, 1 + strlen(RevisionString))); | |
| 483 Globals.push_back(Revision); | |
| 484 } | |
| 485 | |
| 486 constexpr char NoSuffix[] = ""; | |
| 487 lowerGlobals(NoSuffix); | |
| 488 HasSeenCode = true; | |
| 489 } | |
| 490 | |
| 469 void GlobalContext::lowerGlobals(const std::string &SectionSuffix) { | 491 void GlobalContext::lowerGlobals(const std::string &SectionSuffix) { |
| 470 TimerMarker T(TimerStack::TT_emitGlobalInitializers, this); | 492 TimerMarker T(TimerStack::TT_emitGlobalInitializers, this); |
| 471 const bool DumpGlobalVariables = | 493 const bool DumpGlobalVariables = |
| 472 BuildDefs::dump() && (getFlags().getVerbose() & IceV_GlobalInit) && | 494 BuildDefs::dump() && (getFlags().getVerbose() & IceV_GlobalInit) && |
| 473 getFlags().matchVerboseFocusOn("", 0); | 495 getFlags().matchVerboseFocusOn("", 0); |
| 474 if (DumpGlobalVariables) { | 496 if (DumpGlobalVariables) { |
| 475 OstreamLocker L(this); | 497 OstreamLocker L(this); |
| 476 Ostream &Stream = getStrDump(); | 498 Ostream &Stream = getStrDump(); |
| 477 for (const Ice::VariableDeclaration *Global : Globals) { | 499 for (const Ice::VariableDeclaration *Global : Globals) { |
| 478 Global->dump(Stream); | 500 Global->dump(Stream); |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1041 void TimerMarker::pushCfg(const Cfg *Func) { | 1063 void TimerMarker::pushCfg(const Cfg *Func) { |
| 1042 Ctx = Func->getContext(); | 1064 Ctx = Func->getContext(); |
| 1043 Active = Func->getFocusedTiming() || getFlags().getSubzeroTimingEnabled(); | 1065 Active = Func->getFocusedTiming() || getFlags().getSubzeroTimingEnabled(); |
| 1044 if (Active) | 1066 if (Active) |
| 1045 Ctx->pushTimer(ID, StackID); | 1067 Ctx->pushTimer(ID, StackID); |
| 1046 } | 1068 } |
| 1047 | 1069 |
| 1048 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 1070 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
| 1049 | 1071 |
| 1050 } // end of namespace Ice | 1072 } // end of namespace Ice |
| OLD | NEW |