| Index: src/IceGlobalContext.cpp
|
| diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
|
| index 9e1b72c9f47486f1b34e47066b69570d4c1e2f93..3a9d4d707d7671ec8550f9b0f4c7ecd64b9ec40c 100644
|
| --- a/src/IceGlobalContext.cpp
|
| +++ b/src/IceGlobalContext.cpp
|
| @@ -129,9 +129,11 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit,
|
| ELFStreamer *ELFStr, VerboseMask Mask,
|
| TargetArch Arch, OptLevel Opt,
|
| IceString TestPrefix, const ClFlags &Flags)
|
| - : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask),
|
| - ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt),
|
| - TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter() {
|
| + : ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump),
|
| + StrEmit(OsEmit), VMask(Mask), Arch(Arch), Opt(Opt),
|
| + TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter(),
|
| + CfgQ(/*MaxSize=*/Flags.NumTranslationThreads,
|
| + /*Sequential=*/(Flags.NumTranslationThreads == 0)) {
|
| // Create a new ThreadContext for the current thread. No need to
|
| // lock AllThreadContexts at this point since no other threads have
|
| // access yet to this GlobalContext object.
|
| @@ -149,6 +151,43 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit,
|
| }
|
| }
|
|
|
| +void GlobalContext::translateFunctions() {
|
| + while (Cfg *Func = cfgQueueGet()) {
|
| + // Reset per-function stats being accumulated in TLS.
|
| + resetStats();
|
| + // Install Func in TLS for Cfg-specific container allocators.
|
| + Func->updateTLS();
|
| + // Set verbose level to none if the current function does NOT
|
| + // match the -verbose-focus command-line option.
|
| + if (!matchSymbolName(Func->getFunctionName(), getFlags().VerboseFocusOn))
|
| + Func->setVerbose(IceV_None);
|
| + // Disable translation if -notranslate is specified, or if the
|
| + // current function matches the -translate-only option. If
|
| + // translation is disabled, just dump the high-level IR and
|
| + // continue.
|
| + if (getFlags().DisableTranslation ||
|
| + !matchSymbolName(Func->getFunctionName(), getFlags().TranslateOnly)) {
|
| + Func->dump();
|
| + } else {
|
| + Func->translate();
|
| + if (Func->hasError()) {
|
| + getErrorStatus()->assign(1, std::generic_category());
|
| + OstreamLocker L(this);
|
| + getStrDump() << "ICE translation error: " << Func->getError() << "\n";
|
| + } else {
|
| + if (getFlags().UseIntegratedAssembler)
|
| + Func->emitIAS();
|
| + else
|
| + Func->emit();
|
| + // TODO(stichnot): actually add to emit queue
|
| + }
|
| + // TODO(stichnot): fix multithreaded stats dumping.
|
| + dumpStats(Func->getFunctionName());
|
| + }
|
| + delete Func;
|
| + }
|
| +}
|
| +
|
| // Scan a string for S[0-9A-Z]*_ patterns and replace them with
|
| // S<num>_ where <num> is the next base-36 value. If a type name
|
| // legitimately contains that pattern, then the substitution will be
|
| @@ -464,12 +503,18 @@ TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID,
|
| }
|
|
|
| void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) {
|
| + // TODO(stichnot): Timers are completely broken for multithreading; fix.
|
| + if (getFlags().NumTranslationThreads)
|
| + llvm::report_fatal_error("Timers and multithreading are currently broken");
|
| auto Timers = getTimers();
|
| assert(StackID < Timers->size());
|
| Timers->at(StackID).push(ID);
|
| }
|
|
|
| void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) {
|
| + // TODO(stichnot): Timers are completely broken for multithreading; fix.
|
| + if (getFlags().NumTranslationThreads)
|
| + llvm::report_fatal_error("Timers and multithreading are currently broken");
|
| auto Timers = getTimers();
|
| assert(StackID < Timers->size());
|
| Timers->at(StackID).pop(ID);
|
|
|