1 //===-- cc1as_main.cpp - Clang Assembler  ---------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This is the entry point to the clang -cc1as functionality, which implements
11 // the direct interface to the LLVM MC based assembler.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "clang/Basic/Diagnostic.h"
16 #include "clang/Basic/DiagnosticOptions.h"
17 #include "clang/Driver/DriverDiagnostic.h"
18 #include "clang/Driver/Options.h"
19 #include "clang/Frontend/FrontendDiagnostic.h"
20 #include "clang/Frontend/TextDiagnosticPrinter.h"
21 #include "clang/Frontend/Utils.h"
22 #include "llvm/ADT/STLExtras.h"
23 #include "llvm/ADT/StringSwitch.h"
24 #include "llvm/ADT/Triple.h"
25 #include "llvm/IR/DataLayout.h"
26 #include "llvm/MC/MCAsmBackend.h"
27 #include "llvm/MC/MCAsmInfo.h"
28 #include "llvm/MC/MCCodeEmitter.h"
29 #include "llvm/MC/MCContext.h"
30 #include "llvm/MC/MCInstrInfo.h"
31 #include "llvm/MC/MCObjectFileInfo.h"
32 #include "llvm/MC/MCObjectWriter.h"
33 #include "llvm/MC/MCParser/MCAsmParser.h"
34 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
35 #include "llvm/MC/MCRegisterInfo.h"
36 #include "llvm/MC/MCStreamer.h"
37 #include "llvm/MC/MCSubtargetInfo.h"
38 #include "llvm/MC/MCTargetOptions.h"
39 #include "llvm/Option/Arg.h"
40 #include "llvm/Option/ArgList.h"
41 #include "llvm/Option/OptTable.h"
42 #include "llvm/Support/CommandLine.h"
43 #include "llvm/Support/ErrorHandling.h"
44 #include "llvm/Support/FileSystem.h"
45 #include "llvm/Support/FormattedStream.h"
46 #include "llvm/Support/Host.h"
47 #include "llvm/Support/MemoryBuffer.h"
48 #include "llvm/Support/Path.h"
49 #include "llvm/Support/Signals.h"
50 #include "llvm/Support/SourceMgr.h"
51 #include "llvm/Support/TargetRegistry.h"
52 #include "llvm/Support/TargetSelect.h"
53 #include "llvm/Support/Timer.h"
54 #include "llvm/Support/raw_ostream.h"
55 #include <memory>
56 #include <system_error>
57 using namespace clang;
58 using namespace clang::driver;
59 using namespace clang::driver::options;
60 using namespace llvm;
61 using namespace llvm::opt;
62 
63 namespace {
64 
65 /// Helper class for representing a single invocation of the assembler.
66 struct AssemblerInvocation {
67   /// @name Target Options
68   /// @{
69 
70   /// The name of the target triple to assemble for.
71   std::string Triple;
72 
73   /// If given, the name of the target CPU to determine which instructions
74   /// are legal.
75   std::string CPU;
76 
77   /// The list of target specific features to enable or disable -- this should
78   /// be a list of strings starting with '+' or '-'.
79   std::vector<std::string> Features;
80 
81   /// The list of symbol definitions.
82   std::vector<std::string> SymbolDefs;
83 
84   /// @}
85   /// @name Language Options
86   /// @{
87 
88   std::vector<std::string> IncludePaths;
89   unsigned NoInitialTextSection : 1;
90   unsigned SaveTemporaryLabels : 1;
91   unsigned GenDwarfForAssembly : 1;
92   unsigned RelaxELFRelocations : 1;
93   unsigned DwarfVersion;
94   std::string DwarfDebugFlags;
95   std::string DwarfDebugProducer;
96   std::string DebugCompilationDir;
97   std::map<const std::string, const std::string> DebugPrefixMap;
98   llvm::DebugCompressionType CompressDebugSections =
99       llvm::DebugCompressionType::None;
100   std::string MainFileName;
101   std::string SplitDwarfFile;
102 
103   /// @}
104   /// @name Frontend Options
105   /// @{
106 
107   std::string InputFile;
108   std::vector<std::string> LLVMArgs;
109   std::string OutputPath;
110   enum FileType {
111     FT_Asm,  ///< Assembly (.s) output, transliterate mode.
112     FT_Null, ///< No output, for timing purposes.
113     FT_Obj   ///< Object file output.
114   };
115   FileType OutputType;
116   unsigned ShowHelp : 1;
117   unsigned ShowVersion : 1;
118 
119   /// @}
120   /// @name Transliterate Options
121   /// @{
122 
123   unsigned OutputAsmVariant;
124   unsigned ShowEncoding : 1;
125   unsigned ShowInst : 1;
126 
127   /// @}
128   /// @name Assembler Options
129   /// @{
130 
131   unsigned RelaxAll : 1;
132   unsigned NoExecStack : 1;
133   unsigned FatalWarnings : 1;
134   unsigned IncrementalLinkerCompatible : 1;
135 
136   /// The name of the relocation model to use.
137   std::string RelocationModel;
138 
139   /// @}
140 
141 public:
142   AssemblerInvocation() {
143     Triple = "";
144     NoInitialTextSection = 0;
145     InputFile = "-";
146     OutputPath = "-";
147     OutputType = FT_Asm;
148     OutputAsmVariant = 0;
149     ShowInst = 0;
150     ShowEncoding = 0;
151     RelaxAll = 0;
152     NoExecStack = 0;
153     FatalWarnings = 0;
154     IncrementalLinkerCompatible = 0;
155     DwarfVersion = 0;
156   }
157 
158   static bool CreateFromArgs(AssemblerInvocation &Res,
159                              ArrayRef<const char *> Argv,
160                              DiagnosticsEngine &Diags);
161 };
162 
163 }
164 
165 bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
166                                          ArrayRef<const char *> Argv,
167                                          DiagnosticsEngine &Diags) {
168   bool Success = true;
169 
170   // Parse the arguments.
171   std::unique_ptr<OptTable> OptTbl(createDriverOptTable());
172 
173   const unsigned IncludedFlagsBitmask = options::CC1AsOption;
174   unsigned MissingArgIndex, MissingArgCount;
175   InputArgList Args = OptTbl->ParseArgs(Argv, MissingArgIndex, MissingArgCount,
176                                         IncludedFlagsBitmask);
177 
178   // Check for missing argument error.
179   if (MissingArgCount) {
180     Diags.Report(diag::err_drv_missing_argument)
181         << Args.getArgString(MissingArgIndex) << MissingArgCount;
182     Success = false;
183   }
184 
185   // Issue errors on unknown arguments.
186   for (const Arg *A : Args.filtered(OPT_UNKNOWN)) {
187     auto ArgString = A->getAsString(Args);
188     std::string Nearest;
189     if (OptTbl->findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1)
190       Diags.Report(diag::err_drv_unknown_argument) << ArgString;
191     else
192       Diags.Report(diag::err_drv_unknown_argument_with_suggestion)
193           << ArgString << Nearest;
194     Success = false;
195   }
196 
197   // Construct the invocation.
198 
199   // Target Options
200   Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
201   Opts.CPU = Args.getLastArgValue(OPT_target_cpu);
202   Opts.Features = Args.getAllArgValues(OPT_target_feature);
203 
204   // Use the default target triple if unspecified.
205   if (Opts.Triple.empty())
206     Opts.Triple = llvm::sys::getDefaultTargetTriple();
207 
208   // Language Options
209   Opts.IncludePaths = Args.getAllArgValues(OPT_I);
210   Opts.NoInitialTextSection = Args.hasArg(OPT_n);
211   Opts.SaveTemporaryLabels = Args.hasArg(OPT_msave_temp_labels);
212   // Any DebugInfoKind implies GenDwarfForAssembly.
213   Opts.GenDwarfForAssembly = Args.hasArg(OPT_debug_info_kind_EQ);
214 
215   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
216                                      OPT_compress_debug_sections_EQ)) {
217     if (A->getOption().getID() == OPT_compress_debug_sections) {
218       // TODO: be more clever about the compression type auto-detection
219       Opts.CompressDebugSections = llvm::DebugCompressionType::GNU;
220     } else {
221       Opts.CompressDebugSections =
222           llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
223               .Case("none", llvm::DebugCompressionType::None)
224               .Case("zlib", llvm::DebugCompressionType::Z)
225               .Case("zlib-gnu", llvm::DebugCompressionType::GNU)
226               .Default(llvm::DebugCompressionType::None);
227     }
228   }
229 
230   Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
231   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
232   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
233   Opts.DwarfDebugProducer = Args.getLastArgValue(OPT_dwarf_debug_producer);
234   Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
235   Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
236 
237   for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
238     Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
239 
240   // Frontend Options
241   if (Args.hasArg(OPT_INPUT)) {
242     bool First = true;
243     for (const Arg *A : Args.filtered(OPT_INPUT)) {
244       if (First) {
245         Opts.InputFile = A->getValue();
246         First = false;
247       } else {
248         Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
249         Success = false;
250       }
251     }
252   }
253   Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
254   Opts.OutputPath = Args.getLastArgValue(OPT_o);
255   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
256   if (Arg *A = Args.getLastArg(OPT_filetype)) {
257     StringRef Name = A->getValue();
258     unsigned OutputType = StringSwitch<unsigned>(Name)
259       .Case("asm", FT_Asm)
260       .Case("null", FT_Null)
261       .Case("obj", FT_Obj)
262       .Default(~0U);
263     if (OutputType == ~0U) {
264       Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
265       Success = false;
266     } else
267       Opts.OutputType = FileType(OutputType);
268   }
269   Opts.ShowHelp = Args.hasArg(OPT_help);
270   Opts.ShowVersion = Args.hasArg(OPT_version);
271 
272   // Transliterate Options
273   Opts.OutputAsmVariant =
274       getLastArgIntValue(Args, OPT_output_asm_variant, 0, Diags);
275   Opts.ShowEncoding = Args.hasArg(OPT_show_encoding);
276   Opts.ShowInst = Args.hasArg(OPT_show_inst);
277 
278   // Assemble Options
279   Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
280   Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
281   Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
282   Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
283   Opts.IncrementalLinkerCompatible =
284       Args.hasArg(OPT_mincremental_linker_compatible);
285   Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
286 
287   return Success;
288 }
289 
290 static std::unique_ptr<raw_fd_ostream>
291 getOutputStream(StringRef Path, DiagnosticsEngine &Diags, bool Binary) {
292   // Make sure that the Out file gets unlinked from the disk if we get a
293   // SIGINT.
294   if (Path != "-")
295     sys::RemoveFileOnSignal(Path);
296 
297   std::error_code EC;
298   auto Out = llvm::make_unique<raw_fd_ostream>(
299       Path, EC, (Binary ? sys::fs::F_None : sys::fs::F_Text));
300   if (EC) {
301     Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();
302     return nullptr;
303   }
304 
305   return Out;
306 }
307 
308 static bool ExecuteAssembler(AssemblerInvocation &Opts,
309                              DiagnosticsEngine &Diags) {
310   // Get the target specific parser.
311   std::string Error;
312   const Target *TheTarget = TargetRegistry::lookupTarget(Opts.Triple, Error);
313   if (!TheTarget)
314     return Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
315 
316   ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer =
317       MemoryBuffer::getFileOrSTDIN(Opts.InputFile);
318 
319   if (std::error_code EC = Buffer.getError()) {
320     Error = EC.message();
321     return Diags.Report(diag::err_fe_error_reading) << Opts.InputFile;
322   }
323 
324   SourceMgr SrcMgr;
325 
326   // Tell SrcMgr about this buffer, which is what the parser will pick up.
327   SrcMgr.AddNewSourceBuffer(std::move(*Buffer), SMLoc());
328 
329   // Record the location of the include directories so that the lexer can find
330   // it later.
331   SrcMgr.setIncludeDirs(Opts.IncludePaths);
332 
333   std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(Opts.Triple));
334   assert(MRI && "Unable to create target register info!");
335 
336   std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, Opts.Triple));
337   assert(MAI && "Unable to create target asm info!");
338 
339   // Ensure MCAsmInfo initialization occurs before any use, otherwise sections
340   // may be created with a combination of default and explicit settings.
341   MAI->setCompressDebugSections(Opts.CompressDebugSections);
342 
343   MAI->setRelaxELFRelocations(Opts.RelaxELFRelocations);
344 
345   bool IsBinary = Opts.OutputType == AssemblerInvocation::FT_Obj;
346   if (Opts.OutputPath.empty())
347     Opts.OutputPath = "-";
348   std::unique_ptr<raw_fd_ostream> FDOS =
349       getOutputStream(Opts.OutputPath, Diags, IsBinary);
350   if (!FDOS)
351     return true;
352   std::unique_ptr<raw_fd_ostream> DwoOS;
353   if (!Opts.SplitDwarfFile.empty())
354     DwoOS = getOutputStream(Opts.SplitDwarfFile, Diags, IsBinary);
355 
356   // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
357   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
358   std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
359 
360   MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
361 
362   bool PIC = false;
363   if (Opts.RelocationModel == "static") {
364     PIC = false;
365   } else if (Opts.RelocationModel == "pic") {
366     PIC = true;
367   } else {
368     assert(Opts.RelocationModel == "dynamic-no-pic" &&
369            "Invalid PIC model!");
370     PIC = false;
371   }
372 
373   MOFI->InitMCObjectFileInfo(Triple(Opts.Triple), PIC, Ctx);
374   if (Opts.SaveTemporaryLabels)
375     Ctx.setAllowTemporaryLabels(false);
376   if (Opts.GenDwarfForAssembly)
377     Ctx.setGenDwarfForAssembly(true);
378   if (!Opts.DwarfDebugFlags.empty())
379     Ctx.setDwarfDebugFlags(StringRef(Opts.DwarfDebugFlags));
380   if (!Opts.DwarfDebugProducer.empty())
381     Ctx.setDwarfDebugProducer(StringRef(Opts.DwarfDebugProducer));
382   if (!Opts.DebugCompilationDir.empty())
383     Ctx.setCompilationDir(Opts.DebugCompilationDir);
384   if (!Opts.DebugPrefixMap.empty())
385     for (const auto &KV : Opts.DebugPrefixMap)
386       Ctx.addDebugPrefixMapEntry(KV.first, KV.second);
387   if (!Opts.MainFileName.empty())
388     Ctx.setMainFileName(StringRef(Opts.MainFileName));
389   Ctx.setDwarfVersion(Opts.DwarfVersion);
390 
391   // Build up the feature string from the target feature list.
392   std::string FS;
393   if (!Opts.Features.empty()) {
394     FS = Opts.Features[0];
395     for (unsigned i = 1, e = Opts.Features.size(); i != e; ++i)
396       FS += "," + Opts.Features[i];
397   }
398 
399   std::unique_ptr<MCStreamer> Str;
400 
401   std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
402   std::unique_ptr<MCSubtargetInfo> STI(
403       TheTarget->createMCSubtargetInfo(Opts.Triple, Opts.CPU, FS));
404 
405   raw_pwrite_stream *Out = FDOS.get();
406   std::unique_ptr<buffer_ostream> BOS;
407 
408   // FIXME: There is a bit of code duplication with addPassesToEmitFile.
409   if (Opts.OutputType == AssemblerInvocation::FT_Asm) {
410     MCInstPrinter *IP = TheTarget->createMCInstPrinter(
411         llvm::Triple(Opts.Triple), Opts.OutputAsmVariant, *MAI, *MCII, *MRI);
412 
413     std::unique_ptr<MCCodeEmitter> CE;
414     if (Opts.ShowEncoding)
415       CE.reset(TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
416     MCTargetOptions MCOptions;
417     std::unique_ptr<MCAsmBackend> MAB(
418         TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
419 
420     auto FOut = llvm::make_unique<formatted_raw_ostream>(*Out);
421     Str.reset(TheTarget->createAsmStreamer(
422         Ctx, std::move(FOut), /*asmverbose*/ true,
423         /*useDwarfDirectory*/ true, IP, std::move(CE), std::move(MAB),
424         Opts.ShowInst));
425   } else if (Opts.OutputType == AssemblerInvocation::FT_Null) {
426     Str.reset(createNullStreamer(Ctx));
427   } else {
428     assert(Opts.OutputType == AssemblerInvocation::FT_Obj &&
429            "Invalid file type!");
430     if (!FDOS->supportsSeeking()) {
431       BOS = make_unique<buffer_ostream>(*FDOS);
432       Out = BOS.get();
433     }
434 
435     std::unique_ptr<MCCodeEmitter> CE(
436         TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
437     MCTargetOptions MCOptions;
438     std::unique_ptr<MCAsmBackend> MAB(
439         TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
440     std::unique_ptr<MCObjectWriter> OW =
441         DwoOS ? MAB->createDwoObjectWriter(*Out, *DwoOS)
442               : MAB->createObjectWriter(*Out);
443 
444     Triple T(Opts.Triple);
445     Str.reset(TheTarget->createMCObjectStreamer(
446         T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI,
447         Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
448         /*DWARFMustBeAtTheEnd*/ true));
449     Str.get()->InitSections(Opts.NoExecStack);
450   }
451 
452   // Assembly to object compilation should leverage assembly info.
453   Str->setUseAssemblerInfoForParsing(true);
454 
455   bool Failed = false;
456 
457   std::unique_ptr<MCAsmParser> Parser(
458       createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));
459 
460   // FIXME: init MCTargetOptions from sanitizer flags here.
461   MCTargetOptions Options;
462   std::unique_ptr<MCTargetAsmParser> TAP(
463       TheTarget->createMCAsmParser(*STI, *Parser, *MCII, Options));
464   if (!TAP)
465     Failed = Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
466 
467   // Set values for symbols, if any.
468   for (auto &S : Opts.SymbolDefs) {
469     auto Pair = StringRef(S).split('=');
470     auto Sym = Pair.first;
471     auto Val = Pair.second;
472     int64_t Value;
473     // We have already error checked this in the driver.
474     Val.getAsInteger(0, Value);
475     Ctx.setSymbolValue(Parser->getStreamer(), Sym, Value);
476   }
477 
478   if (!Failed) {
479     Parser->setTargetParser(*TAP.get());
480     Failed = Parser->Run(Opts.NoInitialTextSection);
481   }
482 
483   // Close Streamer first.
484   // It might have a reference to the output stream.
485   Str.reset();
486   // Close the output stream early.
487   BOS.reset();
488   FDOS.reset();
489 
490   // Delete output file if there were errors.
491   if (Failed) {
492     if (Opts.OutputPath != "-")
493       sys::fs::remove(Opts.OutputPath);
494     if (!Opts.SplitDwarfFile.empty() && Opts.SplitDwarfFile != "-")
495       sys::fs::remove(Opts.SplitDwarfFile);
496   }
497 
498   return Failed;
499 }
500 
501 static void LLVMErrorHandler(void *UserData, const std::string &Message,
502                              bool GenCrashDiag) {
503   DiagnosticsEngine &Diags = *static_cast<DiagnosticsEngine*>(UserData);
504 
505   Diags.Report(diag::err_fe_error_backend) << Message;
506 
507   // We cannot recover from llvm errors.
508   exit(1);
509 }
510 
511 int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
512   // Initialize targets and assembly printers/parsers.
513   InitializeAllTargetInfos();
514   InitializeAllTargetMCs();
515   InitializeAllAsmParsers();
516 
517   // Construct our diagnostic client.
518   IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
519   TextDiagnosticPrinter *DiagClient
520     = new TextDiagnosticPrinter(errs(), &*DiagOpts);
521   DiagClient->setPrefix("clang -cc1as");
522   IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
523   DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient);
524 
525   // Set an error handler, so that any LLVM backend diagnostics go through our
526   // error handler.
527   ScopedFatalErrorHandler FatalErrorHandler
528     (LLVMErrorHandler, static_cast<void*>(&Diags));
529 
530   // Parse the arguments.
531   AssemblerInvocation Asm;
532   if (!AssemblerInvocation::CreateFromArgs(Asm, Argv, Diags))
533     return 1;
534 
535   if (Asm.ShowHelp) {
536     std::unique_ptr<OptTable> Opts(driver::createDriverOptTable());
537     Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
538                     "Clang Integrated Assembler",
539                     /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
540                     /*ShowAllAliases=*/false);
541     return 0;
542   }
543 
544   // Honor -version.
545   //
546   // FIXME: Use a better -version message?
547   if (Asm.ShowVersion) {
548     llvm::cl::PrintVersionMessage();
549     return 0;
550   }
551 
552   // Honor -mllvm.
553   //
554   // FIXME: Remove this, one day.
555   if (!Asm.LLVMArgs.empty()) {
556     unsigned NumArgs = Asm.LLVMArgs.size();
557     auto Args = llvm::make_unique<const char*[]>(NumArgs + 2);
558     Args[0] = "clang (LLVM option parsing)";
559     for (unsigned i = 0; i != NumArgs; ++i)
560       Args[i + 1] = Asm.LLVMArgs[i].c_str();
561     Args[NumArgs + 1] = nullptr;
562     llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
563   }
564 
565   // Execute the invocation, unless there were parsing errors.
566   bool Failed = Diags.hasErrorOccurred() || ExecuteAssembler(Asm, Diags);
567 
568   // If any timers were active but haven't been destroyed yet, print their
569   // results now.
570   TimerGroup::printAll(errs());
571 
572   return !!Failed;
573 }
574