;
58#define DEBUG_TYPE "codegenaction" 65: CodeGenOpts(CGOpts), BackendCon(BCon) {}
94[&](
constLLVMRemarkSetupFileError &
E) {
95Diags.
Report(diag::err_cannot_open_file)
98[&](
constLLVMRemarkSetupPatternError &
E) {
99Diags.
Report(diag::err_drv_optimization_remark_pattern)
102[&](
constLLVMRemarkSetupFormatError &
E) {
103Diags.
Report(diag::err_drv_optimization_remark_format)
113std::unique_ptr<raw_pwrite_stream> OS,
115llvm::Module *CurLinkModule)
116: CI(CI), Diags(CI.getDiagnostics()), CodeGenOpts(CI.getCodeGenOpts()),
117TargetOpts(CI.getTargetOpts()), LangOpts(CI.getLangOpts()),
118AsmOutStream(
std::move(OS)), FS(VFS), Action(Action),
120CI.getHeaderSearchOpts(), CI.getPreprocessorOpts(),
121CI.getCodeGenOpts(),
C, CoverageInfo)),
122LinkModules(
std::move(LinkModules)), CurLinkModule(CurLinkModule) {
123TimerIsEnabled = CodeGenOpts.TimePasses;
124llvm::TimePassesIsEnabled = CodeGenOpts.TimePasses;
125llvm::TimePassesPerRun = CodeGenOpts.TimePassesPerRun;
126 if(CodeGenOpts.TimePasses)
127LLVMIRGeneration.init(
"irgen",
"LLVM IR generation", CI.
getTimerGroup());
131 returnGen->GetModule();
135 returnstd::unique_ptr<llvm::Module>(Gen->ReleaseModule());
143Gen->HandleCXXStaticMemberVarInstantiation(VD);
147assert(!Context &&
"initialized multiple times");
152LLVMIRGeneration.startTimer();
154Gen->Initialize(Ctx);
157LLVMIRGeneration.stopTimer();
163 "LLVM IR generation of declaration");
166 if(TimerIsEnabled && !LLVMIRGenerationRefCount++)
169Gen->HandleTopLevelDecl(
D);
171 if(TimerIsEnabled && !--LLVMIRGenerationRefCount)
180 "LLVM IR generation of inline function");
184Gen->HandleInlineFunctionDefinition(
D);
198 for(
auto&LM : LinkModules) {
199assert(LM.Module &&
"LinkModule does not actually have a module");
201 if(LM.PropagateAttrs)
208F, CodeGenOpts, LangOpts, TargetOpts, LM.Internalize);
211CurLinkModule = LM.Module.get();
214 if(LM.Internalize) {
215Err = Linker::linkModules(
216*M, std::move(LM.Module), LM.LinkFlags,
217[](llvm::Module &M,
constllvm::StringSet<> &GVS) {
218internalizeModule(M, [&GVS](const llvm::GlobalValue &GV) {
219return !GV.hasName() || (GVS.count(GV.getName()) == 0);
223Err = Linker::linkModules(*M, std::move(LM.Module), LM.LinkFlags);
235llvm::TimeTraceScope TimeScope(
"Frontend");
236PrettyStackTraceString CrashInfo(
"Per-file LLVM IR generation");
237 if(TimerIsEnabled && !LLVMIRGenerationRefCount++)
240Gen->HandleTranslationUnit(
C);
242 if(TimerIsEnabled && !--LLVMIRGenerationRefCount)
245IRGenFinished =
true;
252LLVMContext &Ctx =
getModule()->getContext();
253std::unique_ptr<DiagnosticHandler> OldDiagnosticHandler =
254Ctx.getDiagnosticHandler();
255Ctx.setDiagnosticHandler(std::make_unique<ClangDiagnosticHandler>(
256CodeGenOpts,
this));
258Ctx.setDefaultTargetCPU(TargetOpts.
CPU);
259Ctx.setDefaultTargetFeatures(llvm::join(TargetOpts.
Features,
","));
262setupLLVMOptimizationRemarks(
267 if(Error
E= OptRecordFileOrErr.takeError()) {
272std::unique_ptr<llvm::ToolOutputFile> OptRecordFile =
273std::move(*OptRecordFileOrErr);
277Ctx.setDiagnosticsHotnessRequested(
true);
279 if(CodeGenOpts.MisExpect) {
280Ctx.setMisExpectWarningRequested(
true);
284Ctx.setDiagnosticsMisExpectTolerance(
292 for(
auto&F :
getModule()->functions()) {
293 if(
const Decl*FD = Gen->GetDeclForMangledName(F.getName())) {
294 auto Loc= FD->getASTContext().getFullLoc(FD->getLocation());
297ManglingFullSourceLocs.push_back(std::make_pair(NameHash,
Loc));
301 if(CodeGenOpts.ClearASTBeforeBackend) {
302LLVM_DEBUG(llvm::dbgs() <<
"Clearing AST...\n");
310 C.getAllocator().Reset();
316 C.getTargetInfo().getDataLayoutString(),
getModule(),
317Action, FS, std::move(AsmOutStream),
this);
319Ctx.setDiagnosticHandler(std::move(OldDiagnosticHandler));
322OptRecordFile->keep();
328 "LLVM IR generation of declaration");
329Gen->HandleTagDeclDefinition(
D);
333Gen->HandleTagDeclRequiredDefinition(
D);
337Gen->CompleteTentativeDefinition(
D);
341Gen->CompleteExternalDeclaration(
D);
345Gen->AssignInheritanceModel(RD);
349Gen->HandleVTable(RD);
352voidBackendConsumer::anchor() { }
368 constllvm::SourceMgr &LSM = *
D.getSourceMgr();
372 constMemoryBuffer *LBuf =
373LSM.getMemoryBuffer(LSM.FindBufferContainingLoc(
D.getLoc()));
377std::unique_ptr<llvm::MemoryBuffer> CBuf =
378llvm::MemoryBuffer::getMemBufferCopy(LBuf->getBuffer(),
379LBuf->getBufferIdentifier());
384 unsignedOffset =
D.getLoc().getPointer() - LBuf->getBufferStart();
390#define ComputeDiagID(Severity, GroupName, DiagID) \ 392 switch (Severity) { \ 393 case llvm::DS_Error: \ 394 DiagID = diag::err_fe_##GroupName; \ 396 case llvm::DS_Warning: \ 397 DiagID = diag::warn_fe_##GroupName; \ 399 case llvm::DS_Remark: \ 400 llvm_unreachable("'remark' severity not expected"); \
402case llvm::DS_Note: \
403DiagID = diag::note_fe_##GroupName; \
408#define ComputeDiagRemarkID(Severity, GroupName, DiagID) \ 410 switch (Severity) { \ 411 case llvm::DS_Error: \ 412 DiagID = diag::err_fe_##GroupName; \ 414 case llvm::DS_Warning: \ 415 DiagID = diag::warn_fe_##GroupName; \ 417 case llvm::DS_Remark: \ 418 DiagID = diag::remark_fe_##GroupName; \ 420 case llvm::DS_Note: \ 421 DiagID = diag::note_fe_##GroupName; \ 427 constllvm::SMDiagnostic &
D= DI.getSMDiag();
430 if(DI.isInlineAsmDiag())
438 D.
print(
nullptr, llvm::errs());
447StringRef Message =
D.getMessage();
448(void)Message.consume_front(
"error: ");
452 if(
D.getLoc() != SMLoc())
458 if(DI.isInlineAsmDiag()) {
464 if(
D.getLoc().isValid()) {
468 for(
conststd::pair<unsigned, unsigned> &
Range:
D.getRanges()) {
469 unsigned Column=
D.getColumnNo();
488std::string Message =
D.getMsgStr().str();
511 if(
D.getSeverity() != llvm::DS_Warning)
520Diags.
Report(*
Loc, diag::warn_fe_frame_larger_than)
521<<
D.getStackSize() <<
D.getStackLimit()
522<< llvm::demangle(
D.getFunction().getName());
527 constllvm::DiagnosticInfoResourceLimit &
D) {
531 unsignedDiagID = diag::err_fe_backend_resource_limit;
532 ComputeDiagID(
D.getSeverity(), backend_resource_limit, DiagID);
535<<
D.getResourceName() <<
D.getResourceSize() <<
D.getResourceLimit()
536<< llvm::demangle(
D.getFunction().getName());
541 constllvm::DiagnosticInfoWithLocationBase &
D,
bool&BadDebugInfo,
547 if(
D.isLocationAvailable()) {
571 if(DILoc.
isInvalid() &&
D.isLocationAvailable())
576Diags.
Report(
Loc, diag::note_fe_backend_invalid_loc)
582std::optional<FullSourceLoc>
585 for(
const auto&Pair : ManglingFullSourceLocs) {
586 if(Pair.first == Hash)
593 constllvm::DiagnosticInfoUnsupported &
D) {
595assert(
D.getSeverity() == llvm::DS_Error ||
596 D.getSeverity() == llvm::DS_Warning);
600 boolBadDebugInfo =
false;
603raw_string_ostream MsgStream(Msg);
607 if(Context !=
nullptr) {
609MsgStream <<
D.getMessage();
611DiagnosticPrinterRawOStream DP(MsgStream);
615 autoDiagType =
D.getSeverity() == llvm::DS_Error
616? diag::err_fe_backend_unsupported
617: diag::warn_fe_backend_unsupported;
625Diags.
Report(
Loc, diag::note_fe_backend_invalid_loc)
630 constllvm::DiagnosticInfoOptimizationBase &
D,
unsignedDiagID) {
632assert(
D.getSeverity() == llvm::DS_Remark ||
633 D.getSeverity() == llvm::DS_Warning);
637 boolBadDebugInfo =
false;
640raw_string_ostream MsgStream(Msg);
644 if(Context !=
nullptr) {
646MsgStream <<
D.getMsg();
648DiagnosticPrinterRawOStream DP(MsgStream);
652 if(
D.getHotness())
653MsgStream <<
" (hotness: "<< *
D.getHotness() <<
")";
662Diags.
Report(
Loc, diag::note_fe_backend_invalid_loc)
667 constllvm::DiagnosticInfoOptimizationBase &
D) {
669 if(
D.isVerbose() && !
D.getHotness())
672 if(
D.isPassed()) {
677}
else if(
D.isMissed()) {
683 D, diag::remark_fe_backend_optimization_remark_missed);
685assert(
D.isAnalysis() &&
"Unknown remark type");
687 boolShouldAlwaysPrint =
false;
688 if(
auto*ORA = dyn_cast<llvm::OptimizationRemarkAnalysis>(&
D))
689ShouldAlwaysPrint = ORA->shouldAlwaysPrint();
691 if(ShouldAlwaysPrint ||
694 D, diag::remark_fe_backend_optimization_remark_analysis);
699 constllvm::OptimizationRemarkAnalysisFPCommute &
D) {
704 if(
D.shouldAlwaysPrint() ||
707 D, diag::remark_fe_backend_optimization_remark_analysis_fpcommute);
711 constllvm::OptimizationRemarkAnalysisAliasing &
D) {
716 if(
D.shouldAlwaysPrint() ||
719 D, diag::remark_fe_backend_optimization_remark_analysis_aliasing);
723 constllvm::DiagnosticInfoOptimizationFailure &
D) {
736Diags.
Report(LocCookie,
D.getSeverity() == DiagnosticSeverity::DS_Error
737? diag::err_fe_backend_error_attr
738: diag::warn_fe_backend_warning_attr)
739<< llvm::demangle(
D.getFunctionName()) <<
D.getNote();
743 constllvm::DiagnosticInfoMisExpect &
D) {
746 boolBadDebugInfo =
false;
750Diags.
Report(
Loc, diag::warn_profile_data_misexpect) <<
D.getMsg().str();
757Diags.
Report(
Loc, diag::note_fe_backend_invalid_loc)
764 unsignedDiagID = diag::err_fe_inline_asm;
765llvm::DiagnosticSeverity Severity = DI.getSeverity();
767 switch(DI.getKind()) {
768 casellvm::DK_InlineAsm:
773 casellvm::DK_SrcMgr:
776 casellvm::DK_StackSize:
781 casellvm::DK_ResourceLimit:
789 casellvm::DK_OptimizationRemark:
794 casellvm::DK_OptimizationRemarkMissed:
799 casellvm::DK_OptimizationRemarkAnalysis:
804 casellvm::DK_OptimizationRemarkAnalysisFPCommute:
809 casellvm::DK_OptimizationRemarkAnalysisAliasing:
814 casellvm::DK_MachineOptimizationRemark:
819 casellvm::DK_MachineOptimizationRemarkMissed:
824 casellvm::DK_MachineOptimizationRemarkAnalysis:
829 casellvm::DK_OptimizationFailure:
834 casellvm::DK_Unsupported:
837 casellvm::DK_DontCall:
840 casellvm::DK_MisExpect:
848std::string MsgStorage;
850raw_string_ostream Stream(MsgStorage);
851DiagnosticPrinterRawOStream DP(Stream);
855 if(DI.getKind() == DK_Linker) {
856assert(CurLinkModule &&
"CurLinkModule must be set for linker diagnostics");
857Diags.
Report(DiagID) << CurLinkModule->getModuleIdentifier() << MsgStorage;
868: Act(_Act), VMContext(_VMContext ? _VMContext : new LLVMContext),
869OwnsVMContext(!_VMContext) {}
878 if(!LinkModules.empty())
886<< F.Filename << BCBuf.getError().message();
892getOwningLazyBitcodeModule(std::move(*BCBuf), *VMContext);
894handleAllErrors(ModuleOrErr.takeError(), [&](ErrorInfoBase &EIB) {
895CI.getDiagnostics().Report(diag::err_cannot_open_file)
896<< F.Filename << EIB.message();
901LinkModules.push_back({std::move(ModuleOrErr.get()), F.PropagateAttrs,
902F.Internalize, F.LinkFlags});
919 returnstd::move(TheModule);
923OwnsVMContext =
false;
937staticstd::unique_ptr<raw_pwrite_stream>
954llvm_unreachable(
"Invalid action!");
957std::unique_ptr<ASTConsumer>
968 if(loadLinkModules(CI))
979InFile, std::move(OS), CoverageInfo));
984 if(CI.
getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo &&
986std::unique_ptr<PPCallbacks> Callbacks =
994std::vector<std::unique_ptr<ASTConsumer>> Consumers(2);
995Consumers[0] = std::make_unique<ReducedBMIGenerator>(
998Consumers[1] = std::move(
Result);
999 returnstd::make_unique<MultiplexConsumer>(std::move(Consumers));
1002 returnstd::move(
Result);
1005std::unique_ptr<llvm::Module>
1006CodeGenAction::loadModule(MemoryBufferRef MBRef) {
1010 autoDiagErrors = [&](Error
E) -> std::unique_ptr<llvm::Module> {
1013handleAllErrors(std::move(
E), [&](ErrorInfoBase &EIB) {
1023VMContext->enableDebugTypeODRUniquing();
1027 returnDiagErrors(BMsOrErr.takeError());
1028BitcodeModule *Bm = llvm::lto::findThinLTOModule(*BMsOrErr);
1034 autoM = std::make_unique<llvm::Module>(
"empty", *VMContext);
1039Bm->parseModule(*VMContext);
1041 returnDiagErrors(MOrErr.takeError());
1042 returnstd::move(*MOrErr);
1046 if(loadLinkModules(CI))
1050llvm::SMDiagnostic Err;
1051 if(std::unique_ptr<llvm::Module> M = parseIR(MBRef, Err, *VMContext))
1058 if(BMsOrErr && BMsOrErr->size()) {
1059std::unique_ptr<llvm::Module> FirstM;
1060 for(
auto&BM : *BMsOrErr) {
1062BM.parseModule(*VMContext);
1064 returnDiagErrors(MOrErr.takeError());
1066LinkModules.push_back({std::move(*MOrErr),
false,
1069FirstM = std::move(*MOrErr);
1076consumeError(BMsOrErr.takeError());
1082 if(Err.getLineNo() > 0) {
1083assert(Err.getColumnNo() >= 0);
1084 Loc=
SM.translateFileLineCol(
SM.getFileEntryForID(
SM.getMainFileID()),
1085Err.getLineNo(), Err.getColumnNo() + 1);
1089StringRef Msg = Err.getMessage();
1090Msg.consume_front(
"error: ");
1110std::unique_ptr<raw_pwrite_stream> OS =
1117std::optional<MemoryBufferRef> MainFile =
SM.getBufferOrNone(FID);
1121TheModule = loadModule(*MainFile);
1126 if(TheModule->getTargetTriple() != TargetOpts.
Triple) {
1127Diagnostics.Report(
SourceLocation(), diag::warn_fe_override_module)
1129TheModule->setTargetTriple(TargetOpts.
Triple);
1132 EmbedObject(TheModule.get(), CodeGenOpts, Diagnostics);
1133 EmbedBitcode(TheModule.get(), CodeGenOpts, *MainFile);
1135LLVMContext &Ctx = TheModule->getContext();
1141std::unique_ptr<DiagnosticHandler> PrevHandler = Ctx.getDiagnosticHandler();
1142~RAII() { Ctx.setDiagnosticHandler(std::move(PrevHandler)); }
1148std::move(LinkModules),
"",
nullptr,
nullptr,
1152 if(!CodeGenOpts.LinkBitcodePostopt &&
Result.LinkInModules(&*TheModule))
1157Ctx.setDiscardValueNames(
false);
1158Ctx.setDiagnosticHandler(
1159std::make_unique<ClangDiagnosticHandler>(CodeGenOpts, &
Result));
1161Ctx.setDefaultTargetCPU(TargetOpts.
CPU);
1162Ctx.setDefaultTargetFeatures(llvm::join(TargetOpts.
Features,
","));
1165setupLLVMOptimizationRemarks(
1166Ctx, CodeGenOpts.OptRecordFile, CodeGenOpts.OptRecordPasses,
1167CodeGenOpts.OptRecordFormat, CodeGenOpts.DiagnosticsWithHotness,
1168CodeGenOpts.DiagnosticsHotnessThreshold);
1170 if(Error
E= OptRecordFileOrErr.takeError()) {
1174std::unique_ptr<llvm::ToolOutputFile> OptRecordFile =
1175std::move(*OptRecordFileOrErr);
1182OptRecordFile->keep();
1187voidEmitAssemblyAction::anchor() { }
1191voidEmitBCAction::anchor() { }
1195voidEmitLLVMAction::anchor() { }
1199voidEmitLLVMOnlyAction::anchor() { }
1203voidEmitCodeGenOnlyAction::anchor() { }
1207voidEmitObjAction::anchor() { }
Defines the clang::ASTContext interface.
#define ComputeDiagID(Severity, GroupName, DiagID)
static std::unique_ptr< raw_pwrite_stream > GetOutputStream(CompilerInstance &CI, StringRef InFile, BackendAction Action)
#define ComputeDiagRemarkID(Severity, GroupName, DiagID)
static FullSourceLoc ConvertBackendLocation(const llvm::SMDiagnostic &D, SourceManager &CSM)
ConvertBackendLocation - Convert a location in a temporary llvm::SourceMgr buffer to be a valid FullS...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::FileManager interface and associated types.
Defines the clang::Preprocessor interface.
Defines the SourceManager interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
llvm::Module * getModule() const
void CompleteExternalDeclaration(DeclaratorDecl *D) override
CompleteExternalDeclaration - Callback invoked at the end of a translation unit to notify the consume...
void OptimizationRemarkHandler(const llvm::DiagnosticInfoOptimizationBase &D)
bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D)
Specialized handler for StackSize diagnostic.
void HandleVTable(CXXRecordDecl *RD) override
Callback involved at the end of a translation unit to notify the consumer that a vtable for the given...
void HandleTagDeclDefinition(TagDecl *D) override
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
bool HandleTopLevelDecl(DeclGroupRef D) override
HandleTopLevelDecl - Handle the specified top-level declaration.
void Initialize(ASTContext &Ctx) override
Initialize - This is called to initialize the consumer, providing the ASTContext.
void HandleInlineFunctionDefinition(FunctionDecl *D) override
This callback is invoked each time an inline (method or friend) function definition in a class is com...
void OptimizationFailureHandler(const llvm::DiagnosticInfoOptimizationFailure &D)
void DiagnosticHandlerImpl(const llvm::DiagnosticInfo &DI)
This function is invoked when the backend needs to report something to the user.
void HandleTagDeclRequiredDefinition(const TagDecl *D) override
This callback is invoked the first time each TagDecl is required to be complete.
void HandleInterestingDecl(DeclGroupRef D) override
HandleInterestingDecl - Handle the specified interesting declaration.
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
std::optional< FullSourceLoc > getFunctionSourceLocation(const llvm::Function &F) const
bool ResourceLimitDiagHandler(const llvm::DiagnosticInfoResourceLimit &D)
Specialized handler for ResourceLimit diagnostic.
std::unique_ptr< llvm::Module > takeModule()
void AssignInheritanceModel(CXXRecordDecl *RD) override
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
void HandleTranslationUnit(ASTContext &C) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
void CompleteTentativeDefinition(VarDecl *D) override
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
void UnsupportedDiagHandler(const llvm::DiagnosticInfoUnsupported &D)
Specialized handler for unsupported backend feature diagnostic.
bool InlineAsmDiagHandler(const llvm::DiagnosticInfoInlineAsm &D)
Specialized handler for InlineAsm diagnostic.
bool LinkInModules(llvm::Module *M)
const FullSourceLoc getBestLocationFromDebugLoc(const llvm::DiagnosticInfoWithLocationBase &D, bool &BadDebugInfo, StringRef &Filename, unsigned &Line, unsigned &Column) const
Get the best possible source location to represent a diagnostic that may have associated debug info.
void EmitOptimizationMessage(const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID)
Specialized handlers for optimization remarks.
void DontCallDiagHandler(const llvm::DiagnosticInfoDontCall &D)
void MisExpectDiagHandler(const llvm::DiagnosticInfoMisExpect &D)
Specialized handler for misexpect warnings.
CodeGenerator * getCodeGenerator()
void SrcMgrDiagHandler(const llvm::DiagnosticInfoSrcMgr &D)
Specialized handler for diagnostics reported using SMDiagnostic.
BackendConsumer(CompilerInstance &CI, BackendAction Action, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, llvm::LLVMContext &C, SmallVector< LinkModule, 4 > LinkModules, StringRef InFile, std::unique_ptr< raw_pwrite_stream > OS, CoverageSourceInfo *CoverageInfo, llvm::Module *CurLinkModule=nullptr)
Represents a C++ struct/union/class.
bool isMissedOptRemarkEnabled(StringRef PassName) const override
bool handleDiagnostics(const DiagnosticInfo &DI) override
ClangDiagnosticHandler(const CodeGenOptions &CGOpts, BackendConsumer *BCon)
bool isPassedOptRemarkEnabled(StringRef PassName) const override
bool isAnyRemarkEnabled() const override
bool isAnalysisRemarkEnabled(StringRef PassName) const override
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
CodeGenerator * getCodeGenerator() const
friend class BackendConsumer
void EndSourceFileAction() override
Callback at the end of processing a single input.
bool BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
~CodeGenAction() override
CodeGenAction(unsigned _Act, llvm::LLVMContext *_VMContext=nullptr)
Create a new code generation action.
llvm::LLVMContext * takeLLVMContext()
Take the LLVM context used by this action.
BackendConsumer * BEConsumer
bool hasIRSupport() const override
Does this action support use with IR files?
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
std::unique_ptr< llvm::Module > takeModule()
Take the generated LLVM module, for use after the action has been run.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
std::string OptRecordFile
The name of the file to which the backend should save YAML optimization records.
std::vector< BitcodeFileToLink > LinkBitcodeFiles
The files specified here are linked in to the module before optimizations.
std::optional< uint64_t > DiagnosticsHotnessThreshold
The minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.
std::optional< uint32_t > DiagnosticsMisExpectTolerance
The maximum percentage profiling weights can deviate from the expected values in order to be included...
std::string OptRecordPasses
The regex that filters the passes that should be saved to the optimization records.
OptRemark OptimizationRemark
Selected optimizations for which we should enable optimization remarks.
std::string ThinLTOIndexFile
Name of the function summary index file to use for ThinLTO function importing.
OptRemark OptimizationRemarkAnalysis
Selected optimizations for which we should enable optimization analyses.
std::string OptRecordFormat
The format used for serializing remarks (default: YAML)
OptRemark OptimizationRemarkMissed
Selected optimizations for which we should enable missed optimization remarks.
static CoverageSourceInfo * setUpCoverageCallbacks(Preprocessor &PP)
The primary public interface to the Clang code generator.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
llvm::TimerGroup & getTimerGroup() const
std::unique_ptr< raw_pwrite_stream > createDefaultOutputFile(bool Binary=true, StringRef BaseInput="", StringRef Extension="", bool RemoveFileOnSignal=true, bool CreateMissingDirectories=false, bool ForceUseTemporary=false)
Create the default output file (from the invocation's options) and add it to the list of tracked outp...
llvm::Timer & getFrontendTimer() const
FileManager & getFileManager() const
Return the current file manager to the caller.
InMemoryModuleCache & getModuleCache() const
Preprocessor & getPreprocessor() const
Return the current preprocessor.
TargetOptions & getTargetOpts()
std::unique_ptr< llvm::raw_pwrite_stream > takeOutputStream()
FrontendOptions & getFrontendOpts()
TargetInfo & getTarget() const
llvm::vfs::FileSystem & getVirtualFileSystem() const
LangOptions & getLangOpts()
CodeGenOptions & getCodeGenOpts()
SourceManager & getSourceManager() const
Return the current source manager.
std::unique_ptr< raw_pwrite_stream > createNullOutputFile()
Stores additional source code information like skipped ranges which is required by the coverage mappi...
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
Represents a ValueDecl that came out of a declarator.
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
EmitAssemblyAction(llvm::LLVMContext *_VMContext=nullptr)
EmitBCAction(llvm::LLVMContext *_VMContext=nullptr)
EmitCodeGenOnlyAction(llvm::LLVMContext *_VMContext=nullptr)
EmitLLVMAction(llvm::LLVMContext *_VMContext=nullptr)
EmitLLVMOnlyAction(llvm::LLVMContext *_VMContext=nullptr)
EmitObjAction(llvm::LLVMContext *_VMContext=nullptr)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(FileEntryRef Entry, bool isVolatile=false, bool RequiresNullTerminator=true, std::optional< int64_t > MaybeLimit=std::nullopt, bool IsText=true)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
OptionalFileEntryRef getOptionalFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Get a FileEntryRef if it exists, without doing anything on error.
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > getVirtualFileSystemPtr() const
InputKind getCurrentFileKind() const
CompilerInstance & getCompilerInstance() const
StringRef getCurrentFileOrBufferName() const
unsigned GenReducedBMI
Whether to generate reduced BMI for C++20 named modules.
std::string ModuleOutputPath
Output Path for module output file.
A SourceLocation and its associated SourceManager.
Represents a function declaration or definition.
@ CMK_ModuleInterface
Compiling a C++ modules interface unit.
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
Encodes a location in the source.
static SourceLocation getFromRawEncoding(UIntTy Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
FileID createFileID(FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
FileManager & getFileManager() const
SourceLocation translateFileLineCol(const FileEntry *SourceFile, unsigned Line, unsigned Col) const
Get the source location for the given file:line:col triplet.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
A trivial tuple used to represent a source range.
void AddString(StringRef V) const
Represents the declaration of a struct/union/class/enum.
const char * getDataLayoutString() const
Options for controlling the target.
std::string Triple
The name of the target triple to compile for.
std::vector< std::string > Features
The list of target specific features to enable or disable â this should be a list of strings starting...
std::string CPU
If given, the name of the target CPU to generate code for.
Represents a variable declaration or definition.
Defines the clang::TargetInfo interface.
void mergeDefaultFunctionDefinitionAttributes(llvm::Function &F, const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts, const TargetOptions &TargetOpts, bool WillInternalize)
Adds attributes to F according to our CodeGenOpts and LangOpts, as though we had emitted it ourselves...
The JSON file list parser is used to communicate input to InstallAPI.
void EmbedObject(llvm::Module *M, const CodeGenOptions &CGOpts, DiagnosticsEngine &Diags)
static void reportOptRecordError(Error E, DiagnosticsEngine &Diags, const CodeGenOptions &CodeGenOpts)
CodeGenerator * CreateLLVMCodeGen(DiagnosticsEngine &Diags, llvm::StringRef ModuleName, IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS, const HeaderSearchOptions &HeaderSearchOpts, const PreprocessorOptions &PreprocessorOpts, const CodeGenOptions &CGO, llvm::LLVMContext &C, CoverageSourceInfo *CoverageInfo=nullptr)
CreateLLVMCodeGen - Create a CodeGenerator instance.
@ Result
The result type of a method or function.
void emitBackendOutput(CompilerInstance &CI, CodeGenOptions &CGOpts, StringRef TDesc, llvm::Module *M, BackendAction Action, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, std::unique_ptr< raw_pwrite_stream > OS, BackendConsumer *BC=nullptr)
void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts, llvm::MemoryBufferRef Buf)
@ Backend_EmitAssembly
Emit native assembly files.
@ Backend_EmitLL
Emit human-readable LLVM assembly.
@ Backend_EmitBC
Emit LLVM bitcode files.
@ Backend_EmitObj
Emit native object files.
@ Backend_EmitMCNull
Run CodeGen, but don't emit anything.
@ Backend_EmitNothing
Don't emit anything (benchmarking mode)
Diagnostic wrappers for TextAPI types for error reporting.
hash_code hash_value(const clang::tooling::dependencies::ModuleID &ID)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4