1 //===--- BackendUtil.cpp - LLVM Backend Utilities -------------------------===// 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/BackendUtil.h" 11 #include "clang/Basic/Diagnostic.h" 12 #include "clang/Basic/TargetOptions.h" 13 #include "clang/Basic/LangOptions.h" 14 #include "clang/Frontend/CodeGenOptions.h" 15 #include "clang/Frontend/FrontendDiagnostic.h" 16 #include "llvm/Module.h" 17 #include "llvm/PassManager.h" 18 #include "llvm/Analysis/Verifier.h" 19 #include "llvm/Assembly/PrintModulePass.h" 20 #include "llvm/Bitcode/ReaderWriter.h" 21 #include "llvm/CodeGen/RegAllocRegistry.h" 22 #include "llvm/CodeGen/SchedulerRegistry.h" 23 #include "llvm/MC/SubtargetFeature.h" 24 #include "llvm/Support/CommandLine.h" 25 #include "llvm/Support/FormattedStream.h" 26 #include "llvm/Support/PrettyStackTrace.h" 27 #include "llvm/Support/TargetRegistry.h" 28 #include "llvm/Support/Timer.h" 29 #include "llvm/Support/raw_ostream.h" 30 #include "llvm/DataLayout.h" 31 #include "llvm/Target/TargetLibraryInfo.h" 32 #include "llvm/Target/TargetMachine.h" 33 #include "llvm/Target/TargetOptions.h" 34 #include "llvm/Transforms/Instrumentation.h" 35 #include "llvm/Transforms/IPO.h" 36 #include "llvm/Transforms/IPO/PassManagerBuilder.h" 37 #include "llvm/Transforms/Scalar.h" 38 using namespace clang; 39 using namespace llvm; 40 41 namespace { 42 43 class EmitAssemblyHelper { 44 DiagnosticsEngine &Diags; 45 const CodeGenOptions &CodeGenOpts; 46 const clang::TargetOptions &TargetOpts; 47 const LangOptions &LangOpts; 48 Module *TheModule; 49 50 Timer CodeGenerationTime; 51 52 mutable PassManager *CodeGenPasses; 53 mutable PassManager *PerModulePasses; 54 mutable FunctionPassManager *PerFunctionPasses; 55 56 private: 57 PassManager *getCodeGenPasses(TargetMachine *TM) const { 58 if (!CodeGenPasses) { 59 CodeGenPasses = new PassManager(); 60 CodeGenPasses->add(new DataLayout(TheModule)); 61 // Add TargetTransformInfo. 62 if (TM) { 63 TargetTransformInfo *TTI = 64 new TargetTransformInfo(TM->getScalarTargetTransformInfo(), 65 TM->getVectorTargetTransformInfo()); 66 CodeGenPasses->add(TTI); 67 } 68 } 69 return CodeGenPasses; 70 } 71 72 PassManager *getPerModulePasses(TargetMachine *TM) const { 73 if (!PerModulePasses) { 74 PerModulePasses = new PassManager(); 75 PerModulePasses->add(new DataLayout(TheModule)); 76 if (TM) { 77 TargetTransformInfo *TTI = 78 new TargetTransformInfo(TM->getScalarTargetTransformInfo(), 79 TM->getVectorTargetTransformInfo()); 80 PerModulePasses->add(TTI); 81 } 82 } 83 return PerModulePasses; 84 } 85 86 FunctionPassManager *getPerFunctionPasses(TargetMachine *TM) const { 87 if (!PerFunctionPasses) { 88 PerFunctionPasses = new FunctionPassManager(TheModule); 89 PerFunctionPasses->add(new DataLayout(TheModule)); 90 if (TM) { 91 TargetTransformInfo *TTI = 92 new TargetTransformInfo(TM->getScalarTargetTransformInfo(), 93 TM->getVectorTargetTransformInfo()); 94 PerFunctionPasses->add(TTI); 95 } 96 } 97 return PerFunctionPasses; 98 } 99 100 101 void CreatePasses(TargetMachine *TM); 102 103 /// CreateTargetMachine - Generates the TargetMachine. 104 /// Returns Null if it is unable to create the target machine. 105 /// Some of our clang tests specify triples which are not built 106 /// into clang. This is okay because these tests check the generated 107 /// IR, and they require DataLayout which depends on the triple. 108 /// In this case, we allow this method to fail and not report an error. 109 /// When MustCreateTM is used, we print an error if we are unable to load 110 /// the requested target. 111 TargetMachine *CreateTargetMachine(bool MustCreateTM); 112 113 /// AddEmitPasses - Add passes necessary to emit assembly or LLVM IR. 114 /// 115 /// \return True on success. 116 bool AddEmitPasses(BackendAction Action, formatted_raw_ostream &OS, 117 TargetMachine *TM); 118 119 public: 120 EmitAssemblyHelper(DiagnosticsEngine &_Diags, 121 const CodeGenOptions &CGOpts, 122 const clang::TargetOptions &TOpts, 123 const LangOptions &LOpts, 124 Module *M) 125 : Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts), 126 TheModule(M), CodeGenerationTime("Code Generation Time"), 127 CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {} 128 129 ~EmitAssemblyHelper() { 130 delete CodeGenPasses; 131 delete PerModulePasses; 132 delete PerFunctionPasses; 133 } 134 135 void EmitAssembly(BackendAction Action, raw_ostream *OS); 136 }; 137 138 // We need this wrapper to access LangOpts from extension functions that 139 // we add to the PassManagerBuilder. 140 class PassManagerBuilderWrapper : public PassManagerBuilder { 141 public: 142 PassManagerBuilderWrapper(const CodeGenOptions &CGOpts, 143 const LangOptions &LangOpts) 144 : PassManagerBuilder(), CGOpts(CGOpts), LangOpts(LangOpts) {} 145 const CodeGenOptions &getCGOpts() const { return CGOpts; } 146 const LangOptions &getLangOpts() const { return LangOpts; } 147 private: 148 const CodeGenOptions &CGOpts; 149 const LangOptions &LangOpts; 150 }; 151 152 } 153 154 static void addObjCARCAPElimPass(const PassManagerBuilder &Builder, PassManagerBase &PM) { 155 if (Builder.OptLevel > 0) 156 PM.add(createObjCARCAPElimPass()); 157 } 158 159 static void addObjCARCExpandPass(const PassManagerBuilder &Builder, PassManagerBase &PM) { 160 if (Builder.OptLevel > 0) 161 PM.add(createObjCARCExpandPass()); 162 } 163 164 static void addObjCARCOptPass(const PassManagerBuilder &Builder, PassManagerBase &PM) { 165 if (Builder.OptLevel > 0) 166 PM.add(createObjCARCOptPass()); 167 } 168 169 static void addBoundsCheckingPass(const PassManagerBuilder &Builder, 170 PassManagerBase &PM) { 171 PM.add(createBoundsCheckingPass()); 172 } 173 174 static void addAddressSanitizerPasses(const PassManagerBuilder &Builder, 175 PassManagerBase &PM) { 176 const PassManagerBuilderWrapper &BuilderWrapper = 177 static_cast<const PassManagerBuilderWrapper&>(Builder); 178 const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); 179 const LangOptions &LangOpts = BuilderWrapper.getLangOpts(); 180 PM.add(createAddressSanitizerFunctionPass(LangOpts.SanitizeInitOrder, 181 LangOpts.SanitizeUseAfterReturn, 182 LangOpts.SanitizeUseAfterScope, 183 CGOpts.SanitizerBlacklistFile)); 184 PM.add(createAddressSanitizerModulePass(LangOpts.SanitizeInitOrder, 185 CGOpts.SanitizerBlacklistFile)); 186 } 187 188 static void addMemorySanitizerPass(const PassManagerBuilder &Builder, 189 PassManagerBase &PM) { 190 PM.add(createMemorySanitizerPass()); 191 } 192 193 static void addThreadSanitizerPass(const PassManagerBuilder &Builder, 194 PassManagerBase &PM) { 195 PM.add(createThreadSanitizerPass()); 196 } 197 198 void EmitAssemblyHelper::CreatePasses(TargetMachine *TM) { 199 unsigned OptLevel = CodeGenOpts.OptimizationLevel; 200 CodeGenOptions::InliningMethod Inlining = CodeGenOpts.getInlining(); 201 202 // Handle disabling of LLVM optimization, where we want to preserve the 203 // internal module before any optimization. 204 if (CodeGenOpts.DisableLLVMOpts) { 205 OptLevel = 0; 206 Inlining = CodeGenOpts.NoInlining; 207 } 208 209 PassManagerBuilderWrapper PMBuilder(CodeGenOpts, LangOpts); 210 PMBuilder.OptLevel = OptLevel; 211 PMBuilder.SizeLevel = CodeGenOpts.OptimizeSize; 212 213 PMBuilder.DisableSimplifyLibCalls = !CodeGenOpts.SimplifyLibCalls; 214 PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtATime; 215 PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops; 216 217 // In ObjC ARC mode, add the main ARC optimization passes. 218 if (LangOpts.ObjCAutoRefCount) { 219 PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible, 220 addObjCARCExpandPass); 221 PMBuilder.addExtension(PassManagerBuilder::EP_ModuleOptimizerEarly, 222 addObjCARCAPElimPass); 223 PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate, 224 addObjCARCOptPass); 225 } 226 227 if (LangOpts.SanitizeBounds) { 228 PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate, 229 addBoundsCheckingPass); 230 PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0, 231 addBoundsCheckingPass); 232 } 233 234 if (LangOpts.SanitizeAddress) { 235 PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast, 236 addAddressSanitizerPasses); 237 PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0, 238 addAddressSanitizerPasses); 239 } 240 241 if (LangOpts.SanitizeMemory) { 242 PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast, 243 addMemorySanitizerPass); 244 PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0, 245 addMemorySanitizerPass); 246 } 247 248 if (LangOpts.SanitizeThread) { 249 PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast, 250 addThreadSanitizerPass); 251 PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0, 252 addThreadSanitizerPass); 253 } 254 255 // Figure out TargetLibraryInfo. 256 Triple TargetTriple(TheModule->getTargetTriple()); 257 PMBuilder.LibraryInfo = new TargetLibraryInfo(TargetTriple); 258 if (!CodeGenOpts.SimplifyLibCalls) 259 PMBuilder.LibraryInfo->disableAllFunctions(); 260 261 switch (Inlining) { 262 case CodeGenOptions::NoInlining: break; 263 case CodeGenOptions::NormalInlining: { 264 // FIXME: Derive these constants in a principled fashion. 265 unsigned Threshold = 225; 266 if (CodeGenOpts.OptimizeSize == 1) // -Os 267 Threshold = 75; 268 else if (CodeGenOpts.OptimizeSize == 2) // -Oz 269 Threshold = 25; 270 else if (OptLevel > 2) 271 Threshold = 275; 272 PMBuilder.Inliner = createFunctionInliningPass(Threshold); 273 break; 274 } 275 case CodeGenOptions::OnlyAlwaysInlining: 276 // Respect always_inline. 277 if (OptLevel == 0) 278 // Do not insert lifetime intrinsics at -O0. 279 PMBuilder.Inliner = createAlwaysInlinerPass(false); 280 else 281 PMBuilder.Inliner = createAlwaysInlinerPass(); 282 break; 283 } 284 285 // Set up the per-function pass manager. 286 FunctionPassManager *FPM = getPerFunctionPasses(TM); 287 if (CodeGenOpts.VerifyModule) 288 FPM->add(createVerifierPass()); 289 PMBuilder.populateFunctionPassManager(*FPM); 290 291 // Set up the per-module pass manager. 292 PassManager *MPM = getPerModulePasses(TM); 293 294 if (CodeGenOpts.EmitGcovArcs || CodeGenOpts.EmitGcovNotes) { 295 MPM->add(createGCOVProfilerPass(CodeGenOpts.EmitGcovNotes, 296 CodeGenOpts.EmitGcovArcs, 297 TargetTriple.isMacOSX())); 298 299 if (CodeGenOpts.getDebugInfo() == CodeGenOptions::NoDebugInfo) 300 MPM->add(createStripSymbolsPass(true)); 301 } 302 303 PMBuilder.populateModulePassManager(*MPM); 304 } 305 306 TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { 307 // Create the TargetMachine for generating code. 308 std::string Error; 309 std::string Triple = TheModule->getTargetTriple(); 310 const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error); 311 if (!TheTarget) { 312 if (MustCreateTM) 313 Diags.Report(diag::err_fe_unable_to_create_target) << Error; 314 return 0; 315 } 316 317 // FIXME: Expose these capabilities via actual APIs!!!! Aside from just 318 // being gross, this is also totally broken if we ever care about 319 // concurrency. 320 321 TargetMachine::setAsmVerbosityDefault(CodeGenOpts.AsmVerbose); 322 323 TargetMachine::setFunctionSections(CodeGenOpts.FunctionSections); 324 TargetMachine::setDataSections (CodeGenOpts.DataSections); 325 326 // FIXME: Parse this earlier. 327 llvm::CodeModel::Model CM; 328 if (CodeGenOpts.CodeModel == "small") { 329 CM = llvm::CodeModel::Small; 330 } else if (CodeGenOpts.CodeModel == "kernel") { 331 CM = llvm::CodeModel::Kernel; 332 } else if (CodeGenOpts.CodeModel == "medium") { 333 CM = llvm::CodeModel::Medium; 334 } else if (CodeGenOpts.CodeModel == "large") { 335 CM = llvm::CodeModel::Large; 336 } else { 337 assert(CodeGenOpts.CodeModel.empty() && "Invalid code model!"); 338 CM = llvm::CodeModel::Default; 339 } 340 341 SmallVector<const char *, 16> BackendArgs; 342 BackendArgs.push_back("clang"); // Fake program name. 343 if (!CodeGenOpts.DebugPass.empty()) { 344 BackendArgs.push_back("-debug-pass"); 345 BackendArgs.push_back(CodeGenOpts.DebugPass.c_str()); 346 } 347 if (!CodeGenOpts.LimitFloatPrecision.empty()) { 348 BackendArgs.push_back("-limit-float-precision"); 349 BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str()); 350 } 351 if (llvm::TimePassesIsEnabled) 352 BackendArgs.push_back("-time-passes"); 353 for (unsigned i = 0, e = CodeGenOpts.BackendOptions.size(); i != e; ++i) 354 BackendArgs.push_back(CodeGenOpts.BackendOptions[i].c_str()); 355 if (CodeGenOpts.NoGlobalMerge) 356 BackendArgs.push_back("-global-merge=false"); 357 BackendArgs.push_back(0); 358 llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1, 359 BackendArgs.data()); 360 361 std::string FeaturesStr; 362 if (TargetOpts.Features.size()) { 363 SubtargetFeatures Features; 364 for (std::vector<std::string>::const_iterator 365 it = TargetOpts.Features.begin(), 366 ie = TargetOpts.Features.end(); it != ie; ++it) 367 Features.AddFeature(*it); 368 FeaturesStr = Features.getString(); 369 } 370 371 llvm::Reloc::Model RM = llvm::Reloc::Default; 372 if (CodeGenOpts.RelocationModel == "static") { 373 RM = llvm::Reloc::Static; 374 } else if (CodeGenOpts.RelocationModel == "pic") { 375 RM = llvm::Reloc::PIC_; 376 } else { 377 assert(CodeGenOpts.RelocationModel == "dynamic-no-pic" && 378 "Invalid PIC model!"); 379 RM = llvm::Reloc::DynamicNoPIC; 380 } 381 382 CodeGenOpt::Level OptLevel = CodeGenOpt::Default; 383 switch (CodeGenOpts.OptimizationLevel) { 384 default: break; 385 case 0: OptLevel = CodeGenOpt::None; break; 386 case 3: OptLevel = CodeGenOpt::Aggressive; break; 387 } 388 389 llvm::TargetOptions Options; 390 391 // Set frame pointer elimination mode. 392 if (!CodeGenOpts.DisableFPElim) { 393 Options.NoFramePointerElim = false; 394 Options.NoFramePointerElimNonLeaf = false; 395 } else if (CodeGenOpts.OmitLeafFramePointer) { 396 Options.NoFramePointerElim = false; 397 Options.NoFramePointerElimNonLeaf = true; 398 } else { 399 Options.NoFramePointerElim = true; 400 Options.NoFramePointerElimNonLeaf = true; 401 } 402 403 if (CodeGenOpts.UseInitArray) 404 Options.UseInitArray = true; 405 406 // Set float ABI type. 407 if (CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp") 408 Options.FloatABIType = llvm::FloatABI::Soft; 409 else if (CodeGenOpts.FloatABI == "hard") 410 Options.FloatABIType = llvm::FloatABI::Hard; 411 else { 412 assert(CodeGenOpts.FloatABI.empty() && "Invalid float abi!"); 413 Options.FloatABIType = llvm::FloatABI::Default; 414 } 415 416 // Set FP fusion mode. 417 switch (CodeGenOpts.getFPContractMode()) { 418 case CodeGenOptions::FPC_Off: 419 Options.AllowFPOpFusion = llvm::FPOpFusion::Strict; 420 break; 421 case CodeGenOptions::FPC_On: 422 Options.AllowFPOpFusion = llvm::FPOpFusion::Standard; 423 break; 424 case CodeGenOptions::FPC_Fast: 425 Options.AllowFPOpFusion = llvm::FPOpFusion::Fast; 426 break; 427 } 428 429 Options.LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD; 430 Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath; 431 Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath; 432 Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS; 433 Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath; 434 Options.UseSoftFloat = CodeGenOpts.SoftFloat; 435 Options.StackAlignmentOverride = CodeGenOpts.StackAlignment; 436 Options.RealignStack = CodeGenOpts.StackRealignment; 437 Options.DisableTailCalls = CodeGenOpts.DisableTailCalls; 438 Options.TrapFuncName = CodeGenOpts.TrapFuncName; 439 Options.PositionIndependentExecutable = LangOpts.PIELevel != 0; 440 Options.SSPBufferSize = CodeGenOpts.SSPBufferSize; 441 442 TargetMachine *TM = TheTarget->createTargetMachine(Triple, TargetOpts.CPU, 443 FeaturesStr, Options, 444 RM, CM, OptLevel); 445 446 if (CodeGenOpts.RelaxAll) 447 TM->setMCRelaxAll(true); 448 if (CodeGenOpts.SaveTempLabels) 449 TM->setMCSaveTempLabels(true); 450 if (CodeGenOpts.NoDwarf2CFIAsm) 451 TM->setMCUseCFI(false); 452 if (!CodeGenOpts.NoDwarfDirectoryAsm) 453 TM->setMCUseDwarfDirectory(true); 454 if (CodeGenOpts.NoExecStack) 455 TM->setMCNoExecStack(true); 456 457 return TM; 458 } 459 460 bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action, 461 formatted_raw_ostream &OS, 462 TargetMachine *TM) { 463 464 // Create the code generator passes. 465 PassManager *PM = getCodeGenPasses(TM); 466 467 // Add LibraryInfo. 468 llvm::Triple TargetTriple(TheModule->getTargetTriple()); 469 TargetLibraryInfo *TLI = new TargetLibraryInfo(TargetTriple); 470 if (!CodeGenOpts.SimplifyLibCalls) 471 TLI->disableAllFunctions(); 472 PM->add(TLI); 473 474 // Add TargetTransformInfo. 475 PM->add(new TargetTransformInfo(TM->getScalarTargetTransformInfo(), 476 TM->getVectorTargetTransformInfo())); 477 478 // Normal mode, emit a .s or .o file by running the code generator. Note, 479 // this also adds codegenerator level optimization passes. 480 TargetMachine::CodeGenFileType CGFT = TargetMachine::CGFT_AssemblyFile; 481 if (Action == Backend_EmitObj) 482 CGFT = TargetMachine::CGFT_ObjectFile; 483 else if (Action == Backend_EmitMCNull) 484 CGFT = TargetMachine::CGFT_Null; 485 else 486 assert(Action == Backend_EmitAssembly && "Invalid action!"); 487 488 // Add ObjC ARC final-cleanup optimizations. This is done as part of the 489 // "codegen" passes so that it isn't run multiple times when there is 490 // inlining happening. 491 if (LangOpts.ObjCAutoRefCount && 492 CodeGenOpts.OptimizationLevel > 0) 493 PM->add(createObjCARCContractPass()); 494 495 if (TM->addPassesToEmitFile(*PM, OS, CGFT, 496 /*DisableVerify=*/!CodeGenOpts.VerifyModule)) { 497 Diags.Report(diag::err_fe_unable_to_interface_with_target); 498 return false; 499 } 500 501 return true; 502 } 503 504 void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) { 505 TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : 0); 506 llvm::formatted_raw_ostream FormattedOS; 507 508 bool UsesCodeGen = (Action != Backend_EmitNothing && 509 Action != Backend_EmitBC && 510 Action != Backend_EmitLL); 511 TargetMachine *TM = CreateTargetMachine(UsesCodeGen); 512 CreatePasses(TM); 513 514 switch (Action) { 515 case Backend_EmitNothing: 516 break; 517 518 case Backend_EmitBC: 519 getPerModulePasses(TM)->add(createBitcodeWriterPass(*OS)); 520 break; 521 522 case Backend_EmitLL: 523 FormattedOS.setStream(*OS, formatted_raw_ostream::PRESERVE_STREAM); 524 getPerModulePasses(TM)->add(createPrintModulePass(&FormattedOS)); 525 break; 526 527 default: 528 FormattedOS.setStream(*OS, formatted_raw_ostream::PRESERVE_STREAM); 529 if (!AddEmitPasses(Action, FormattedOS, TM)) 530 return; 531 } 532 533 // Before executing passes, print the final values of the LLVM options. 534 cl::PrintOptionValues(); 535 536 // Run passes. For now we do all passes at once, but eventually we 537 // would like to have the option of streaming code generation. 538 539 if (PerFunctionPasses) { 540 PrettyStackTraceString CrashInfo("Per-function optimization"); 541 542 PerFunctionPasses->doInitialization(); 543 for (Module::iterator I = TheModule->begin(), 544 E = TheModule->end(); I != E; ++I) 545 if (!I->isDeclaration()) 546 PerFunctionPasses->run(*I); 547 PerFunctionPasses->doFinalization(); 548 } 549 550 if (PerModulePasses) { 551 PrettyStackTraceString CrashInfo("Per-module optimization passes"); 552 PerModulePasses->run(*TheModule); 553 } 554 555 if (CodeGenPasses) { 556 PrettyStackTraceString CrashInfo("Code generation"); 557 CodeGenPasses->run(*TheModule); 558 } 559 } 560 561 void clang::EmitBackendOutput(DiagnosticsEngine &Diags, 562 const CodeGenOptions &CGOpts, 563 const clang::TargetOptions &TOpts, 564 const LangOptions &LOpts, 565 Module *M, 566 BackendAction Action, raw_ostream *OS) { 567 EmitAssemblyHelper AsmHelper(Diags, CGOpts, TOpts, LOpts, M); 568 569 AsmHelper.EmitAssembly(Action, OS); 570 } 571