Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/llvm2ice.cpp - Driver for testing ----------------------===// | 1 //===- subzero/src/llvm2ice.cpp - Driver for testing ----------------------===// |
| 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 // This file defines a driver that uses LLVM capabilities to parse a | 10 // This file defines a driver that uses LLVM capabilities to parse a |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 static cl::opt<bool> AlwaysExitSuccess( | 196 static cl::opt<bool> AlwaysExitSuccess( |
| 197 "exit-success", cl::desc("Exit with success status, even if errors found"), | 197 "exit-success", cl::desc("Exit with success status, even if errors found"), |
| 198 cl::init(false)); | 198 cl::init(false)); |
| 199 | 199 |
| 200 static cl::opt<bool> | 200 static cl::opt<bool> |
| 201 GenerateBuildAtts("build-atts", | 201 GenerateBuildAtts("build-atts", |
| 202 cl::desc("Generate list of build attributes associated with " | 202 cl::desc("Generate list of build attributes associated with " |
| 203 "this executable."), | 203 "this executable."), |
| 204 cl::init(false)); | 204 cl::init(false)); |
| 205 | 205 |
| 206 static cl::opt<uint32_t> | |
| 207 NumThreads("threads", | |
| 208 cl::desc("Number of translation threads (0 for purely sequential)"), | |
| 209 cl::init(0)); | |
|
JF
2015/01/22 20:50:56
This should default to std::thread::hardware_concu
Jim Stichnoth
2015/01/23 07:55:55
Well, 1 isn't exactly sequential, as there would b
| |
| 210 static cl::alias SplitModule("split-module", cl::desc("Alias for -threads"), | |
|
Karl
2015/01/22 20:41:13
Not sure this can be an alias. Single threaded for
JF
2015/01/22 20:50:56
Why add the alias at all?
Jim Stichnoth
2015/01/23 07:55:55
The idea was to make it easier to plumb llvm2ice a
| |
| 211 cl::NotHidden, cl::aliasopt(NumThreads)); | |
| 212 | |
| 206 static int GetReturnValue(int Val) { | 213 static int GetReturnValue(int Val) { |
| 207 if (AlwaysExitSuccess) | 214 if (AlwaysExitSuccess) |
| 208 return 0; | 215 return 0; |
| 209 return Val; | 216 return Val; |
| 210 } | 217 } |
| 211 | 218 |
| 212 static struct { | 219 static struct { |
| 213 const char *FlagName; | 220 const char *FlagName; |
| 214 int FlagValue; | 221 int FlagValue; |
| 215 } ConditionalBuildAttributes[] = {{"dump", ALLOW_DUMP}, | 222 } ConditionalBuildAttributes[] = {{"dump", ALLOW_DUMP}, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 << "ALLOW_DISABLE_IR_GEN!\n"; | 288 << "ALLOW_DISABLE_IR_GEN!\n"; |
| 282 return GetReturnValue(1); | 289 return GetReturnValue(1); |
| 283 } | 290 } |
| 284 | 291 |
| 285 Ice::ClFlags Flags; | 292 Ice::ClFlags Flags; |
| 286 Flags.DisableInternal = DisableInternal; | 293 Flags.DisableInternal = DisableInternal; |
| 287 Flags.SubzeroTimingEnabled = SubzeroTimingEnabled; | 294 Flags.SubzeroTimingEnabled = SubzeroTimingEnabled; |
| 288 Flags.DisableTranslation = DisableTranslation; | 295 Flags.DisableTranslation = DisableTranslation; |
| 289 Flags.FunctionSections = FunctionSections; | 296 Flags.FunctionSections = FunctionSections; |
| 290 Flags.DataSections = DataSections; | 297 Flags.DataSections = DataSections; |
| 298 Flags.UseELFWriter = UseELFWriter; | |
| 291 Flags.UseIntegratedAssembler = UseIntegratedAssembler; | 299 Flags.UseIntegratedAssembler = UseIntegratedAssembler; |
| 292 Flags.UseELFWriter = UseELFWriter; | |
| 293 Flags.UseSandboxing = UseSandboxing; | 300 Flags.UseSandboxing = UseSandboxing; |
| 294 Flags.PhiEdgeSplit = EnablePhiEdgeSplit; | 301 Flags.PhiEdgeSplit = EnablePhiEdgeSplit; |
| 295 Flags.DecorateAsm = DecorateAsm; | 302 Flags.DecorateAsm = DecorateAsm; |
| 296 Flags.DumpStats = DumpStats; | 303 Flags.DumpStats = DumpStats; |
| 297 Flags.AllowUninitializedGlobals = AllowUninitializedGlobals; | 304 Flags.AllowUninitializedGlobals = AllowUninitializedGlobals; |
| 298 Flags.TimeEachFunction = TimeEachFunction; | 305 Flags.TimeEachFunction = TimeEachFunction; |
| 306 Flags.NumTranslationThreads = NumThreads; | |
| 299 Flags.DefaultGlobalPrefix = DefaultGlobalPrefix; | 307 Flags.DefaultGlobalPrefix = DefaultGlobalPrefix; |
| 300 Flags.DefaultFunctionPrefix = DefaultFunctionPrefix; | 308 Flags.DefaultFunctionPrefix = DefaultFunctionPrefix; |
| 301 Flags.TimingFocusOn = TimingFocusOn; | 309 Flags.TimingFocusOn = TimingFocusOn; |
| 302 Flags.VerboseFocusOn = VerboseFocusOn; | 310 Flags.VerboseFocusOn = VerboseFocusOn; |
| 303 Flags.TranslateOnly = TranslateOnly; | 311 Flags.TranslateOnly = TranslateOnly; |
| 304 Flags.DisableIRGeneration = DisableIRGeneration; | 312 Flags.DisableIRGeneration = DisableIRGeneration; |
| 305 Flags.AllowErrorRecovery = AllowErrorRecovery; | 313 Flags.AllowErrorRecovery = AllowErrorRecovery; |
| 306 | 314 |
| 307 // Force -build-on-read=0 for .ll files. | 315 // Force -build-on-read=0 for .ll files. |
| 308 const std::string LLSuffix = ".ll"; | 316 const std::string LLSuffix = ".ll"; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 Ice::GlobalContext Ctx(Ls.get(), Os.get(), ELFStr.get(), VMask, TargetArch, | 352 Ice::GlobalContext Ctx(Ls.get(), Os.get(), ELFStr.get(), VMask, TargetArch, |
| 345 OptLevel, TestPrefix, Flags); | 353 OptLevel, TestPrefix, Flags); |
| 346 | 354 |
| 347 Ice::TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx); | 355 Ice::TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx); |
| 348 | 356 |
| 349 if (UseELFWriter) { | 357 if (UseELFWriter) { |
| 350 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); | 358 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); |
| 351 Ctx.getObjectWriter()->writeInitialELFHeader(); | 359 Ctx.getObjectWriter()->writeInitialELFHeader(); |
| 352 } | 360 } |
| 353 | 361 |
| 362 Ctx.startWorkerThreads(); | |
| 363 | |
| 354 int ErrorStatus = 0; | 364 int ErrorStatus = 0; |
|
JF
2015/01/22 20:50:56
This should also be an std::vector<std::error_code
Jim Stichnoth
2015/01/23 07:55:55
Changed to std::error_code.
| |
| 355 if (BuildOnRead) { | 365 if (BuildOnRead) { |
| 356 Ice::PNaClTranslator Translator(&Ctx, Flags); | 366 Ice::PNaClTranslator Translator(&Ctx, Flags); |
| 357 Translator.translate(IRFilename); | 367 Translator.translate(IRFilename); |
| 358 ErrorStatus = Translator.getErrorStatus(); | 368 ErrorStatus = Translator.getErrorStatus(); |
| 359 } else if (ALLOW_LLVM_IR) { | 369 } else if (ALLOW_LLVM_IR) { |
| 360 // Parse the input LLVM IR file into a module. | 370 // Parse the input LLVM IR file into a module. |
| 361 SMDiagnostic Err; | 371 SMDiagnostic Err; |
| 362 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); | 372 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); |
| 363 raw_ostream *Verbose = LLVMVerboseErrors ? &errs() : nullptr; | 373 raw_ostream *Verbose = LLVMVerboseErrors ? &errs() : nullptr; |
| 364 Module *Mod = | 374 Module *Mod = |
| 365 NaClParseIRFile(IRFilename, InputFileFormat, Err, Verbose, | 375 NaClParseIRFile(IRFilename, InputFileFormat, Err, Verbose, |
| 366 getGlobalContext()); | 376 getGlobalContext()); |
| 367 | 377 |
| 368 if (!Mod) { | 378 if (!Mod) { |
| 369 Err.print(argv[0], errs()); | 379 Err.print(argv[0], errs()); |
| 370 return GetReturnValue(1); | 380 return GetReturnValue(1); |
| 371 } | 381 } |
| 372 | 382 |
| 373 Ice::Converter Converter(Mod, &Ctx, Flags); | 383 Ice::Converter Converter(Mod, &Ctx, Flags); |
| 374 Converter.convertToIce(); | 384 Converter.convertToIce(); |
| 375 ErrorStatus = Converter.getErrorStatus(); | 385 ErrorStatus = Converter.getErrorStatus(); |
| 376 } else { | 386 } else { |
| 377 *Ls << "Error: Build doesn't allow LLVM IR, " | 387 *Ls << "Error: Build doesn't allow LLVM IR, " |
| 378 << "--build-on-read=0 not allowed\n"; | 388 << "--build-on-read=0 not allowed\n"; |
| 379 return GetReturnValue(1); | 389 return GetReturnValue(1); |
| 380 } | 390 } |
| 391 // Error status is the combination of the bitcode parser's error | |
| 392 // status and the translation error status. | |
| 393 ErrorStatus |= Ctx.getErrorStatus(); | |
| 394 | |
| 381 if (UseELFWriter) { | 395 if (UseELFWriter) { |
| 382 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); | 396 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); |
| 383 Ctx.getObjectWriter()->writeNonUserSections(); | 397 Ctx.getObjectWriter()->writeNonUserSections(); |
| 384 } | 398 } |
| 385 if (SubzeroTimingEnabled) | 399 if (SubzeroTimingEnabled) |
| 386 Ctx.dumpTimers(); | 400 Ctx.dumpTimers(); |
| 387 if (TimeEachFunction) { | 401 if (TimeEachFunction) { |
| 388 const bool DumpCumulative = false; | 402 const bool DumpCumulative = false; |
| 389 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); | 403 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); |
| 390 } | 404 } |
| 391 const bool FinalStats = true; | 405 const bool FinalStats = true; |
| 392 Ctx.dumpStats("_FINAL_", FinalStats); | 406 Ctx.dumpStats("_FINAL_", FinalStats); |
| 393 return GetReturnValue(ErrorStatus); | 407 return GetReturnValue(ErrorStatus); |
| 394 } | 408 } |
| OLD | NEW |