1 //===--- CodeGenAction.cpp - LLVM Code Generation Frontend Action ---------===//
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 #include "clang/CodeGen/CodeGenAction.h"
11 #include "clang/AST/ASTConsumer.h"
12 #include "clang/AST/ASTContext.h"
13 #include "clang/AST/DeclGroup.h"
14 #include "clang/Basic/FileManager.h"
15 #include "clang/Basic/SourceManager.h"
16 #include "clang/Basic/TargetInfo.h"
17 #include "clang/CodeGen/BackendUtil.h"
18 #include "clang/CodeGen/ModuleBuilder.h"
19 #include "clang/Frontend/CompilerInstance.h"
20 #include "clang/Frontend/FrontendDiagnostic.h"
21 #include "llvm/ADT/OwningPtr.h"
22 #include "llvm/ADT/SmallString.h"
23 #include "llvm/Bitcode/ReaderWriter.h"
24 #include "llvm/IR/DiagnosticInfo.h"
25 #include "llvm/IR/DiagnosticPrinter.h"
26 #include "llvm/IR/LLVMContext.h"
27 #include "llvm/IR/Module.h"
28 #include "llvm/IRReader/IRReader.h"
29 #include "llvm/Linker.h"
30 #include "llvm/Pass.h"
31 #include "llvm/Support/MemoryBuffer.h"
32 #include "llvm/Support/SourceMgr.h"
33 #include "llvm/Support/Timer.h"
34 using namespace clang;
35 using namespace llvm;
36 
37 namespace clang {
38   class BackendConsumer : public ASTConsumer {
39     virtual void anchor();
40     DiagnosticsEngine &Diags;
41     BackendAction Action;
42     const CodeGenOptions &CodeGenOpts;
43     const TargetOptions &TargetOpts;
44     const LangOptions &LangOpts;
45     raw_ostream *AsmOutStream;
46     ASTContext *Context;
47 
48     Timer LLVMIRGeneration;
49 
50     OwningPtr<CodeGenerator> Gen;
51 
52     OwningPtr<llvm::Module> TheModule, LinkModule;
53 
54   public:
55     BackendConsumer(BackendAction action, DiagnosticsEngine &_Diags,
56                     const CodeGenOptions &compopts,
57                     const TargetOptions &targetopts,
58                     const LangOptions &langopts, bool TimePasses,
59                     const std::string &infile, llvm::Module *LinkModule,
60                     raw_ostream *OS, LLVMContext &C)
61         : Diags(_Diags), Action(action), CodeGenOpts(compopts),
62           TargetOpts(targetopts), LangOpts(langopts), AsmOutStream(OS),
63           Context(), LLVMIRGeneration("LLVM IR Generation Time"),
64           Gen(CreateLLVMCodeGen(Diags, infile, compopts, targetopts, C)),
65           LinkModule(LinkModule) {
66       llvm::TimePassesIsEnabled = TimePasses;
67     }
68 
69     llvm::Module *takeModule() { return TheModule.take(); }
70     llvm::Module *takeLinkModule() { return LinkModule.take(); }
71 
72     virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
73       Gen->HandleCXXStaticMemberVarInstantiation(VD);
74     }
75 
76     virtual void Initialize(ASTContext &Ctx) {
77       Context = &Ctx;
78 
79       if (llvm::TimePassesIsEnabled)
80         LLVMIRGeneration.startTimer();
81 
82       Gen->Initialize(Ctx);
83 
84       TheModule.reset(Gen->GetModule());
85 
86       if (llvm::TimePassesIsEnabled)
87         LLVMIRGeneration.stopTimer();
88     }
89 
90     virtual bool HandleTopLevelDecl(DeclGroupRef D) {
91       PrettyStackTraceDecl CrashInfo(*D.begin(), SourceLocation(),
92                                      Context->getSourceManager(),
93                                      "LLVM IR generation of declaration");
94 
95       if (llvm::TimePassesIsEnabled)
96         LLVMIRGeneration.startTimer();
97 
98       Gen->HandleTopLevelDecl(D);
99 
100       if (llvm::TimePassesIsEnabled)
101         LLVMIRGeneration.stopTimer();
102 
103       return true;
104     }
105 
106     virtual void HandleTranslationUnit(ASTContext &C) {
107       {
108         PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
109         if (llvm::TimePassesIsEnabled)
110           LLVMIRGeneration.startTimer();
111 
112         Gen->HandleTranslationUnit(C);
113 
114         if (llvm::TimePassesIsEnabled)
115           LLVMIRGeneration.stopTimer();
116       }
117 
118       // Silently ignore if we weren't initialized for some reason.
119       if (!TheModule)
120         return;
121 
122       // Make sure IR generation is happy with the module. This is released by
123       // the module provider.
124       llvm::Module *M = Gen->ReleaseModule();
125       if (!M) {
126         // The module has been released by IR gen on failures, do not double
127         // free.
128         TheModule.take();
129         return;
130       }
131 
132       assert(TheModule.get() == M &&
133              "Unexpected module change during IR generation");
134 
135       // Link LinkModule into this module if present, preserving its validity.
136       if (LinkModule) {
137         std::string ErrorMsg;
138         if (Linker::LinkModules(M, LinkModule.get(), Linker::PreserveSource,
139                                 &ErrorMsg)) {
140           Diags.Report(diag::err_fe_cannot_link_module)
141             << LinkModule->getModuleIdentifier() << ErrorMsg;
142           return;
143         }
144       }
145 
146       // Install an inline asm handler so that diagnostics get printed through
147       // our diagnostics hooks.
148       LLVMContext &Ctx = TheModule->getContext();
149       LLVMContext::InlineAsmDiagHandlerTy OldHandler =
150         Ctx.getInlineAsmDiagnosticHandler();
151       void *OldContext = Ctx.getInlineAsmDiagnosticContext();
152       Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this);
153 
154       LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
155           Ctx.getDiagnosticHandler();
156       void *OldDiagnosticContext = Ctx.getDiagnosticContext();
157       Ctx.setDiagnosticHandler(DiagnosticHandler, this);
158 
159       EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
160                         C.getTargetInfo().getTargetDescription(),
161                         TheModule.get(), Action, AsmOutStream);
162 
163       Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
164 
165       Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
166     }
167 
168     virtual void HandleTagDeclDefinition(TagDecl *D) {
169       PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
170                                      Context->getSourceManager(),
171                                      "LLVM IR generation of declaration");
172       Gen->HandleTagDeclDefinition(D);
173     }
174 
175     virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {
176       Gen->HandleTagDeclRequiredDefinition(D);
177     }
178 
179     virtual void CompleteTentativeDefinition(VarDecl *D) {
180       Gen->CompleteTentativeDefinition(D);
181     }
182 
183     virtual void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) {
184       Gen->HandleVTable(RD, DefinitionRequired);
185     }
186 
187     virtual void HandleLinkerOptionPragma(llvm::StringRef Opts) {
188       Gen->HandleLinkerOptionPragma(Opts);
189     }
190 
191     virtual void HandleDetectMismatch(llvm::StringRef Name,
192                                       llvm::StringRef Value) {
193       Gen->HandleDetectMismatch(Name, Value);
194     }
195 
196     virtual void HandleDependentLibrary(llvm::StringRef Opts) {
197       Gen->HandleDependentLibrary(Opts);
198     }
199 
200     static void InlineAsmDiagHandler(const llvm::SMDiagnostic &SM,void *Context,
201                                      unsigned LocCookie) {
202       SourceLocation Loc = SourceLocation::getFromRawEncoding(LocCookie);
203       ((BackendConsumer*)Context)->InlineAsmDiagHandler2(SM, Loc);
204     }
205 
206     static void DiagnosticHandler(const llvm::DiagnosticInfo &DI,
207                                   void *Context) {
208       ((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI);
209     }
210 
211     void InlineAsmDiagHandler2(const llvm::SMDiagnostic &,
212                                SourceLocation LocCookie);
213 
214     void DiagnosticHandlerImpl(const llvm::DiagnosticInfo &DI);
215     /// \brief Specialized handler for InlineAsm diagnostic.
216     /// \return True if the diagnostic has been successfully reported, false
217     /// otherwise.
218     bool InlineAsmDiagHandler(const llvm::DiagnosticInfoInlineAsm &D);
219     /// \brief Specialized handler for StackSize diagnostic.
220     /// \return True if the diagnostic has been successfully reported, false
221     /// otherwise.
222     bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D);
223   };
224 
225   void BackendConsumer::anchor() {}
226 }
227 
228 /// ConvertBackendLocation - Convert a location in a temporary llvm::SourceMgr
229 /// buffer to be a valid FullSourceLoc.
230 static FullSourceLoc ConvertBackendLocation(const llvm::SMDiagnostic &D,
231                                             SourceManager &CSM) {
232   // Get both the clang and llvm source managers.  The location is relative to
233   // a memory buffer that the LLVM Source Manager is handling, we need to add
234   // a copy to the Clang source manager.
235   const llvm::SourceMgr &LSM = *D.getSourceMgr();
236 
237   // We need to copy the underlying LLVM memory buffer because llvm::SourceMgr
238   // already owns its one and clang::SourceManager wants to own its one.
239   const MemoryBuffer *LBuf =
240   LSM.getMemoryBuffer(LSM.FindBufferContainingLoc(D.getLoc()));
241 
242   // Create the copy and transfer ownership to clang::SourceManager.
243   llvm::MemoryBuffer *CBuf =
244   llvm::MemoryBuffer::getMemBufferCopy(LBuf->getBuffer(),
245                                        LBuf->getBufferIdentifier());
246   FileID FID = CSM.createFileIDForMemBuffer(CBuf);
247 
248   // Translate the offset into the file.
249   unsigned Offset = D.getLoc().getPointer()  - LBuf->getBufferStart();
250   SourceLocation NewLoc =
251   CSM.getLocForStartOfFile(FID).getLocWithOffset(Offset);
252   return FullSourceLoc(NewLoc, CSM);
253 }
254 
255 
256 /// InlineAsmDiagHandler2 - This function is invoked when the backend hits an
257 /// error parsing inline asm.  The SMDiagnostic indicates the error relative to
258 /// the temporary memory buffer that the inline asm parser has set up.
259 void BackendConsumer::InlineAsmDiagHandler2(const llvm::SMDiagnostic &D,
260                                             SourceLocation LocCookie) {
261   // There are a couple of different kinds of errors we could get here.  First,
262   // we re-format the SMDiagnostic in terms of a clang diagnostic.
263 
264   // Strip "error: " off the start of the message string.
265   StringRef Message = D.getMessage();
266   if (Message.startswith("error: "))
267     Message = Message.substr(7);
268 
269   // If the SMDiagnostic has an inline asm source location, translate it.
270   FullSourceLoc Loc;
271   if (D.getLoc() != SMLoc())
272     Loc = ConvertBackendLocation(D, Context->getSourceManager());
273 
274 
275   // If this problem has clang-level source location information, report the
276   // issue as being an error in the source with a note showing the instantiated
277   // code.
278   if (LocCookie.isValid()) {
279     Diags.Report(LocCookie, diag::err_fe_inline_asm).AddString(Message);
280 
281     if (D.getLoc().isValid()) {
282       DiagnosticBuilder B = Diags.Report(Loc, diag::note_fe_inline_asm_here);
283       // Convert the SMDiagnostic ranges into SourceRange and attach them
284       // to the diagnostic.
285       for (unsigned i = 0, e = D.getRanges().size(); i != e; ++i) {
286         std::pair<unsigned, unsigned> Range = D.getRanges()[i];
287         unsigned Column = D.getColumnNo();
288         B << SourceRange(Loc.getLocWithOffset(Range.first - Column),
289                          Loc.getLocWithOffset(Range.second - Column));
290       }
291     }
292     return;
293   }
294 
295   // Otherwise, report the backend error as occurring in the generated .s file.
296   // If Loc is invalid, we still need to report the error, it just gets no
297   // location info.
298   Diags.Report(Loc, diag::err_fe_inline_asm).AddString(Message);
299 }
300 
301 #define ComputeDiagID(Severity, GroupName, DiagID)                             \
302   do {                                                                         \
303     switch (Severity) {                                                        \
304     case llvm::DS_Error:                                                       \
305       DiagID = diag::err_fe_##GroupName;                                       \
306       break;                                                                   \
307     case llvm::DS_Warning:                                                     \
308       DiagID = diag::warn_fe_##GroupName;                                      \
309       break;                                                                   \
310     case llvm::DS_Remark:                                                      \
311       llvm_unreachable("'remark' severity not expected");                      \
312       break;                                                                   \
313     case llvm::DS_Note:                                                        \
314       DiagID = diag::note_fe_##GroupName;                                      \
315       break;                                                                   \
316     }                                                                          \
317   } while (false)
318 
319 #define ComputeDiagRemarkID(Severity, GroupName, DiagID)                       \
320   do {                                                                         \
321     switch (Severity) {                                                        \
322     case llvm::DS_Error:                                                       \
323       DiagID = diag::err_fe_##GroupName;                                       \
324       break;                                                                   \
325     case llvm::DS_Warning:                                                     \
326       DiagID = diag::warn_fe_##GroupName;                                      \
327       break;                                                                   \
328     case llvm::DS_Remark:                                                      \
329       DiagID = diag::remark_fe_##GroupName;                                    \
330       break;                                                                   \
331     case llvm::DS_Note:                                                        \
332       DiagID = diag::note_fe_##GroupName;                                      \
333       break;                                                                   \
334     }                                                                          \
335   } while (false)
336 
337 bool
338 BackendConsumer::InlineAsmDiagHandler(const llvm::DiagnosticInfoInlineAsm &D) {
339   unsigned DiagID;
340   ComputeDiagID(D.getSeverity(), inline_asm, DiagID);
341   std::string Message = D.getMsgStr().str();
342 
343   // If this problem has clang-level source location information, report the
344   // issue as being a problem in the source with a note showing the instantiated
345   // code.
346   SourceLocation LocCookie =
347       SourceLocation::getFromRawEncoding(D.getLocCookie());
348   if (LocCookie.isValid())
349     Diags.Report(LocCookie, DiagID).AddString(Message);
350   else {
351     // Otherwise, report the backend diagnostic as occurring in the generated
352     // .s file.
353     // If Loc is invalid, we still need to report the diagnostic, it just gets
354     // no location info.
355     FullSourceLoc Loc;
356     Diags.Report(Loc, DiagID).AddString(Message);
357   }
358   // We handled all the possible severities.
359   return true;
360 }
361 
362 bool
363 BackendConsumer::StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D) {
364   if (D.getSeverity() != llvm::DS_Warning)
365     // For now, the only support we have for StackSize diagnostic is warning.
366     // We do not know how to format other severities.
367     return false;
368 
369   // FIXME: We should demangle the function name.
370   // FIXME: Is there a way to get a location for that function?
371   FullSourceLoc Loc;
372   Diags.Report(Loc, diag::warn_fe_backend_frame_larger_than)
373       << D.getStackSize() << D.getFunction().getName();
374   return true;
375 }
376 
377 /// \brief This function is invoked when the backend needs
378 /// to report something to the user.
379 void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
380   unsigned DiagID = diag::err_fe_inline_asm;
381   llvm::DiagnosticSeverity Severity = DI.getSeverity();
382   // Get the diagnostic ID based.
383   switch (DI.getKind()) {
384   case llvm::DK_InlineAsm:
385     if (InlineAsmDiagHandler(cast<DiagnosticInfoInlineAsm>(DI)))
386       return;
387     ComputeDiagID(Severity, inline_asm, DiagID);
388     break;
389   case llvm::DK_StackSize:
390     if (StackSizeDiagHandler(cast<DiagnosticInfoStackSize>(DI)))
391       return;
392     ComputeDiagID(Severity, backend_frame_larger_than, DiagID);
393     break;
394   default:
395     // Plugin IDs are not bound to any value as they are set dynamically.
396     ComputeDiagRemarkID(Severity, backend_plugin, DiagID);
397     break;
398   }
399   std::string MsgStorage;
400   {
401     raw_string_ostream Stream(MsgStorage);
402     DiagnosticPrinterRawOStream DP(Stream);
403     DI.print(DP);
404   }
405 
406   // Report the backend message using the usual diagnostic mechanism.
407   FullSourceLoc Loc;
408   Diags.Report(Loc, DiagID).AddString(MsgStorage);
409 }
410 #undef ComputeDiagID
411 
412 CodeGenAction::CodeGenAction(unsigned _Act, LLVMContext *_VMContext)
413   : Act(_Act), LinkModule(0),
414     VMContext(_VMContext ? _VMContext : new LLVMContext),
415     OwnsVMContext(!_VMContext) {}
416 
417 CodeGenAction::~CodeGenAction() {
418   TheModule.reset();
419   if (OwnsVMContext)
420     delete VMContext;
421 }
422 
423 bool CodeGenAction::hasIRSupport() const { return true; }
424 
425 void CodeGenAction::EndSourceFileAction() {
426   // If the consumer creation failed, do nothing.
427   if (!getCompilerInstance().hasASTConsumer())
428     return;
429 
430   // If we were given a link module, release consumer's ownership of it.
431   if (LinkModule)
432     BEConsumer->takeLinkModule();
433 
434   // Steal the module from the consumer.
435   TheModule.reset(BEConsumer->takeModule());
436 }
437 
438 llvm::Module *CodeGenAction::takeModule() {
439   return TheModule.take();
440 }
441 
442 llvm::LLVMContext *CodeGenAction::takeLLVMContext() {
443   OwnsVMContext = false;
444   return VMContext;
445 }
446 
447 static raw_ostream *GetOutputStream(CompilerInstance &CI,
448                                     StringRef InFile,
449                                     BackendAction Action) {
450   switch (Action) {
451   case Backend_EmitAssembly:
452     return CI.createDefaultOutputFile(false, InFile, "s");
453   case Backend_EmitLL:
454     return CI.createDefaultOutputFile(false, InFile, "ll");
455   case Backend_EmitBC:
456     return CI.createDefaultOutputFile(true, InFile, "bc");
457   case Backend_EmitNothing:
458     return 0;
459   case Backend_EmitMCNull:
460   case Backend_EmitObj:
461     return CI.createDefaultOutputFile(true, InFile, "o");
462   }
463 
464   llvm_unreachable("Invalid action!");
465 }
466 
467 ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI,
468                                               StringRef InFile) {
469   BackendAction BA = static_cast<BackendAction>(Act);
470   OwningPtr<raw_ostream> OS(GetOutputStream(CI, InFile, BA));
471   if (BA != Backend_EmitNothing && !OS)
472     return 0;
473 
474   llvm::Module *LinkModuleToUse = LinkModule;
475 
476   // If we were not given a link module, and the user requested that one be
477   // loaded from bitcode, do so now.
478   const std::string &LinkBCFile = CI.getCodeGenOpts().LinkBitcodeFile;
479   if (!LinkModuleToUse && !LinkBCFile.empty()) {
480     std::string ErrorStr;
481 
482     llvm::MemoryBuffer *BCBuf =
483       CI.getFileManager().getBufferForFile(LinkBCFile, &ErrorStr);
484     if (!BCBuf) {
485       CI.getDiagnostics().Report(diag::err_cannot_open_file)
486         << LinkBCFile << ErrorStr;
487       return 0;
488     }
489 
490     ErrorOr<llvm::Module *> ModuleOrErr =
491         getLazyBitcodeModule(BCBuf, *VMContext);
492     if (error_code EC = ModuleOrErr.getError()) {
493       CI.getDiagnostics().Report(diag::err_cannot_open_file)
494         << LinkBCFile << EC.message();
495       return 0;
496     }
497     LinkModuleToUse = ModuleOrErr.get();
498   }
499 
500   BEConsumer =
501       new BackendConsumer(BA, CI.getDiagnostics(),
502                           CI.getCodeGenOpts(), CI.getTargetOpts(),
503                           CI.getLangOpts(),
504                           CI.getFrontendOpts().ShowTimers, InFile,
505                           LinkModuleToUse, OS.take(), *VMContext);
506   return BEConsumer;
507 }
508 
509 void CodeGenAction::ExecuteAction() {
510   // If this is an IR file, we have to treat it specially.
511   if (getCurrentFileKind() == IK_LLVM_IR) {
512     BackendAction BA = static_cast<BackendAction>(Act);
513     CompilerInstance &CI = getCompilerInstance();
514     raw_ostream *OS = GetOutputStream(CI, getCurrentFile(), BA);
515     if (BA != Backend_EmitNothing && !OS)
516       return;
517 
518     bool Invalid;
519     SourceManager &SM = CI.getSourceManager();
520     const llvm::MemoryBuffer *MainFile = SM.getBuffer(SM.getMainFileID(),
521                                                       &Invalid);
522     if (Invalid)
523       return;
524 
525     // FIXME: This is stupid, IRReader shouldn't take ownership.
526     llvm::MemoryBuffer *MainFileCopy =
527       llvm::MemoryBuffer::getMemBufferCopy(MainFile->getBuffer(),
528                                            getCurrentFile());
529 
530     llvm::SMDiagnostic Err;
531     TheModule.reset(ParseIR(MainFileCopy, Err, *VMContext));
532     if (!TheModule) {
533       // Translate from the diagnostic info to the SourceManager location.
534       SourceLocation Loc = SM.translateFileLineCol(
535         SM.getFileEntryForID(SM.getMainFileID()), Err.getLineNo(),
536         Err.getColumnNo() + 1);
537 
538       // Strip off a leading diagnostic code if there is one.
539       StringRef Msg = Err.getMessage();
540       if (Msg.startswith("error: "))
541         Msg = Msg.substr(7);
542 
543       unsigned DiagID =
544           CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0");
545 
546       CI.getDiagnostics().Report(Loc, DiagID) << Msg;
547       return;
548     }
549     const TargetOptions &TargetOpts = CI.getTargetOpts();
550     if (TheModule->getTargetTriple() != TargetOpts.Triple) {
551       unsigned DiagID = CI.getDiagnostics().getCustomDiagID(
552           DiagnosticsEngine::Warning,
553           "overriding the module target triple with %0");
554 
555       CI.getDiagnostics().Report(SourceLocation(), DiagID) << TargetOpts.Triple;
556       TheModule->setTargetTriple(TargetOpts.Triple);
557     }
558 
559     EmitBackendOutput(CI.getDiagnostics(), CI.getCodeGenOpts(), TargetOpts,
560                       CI.getLangOpts(), CI.getTarget().getTargetDescription(),
561                       TheModule.get(), BA, OS);
562     return;
563   }
564 
565   // Otherwise follow the normal AST path.
566   this->ASTFrontendAction::ExecuteAction();
567 }
568 
569 //
570 
571 void EmitAssemblyAction::anchor() { }
572 EmitAssemblyAction::EmitAssemblyAction(llvm::LLVMContext *_VMContext)
573   : CodeGenAction(Backend_EmitAssembly, _VMContext) {}
574 
575 void EmitBCAction::anchor() { }
576 EmitBCAction::EmitBCAction(llvm::LLVMContext *_VMContext)
577   : CodeGenAction(Backend_EmitBC, _VMContext) {}
578 
579 void EmitLLVMAction::anchor() { }
580 EmitLLVMAction::EmitLLVMAction(llvm::LLVMContext *_VMContext)
581   : CodeGenAction(Backend_EmitLL, _VMContext) {}
582 
583 void EmitLLVMOnlyAction::anchor() { }
584 EmitLLVMOnlyAction::EmitLLVMOnlyAction(llvm::LLVMContext *_VMContext)
585   : CodeGenAction(Backend_EmitNothing, _VMContext) {}
586 
587 void EmitCodeGenOnlyAction::anchor() { }
588 EmitCodeGenOnlyAction::EmitCodeGenOnlyAction(llvm::LLVMContext *_VMContext)
589   : CodeGenAction(Backend_EmitMCNull, _VMContext) {}
590 
591 void EmitObjAction::anchor() { }
592 EmitObjAction::EmitObjAction(llvm::LLVMContext *_VMContext)
593   : CodeGenAction(Backend_EmitObj, _VMContext) {}
594