#include #include #include "llvm/Support/Extension.def"">

clang: lib/CodeGen/BackendUtil.cpp File Reference (original) (raw)

#include "[clang/CodeGen/BackendUtil.h](BackendUtil%5F8h%5Fsource.html)"
#include "[BackendConsumer.h](BackendConsumer%5F8h%5Fsource.html)"
#include "[LinkInModulesPass.h](LinkInModulesPass%5F8h%5Fsource.html)"
#include "[clang/Basic/CodeGenOptions.h](CodeGenOptions%5F8h%5Fsource.html)"
#include "[clang/Basic/Diagnostic.h](Basic%5F2Diagnostic%5F8h%5Fsource.html)"
#include "[clang/Basic/LangOptions.h](LangOptions%5F8h%5Fsource.html)"
#include "[clang/Basic/TargetOptions.h](TargetOptions%5F8h%5Fsource.html)"
#include "[clang/Frontend/FrontendDiagnostic.h](FrontendDiagnostic%5F8h%5Fsource.html)"
#include "[clang/Frontend/Utils.h](Frontend%5F2Utils%5F8h%5Fsource.html)"
#include "[clang/Lex/HeaderSearchOptions.h](HeaderSearchOptions%5F8h%5Fsource.html)"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/Frontend/Driver/CodeGenOptions.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IRPrinter/IRPrintingPasses.h"
#include "llvm/LTO/LTOBackend.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Object/OffloadBinary.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/ProfileData/InstrProfCorrelator.h"
#include "llvm/Support/BuryPointer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/TargetParser/SubtargetFeature.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/HipStdPar/HipStdPar.h"
#include "llvm/Transforms/IPO/EmbedBitcodePass.h"
#include "llvm/Transforms/IPO/LowerTypeTests.h"
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
#include "llvm/Transforms/InstCombine/InstCombine.h"
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
#include "llvm/Transforms/Instrumentation/BoundsChecking.h"
#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
#include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
#include "llvm/Transforms/Instrumentation/InstrProfiling.h"
#include "llvm/Transforms/Instrumentation/KCFI.h"
#include "llvm/Transforms/Instrumentation/LowerAllowCheckPass.h"
#include "llvm/Transforms/Instrumentation/MemProfiler.h"
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
#include "llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h"
#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
#include "llvm/Transforms/Instrumentation/RealtimeSanitizer.h"
#include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h"
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
#include "llvm/Transforms/Instrumentation/TypeSanitizer.h"
#include "llvm/Transforms/ObjCARC.h"
#include "llvm/Transforms/Scalar/EarlyCSE.h"
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/JumpThreading.h"
#include "llvm/Transforms/Utils/Debugify.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <limits>
#include <memory>
#include <optional>
#include "llvm/Support/Extension.def"

Go to the source code of this file.

