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

Side by Side Diff: src/PNaClTranslator.cpp

Issue 1784243006: Subzero: Improve the use of timers. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 9 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/IceTimerTree.def ('k') | no next file » | 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/PNaClTranslator.cpp - ICE from bitcode -----------------===// 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===//
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 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 public: 1332 public:
1333 FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) 1333 FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
1334 : BlockParserBaseClass(BlockID, EnclosingParser), 1334 : BlockParserBaseClass(BlockID, EnclosingParser),
1335 Timer(Ice::TimerStack::TT_parseFunctions, getTranslator().getContext()), 1335 Timer(Ice::TimerStack::TT_parseFunctions, getTranslator().getContext()),
1336 Func(nullptr), FcnId(Context->getNextFunctionBlockValueID()), 1336 Func(nullptr), FcnId(Context->getNextFunctionBlockValueID()),
1337 FuncDecl(Context->getFunctionByID(FcnId)), 1337 FuncDecl(Context->getFunctionByID(FcnId)),
1338 CachedNumGlobalValueIDs(Context->getNumGlobalIDs()), 1338 CachedNumGlobalValueIDs(Context->getNumGlobalIDs()),
1339 NextLocalInstIndex(Context->getNumGlobalIDs()) {} 1339 NextLocalInstIndex(Context->getNumGlobalIDs()) {}
1340 1340
1341 bool convertFunction() { 1341 bool convertFunction() {
1342 const Ice::TimerStackIdT StackID = Ice::GlobalContext::TSK_Funcs;
1343 Ice::TimerIdT TimerID = 0;
1344 const bool TimeThisFunction = getFlags().getTimeEachFunction();
1345 if (TimeThisFunction) {
1346 TimerID = getTranslator().getContext()->getTimerID(StackID,
1347 FuncDecl->getName());
1348 getTranslator().getContext()->pushTimer(TimerID, StackID);
1349 }
1350
1351 // Note: The Cfg is created, even when IR generation is disabled. This is
1352 // done to install a CfgLocalAllocator for various internal containers.
1353 Func = Ice::Cfg::create(getTranslator().getContext(),
1354 getTranslator().getNextSequenceNumber());
1355 bool ParserResult; 1342 bool ParserResult;
1356 { 1343 {
1344 Ice::TimerMarker T(getTranslator().getContext(), FuncDecl->getName());
1345 // Note: The Cfg is created, even when IR generation is disabled. This is
1346 // done to install a CfgLocalAllocator for various internal containers.
1347 Func = Ice::Cfg::create(getTranslator().getContext(),
1348 getTranslator().getNextSequenceNumber());
1349
1357 Ice::CfgLocalAllocatorScope _(Func.get()); 1350 Ice::CfgLocalAllocatorScope _(Func.get());
1358 1351
1359 // TODO(kschimpf) Clean up API to add a function signature to a CFG. 1352 // TODO(kschimpf) Clean up API to add a function signature to a CFG.
1360 const Ice::FuncSigType &Signature = FuncDecl->getSignature(); 1353 const Ice::FuncSigType &Signature = FuncDecl->getSignature();
1361 1354
1362 Func->setFunctionName(FuncDecl->getName()); 1355 Func->setFunctionName(FuncDecl->getName());
1363 Func->setReturnType(Signature.getReturnType()); 1356 Func->setReturnType(Signature.getReturnType());
1364 Func->setInternal(FuncDecl->getLinkage() == GlobalValue::InternalLinkage); 1357 Func->setInternal(FuncDecl->getLinkage() == GlobalValue::InternalLinkage);
1365 CurrentNode = installNextBasicBlock(); 1358 CurrentNode = installNextBasicBlock();
1366 Func->setEntryNode(CurrentNode); 1359 Func->setEntryNode(CurrentNode);
1367 for (Ice::Type ArgType : Signature.getArgList()) { 1360 for (Ice::Type ArgType : Signature.getArgList()) {
1368 Func->addArg(getNextInstVar(ArgType)); 1361 Func->addArg(getNextInstVar(ArgType));
1369 } 1362 }
1370 1363
1371 ParserResult = ParseThisBlock(); 1364 ParserResult = ParseThisBlock();
1372 1365
1373 // Temporarily end per-function timing, which will be resumed by the
1374 // translator function. This is because translation may be done
1375 // asynchronously in a separate thread.
1376 if (TimeThisFunction)
1377 getTranslator().getContext()->popTimer(TimerID, StackID);
1378
1379 // Note: Once any errors have been found, we turn off all translation of 1366 // Note: Once any errors have been found, we turn off all translation of
1380 // all remaining functions. This allows successive parsing errors to be 1367 // all remaining functions. This allows successive parsing errors to be
1381 // reported, without adding extra checks to the translator for such 1368 // reported, without adding extra checks to the translator for such
1382 // parsing errors. 1369 // parsing errors.
1383 } 1370 }
1384 if (Context->getNumErrors() == 0 && Func) { 1371 if (Context->getNumErrors() == 0 && Func) {
1385 getTranslator().translateFcn(std::move(Func)); 1372 getTranslator().translateFcn(std::move(Func));
1386 // The translator now has ownership of Func. 1373 // The translator now has ownership of Func.
1387 } else { 1374 } else {
1388 Func.reset(); 1375 Func.reset();
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after
3211 raw_string_ostream StrBuf(Buffer); 3198 raw_string_ostream StrBuf(Buffer);
3212 StrBuf << IRFilename << ": Does not contain a module!"; 3199 StrBuf << IRFilename << ": Does not contain a module!";
3213 llvm::report_fatal_error(StrBuf.str()); 3200 llvm::report_fatal_error(StrBuf.str());
3214 } 3201 }
3215 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { 3202 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) {
3216 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); 3203 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes");
3217 } 3204 }
3218 } 3205 }
3219 3206
3220 } // end of namespace Ice 3207 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTimerTree.def ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698