Namespaces
namespace llvm
Diagnostic wrappers for TextAPI types for error reporting.
namespace clang
The JSON file list parser is used to communicate input to InstallAPI.
Macros
#define HANDLE_EXTENSION(Ext) llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
#define HANDLE_EXTENSION(Ext) get##Ext##PluginInfo().RegisterPassBuilderCallbacks(PB);
Functions
static cl::opt< bool > llvm::ClSanitizeOnOptimizerEarlyEP ("sanitizer-early-opt-ep", cl::Optional, cl::desc("Insert sanitizers on OptimizerEarlyEP."))
static cl::opt< PGOOptions::ColdFuncOpt > llvm::ClPGOColdFuncAttr ("pgo-cold-func-opt", cl::init(PGOOptions::ColdFuncOpt::Default), cl::Hidden, cl::desc("Function attribute to apply to cold functions as determined by PGO"), cl::values(clEnumValN(PGOOptions::ColdFuncOpt::Default, "default", "Default (no attribute)"), clEnumValN(PGOOptions::ColdFuncOpt::OptSize, "optsize", "Mark cold functions with optsize."), clEnumValN(PGOOptions::ColdFuncOpt::MinSize, "minsize", "Mark cold functions with minsize."), clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone", "Mark cold functions with optnone.")))
static SanitizerCoverageOptions getSancovOptsFromCGOpts (const CodeGenOptions &CGOpts)
static SanitizerBinaryMetadataOptions getSanitizerBinaryMetadataOptions (const CodeGenOptions &CGOpts)
static bool asanUseGlobalsGC (const Triple &T, const CodeGenOptions &CGOpts)
static std::optional< llvm::CodeModel::Model > getCodeModel (const CodeGenOptions &CodeGenOpts)
static CodeGenFileType getCodeGenFileType (BackendAction Action)
static bool actionRequiresCodeGen (BackendAction Action)
static std::string flattenClangCommandLine (ArrayRef< std::string > Args, StringRef MainFilename)
static bool initTargetOptions (const CompilerInstance &CI, DiagnosticsEngine &Diags, llvm::TargetOptions &Options)
static std::optional< GCOVOptions > getGCOVOptions (const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts)
static std::optional< InstrProfOptions > getInstrProfOptions (const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts)
static void setCommandLineOpts (const CodeGenOptions &CodeGenOpts)
static OptimizationLevel mapToLevel (const CodeGenOptions &Opts)
static void addKCFIPass (const Triple &TargetTriple, const LangOptions &LangOpts, PassBuilder &PB)
static void addSanitizers (const Triple &TargetTriple, const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts, PassBuilder &PB)
static void runThinLTOBackend (CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex, llvm::Module *M, std::unique_ptr< raw_pwrite_stream > OS, std::string SampleProfile, std::string ProfileRemapping, BackendAction Action)
Variables
cl::opt< bool > llvm::PrintPipelinePasses
cl::opt< InstrProfCorrelator::ProfCorrelatorKind > llvm::ProfileCorrelate
llvm:🆑:opt< bool > clang::ClSanitizeGuardChecks

â—† HANDLE_EXTENSION [1/2]

| #define HANDLE_EXTENSION | ( | | Ext | ) | llvm::PassPluginLibraryInfo get##Ext##PluginInfo(); | | ------------------------- | - | | --- | - | --------------------------------------------------- |

â—† HANDLE_EXTENSION [2/2]

| #define HANDLE_EXTENSION | ( | | Ext | ) | get##Ext##PluginInfo().RegisterPassBuilderCallbacks(PB); | | ------------------------- | - | | --- | - | -------------------------------------------------------- |

â—† actionRequiresCodeGen()

â—† addKCFIPass()

static void addKCFIPass ( const Triple & TargetTriple, const LangOptions & LangOpts, PassBuilder & PB ) static

â—† addSanitizers()

static void addSanitizers ( const Triple & TargetTriple, const CodeGenOptions & CodeGenOpts, const LangOptions & LangOpts, PassBuilder & PB ) static

Definition at line 688 of file BackendUtil.cpp.

References asanUseGlobalsGC(), llvm::ClSanitizeOnOptimizerEarlyEP(), getSancovOptsFromCGOpts(), getSanitizerBinaryMetadataOptions(), clang::SanitizerSet::has(), clang::CodeGenOptions::hasSanitizeBinaryMetadata(), clang::CodeGenOptions::hasSanitizeCoverage(), clang::LangOptions::NoSanitizeFiles, clang::LangOptions::Sanitize, clang::CodeGenOptions::SanitizeCoverageAllowlistFiles, clang::CodeGenOptions::SanitizeCoverageIgnorelistFiles, clang::CodeGenOptions::SanitizeMetadataIgnorelistFiles, and clang::CodeGenOptions::SanitizeRecover.

â—† asanUseGlobalsGC()

â—† flattenClangCommandLine()

static std::string flattenClangCommandLine ( ArrayRef< std::string > Args, StringRef MainFilename ) static

â—† getCodeGenFileType()

static CodeGenFileType getCodeGenFileType ( BackendAction Action) static

â—† getCodeModel()

static std::optional< llvm::CodeModel::Model > getCodeModel ( const CodeGenOptions & CodeGenOpts) static

â—† getGCOVOptions()

static std::optional< GCOVOptions > getGCOVOptions ( const CodeGenOptions & CodeGenOpts, const LangOptions & LangOpts ) static

â—† getInstrProfOptions()

static std::optional< InstrProfOptions > getInstrProfOptions ( const CodeGenOptions & CodeGenOpts, const LangOptions & LangOpts ) static

â—† getSancovOptsFromCGOpts()

static SanitizerCoverageOptions getSancovOptsFromCGOpts ( const CodeGenOptions & CGOpts) static

â—† getSanitizerBinaryMetadataOptions()

static SanitizerBinaryMetadataOptions getSanitizerBinaryMetadataOptions ( const CodeGenOptions & CGOpts) static

â—† initTargetOptions()

Definition at line 353 of file BackendUtil.cpp.

References clang::TargetOptions::ABI, clang::CodeGenOptions::Argv0, clang::CodeGenOptions::AsSecureLogFile, clang::CodeGenOptions::BBSections, clang::CodeGenOptions::BinutilsVersion, clang::CodeGenOptions::CommandLineArgs, clang::TargetOptions::EABIVersion, flattenClangCommandLine(), clang::CodeGenOptions::FloatABI, clang::CompilerInstance::getCodeGenOpts(), clang::CompilerInstance::getHeaderSearchOpts(), clang::CompilerInstance::getLangOpts(), clang::CompilerInstance::getTargetOpts(), clang::LangOptions::hasDWARFExceptions(), clang::LangOptions::hasSEHExceptions(), clang::LangOptions::hasSjLjExceptions(), clang::LangOptions::hasWasmExceptions(), clang::CodeGenOptions::MainFileName, clang::CodeGenOptions::ObjectFilenameForDebug, clang::DiagnosticsEngine::Report(), clang::CodeGenOptions::SplitDwarfFile, and clang::CodeGenOptions::StackUsageOutput.

Referenced by runThinLTOBackend().

â—† mapToLevel()

static OptimizationLevel mapToLevel ( const CodeGenOptions & Opts) static

â—† runThinLTOBackend()

static void runThinLTOBackend ( CompilerInstance & CI, ModuleSummaryIndex * CombinedIndex, llvm::Module * M, std::unique_ptr< raw_pwrite_stream > OS, std::string SampleProfile, std::string ProfileRemapping, BackendAction Action ) static

Definition at line 1259 of file BackendUtil.cpp.

References clang::Backend_EmitBC, clang::Backend_EmitLL, clang::Backend_EmitNothing, E, getCodeGenFileType(), clang::CompilerInstance::getCodeGenOpts(), getCodeModel(), clang::CompilerInstance::getDiagnostics(), clang::CompilerInstance::getTargetOpts(), initTargetOptions(), and setCommandLineOpts().

Referenced by clang::emitBackendOutput().

â—† setCommandLineOpts()

static void setCommandLineOpts ( const CodeGenOptions & CodeGenOpts) static