Go to the documentation of this file.
27 #include "llvm/Config/llvm-config.h"
65 #if !defined(_MSC_VER) && !defined(__MINGW32__)
73 #define DEBUG_TYPE "thinlto"
104 " to save optimized bitcode\n");
112 GVSummaryList, [](
const std::unique_ptr<GlobalValueSummary> &Summary) {
113 auto Linkage = Summary->linkage();
117 if (StrongDefForLinker != GVSummaryList.end())
118 return StrongDefForLinker->get();
122 GVSummaryList, [](
const std::unique_ptr<GlobalValueSummary> &Summary) {
123 auto Linkage = Summary->linkage();
127 if (FirstDefForLinker == GVSummaryList.end())
129 return FirstDefForLinker->get();
135 static void computePrevailingCopies(
139 return GVSummaryList.size() > 1;
143 if (HasMultipleCopies(
I.second.SummaryList))
144 PrevailingCopy[
I.first] =
145 getFirstDefinitionForLinker(
I.second.SummaryList);
150 generateModuleMap(std::vector<std::unique_ptr<lto::InputFile>> &Modules) {
152 for (
auto &M : Modules) {
154 "Expect unique Buffer Identifier");
155 ModuleMap[
M->getName()] =
M.get();
161 bool ClearDSOLocalOnDeclarations) {
170 ThinLTODiagnosticInfo(
const Twine &DiagMsg,
178 static void verifyLoadedModule(
Module &TheModule) {
179 bool BrokenDebugInfo =
false;
182 if (BrokenDebugInfo) {
184 "Invalid debug info found, debug info will be stripped",
DS_Warning));
189 static std::unique_ptr<Module> loadModuleFromInput(
lto::InputFile *Input,
193 auto &
Mod =
Input->getSingleBitcodeModule();
201 SMDiagnostic Err = SMDiagnostic(Mod.getModuleIdentifier(),
202 SourceMgr::DK_Error, EIB.message());
203 Err.print(
"ThinLTO", errs());
208 verifyLoadedModule(*ModuleOrErr.
get());
216 bool ClearDSOLocalOnDeclarations) {
219 return loadModuleFromInput(Input, TheModule.
getContext(),
227 SMDiagnostic Err = SMDiagnostic(TheModule.getModuleIdentifier(),
228 SourceMgr::DK_Error, EIB.message());
229 Err.print(
"ThinLTO", errs());
234 verifyLoadedModule(TheModule);
238 unsigned OptLevel,
bool Freestanding,
254 std::unique_ptr<TargetLibraryInfoImpl> TLII(
257 TLII->disableAllFunctions();
296 for (
const auto &Sym :
File.symbols()) {
303 static void computeGUIDPreservedSymbols(
const lto::InputFile &File,
309 for (
const auto &Sym :
File.symbols()) {
319 const Triple &TheTriple) {
322 GUIDPreservedSymbols);
323 return GUIDPreservedSymbols;
326 std::unique_ptr<MemoryBuffer> codegenModule(
Module &TheModule,
347 return std::make_unique<SmallVectorMemoryBuffer>(
352 class ModuleCacheEntry {
363 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
366 if (CachePath.
empty())
369 if (!
Index.modulePaths().count(ModuleID))
388 ResolvedODR, DefinedGVSummaries);
396 StringRef getEntryPath() {
return EntryPath; }
400 if (EntryPath.empty())
401 return std::error_code();
408 *FDOrErr, EntryPath, -1,
false);
415 if (EntryPath.empty())
428 std::string ErrorMsgBuffer;
429 llvm::raw_string_ostream S(ErrorMsgBuffer);
433 llvm::atomic_write_error::failed_to_create_uniq_file) {
434 errs() <<
"Error: " << ErrorMsgBuffer <<
"\n";
435 report_fatal_error(
"ThinLTO: Can't get a temporary file");
444 static std::unique_ptr<MemoryBuffer>
452 bool DisableCodeGen,
StringRef SaveTempsDir,
453 bool Freestanding,
unsigned OptLevel,
unsigned count,
454 bool DebugPassManager) {
457 bool SingleModule = (ModuleMap.
size() == 1);
461 bool ClearDSOLocalOnDeclarations =
462 TM.getTargetTriple().isOSBinFormatELF() &&
467 promoteModule(TheModule,
Index, ClearDSOLocalOnDeclarations);
473 saveTempBitcode(TheModule, SaveTempsDir,
count,
".1.promoted.bc");
478 if (!ExportList.
empty() || !GUIDPreservedSymbols.
empty()) {
484 saveTempBitcode(TheModule, SaveTempsDir,
count,
".2.internalized.bc");
487 crossImportIntoModule(TheModule,
Index, ModuleMap, ImportList,
488 ClearDSOLocalOnDeclarations);
491 saveTempBitcode(TheModule, SaveTempsDir,
count,
".3.imported.bc");
494 optimizeModule(TheModule,
TM, OptLevel, Freestanding, DebugPassManager,
497 saveTempBitcode(TheModule, SaveTempsDir,
count,
".4.opt.bc");
499 if (DisableCodeGen) {
508 return std::make_unique<SmallVectorMemoryBuffer>(
512 return codegenModule(TheModule,
TM);
520 static void resolvePrevailingInIndex(
522 StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>>
529 const auto &Prevailing = PrevailingCopy.
find(GUID);
531 if (Prevailing == PrevailingCopy.
end())
533 return Prevailing->second ==
S;
536 auto recordNewLinkage = [&](
StringRef ModuleIdentifier,
539 ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
545 GUIDPreservedSymbols);
550 const Triple &TheTriple) {
555 TMBuilder.
MCpu =
"core2";
557 TMBuilder.
MCpu =
"yonah";
560 TMBuilder.
MCpu =
"cyclone";
573 toString(InputOrError.takeError()));
575 auto TripleStr = (*InputOrError)->getTargetTriple();
576 Triple TheTriple(TripleStr);
579 initTMBuilder(TMBuilder,
Triple(TheTriple));
580 else if (TMBuilder.
TheTriple != TheTriple) {
587 Modules.emplace_back(
std::move(*InputOrError));
613 std::string FeatureStr = Features.
getString();
615 std::unique_ptr<TargetMachine>
TM(
618 assert(
TM &&
"Cannot create target machine");
628 std::unique_ptr<ModuleSummaryIndex> CombinedIndex =
629 std::make_unique<ModuleSummaryIndex>(
false);
631 for (
auto &
Mod : Modules) {
632 auto &
M =
Mod->getSingleBitcodeModule();
634 M.readSummary(*CombinedIndex,
Mod->
getName(), NextModuleId++)) {
638 "error: can't create module summary index for buffer: ");
642 return CombinedIndex;
652 : ExportLists(ExportLists), GUIDPreservedSymbols(GUIDPreservedSymbols) {}
655 const auto &ExportList = ExportLists.
find(ModuleIdentifier);
656 return (ExportList != ExportLists.
end() && ExportList->second.
count(
VI)) ||
657 GUIDPreservedSymbols.
count(
VI.getGUID());
661 struct IsPrevailing {
665 : PrevailingCopy(PrevailingCopy) {}
668 const auto &Prevailing = PrevailingCopy.
find(GUID);
670 if (Prevailing == PrevailingCopy.
end())
672 return Prevailing->second ==
S;
696 auto ModuleCount =
Index.modulePaths().size();
701 Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
704 auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
708 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
720 computePrevailingCopies(
Index, PrevailingCopy);
724 resolvePrevailingInIndex(
Index, ResolvedODR, GUIDPreservedSymbols,
728 ModuleToDefinedGVSummaries[ModuleIdentifier],
734 Index, IsExported(ExportLists, GUIDPreservedSymbols),
735 IsPrevailing(PrevailingCopy));
738 promoteModule(TheModule,
Index,
false);
747 auto ModuleMap = generateModuleMap(Modules);
748 auto ModuleCount =
Index.modulePaths().size();
752 Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
755 auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
758 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
771 crossImportIntoModule(TheModule,
Index, ModuleMap, ImportList,
780 std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex,
782 auto ModuleCount =
Index.modulePaths().size();
787 Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
790 auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
793 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
805 ModuleIdentifier, ModuleToDefinedGVSummaries,
806 ImportLists[ModuleIdentifier], ModuleToSummariesForIndex);
815 auto ModuleCount =
Index.modulePaths().size();
820 Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
823 auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
826 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
837 std::map<std::string, GVSummaryMapTy> ModuleToSummariesForIndex;
839 ModuleIdentifier, ModuleToDefinedGVSummaries,
840 ImportLists[ModuleIdentifier], ModuleToSummariesForIndex);
844 ModuleToSummariesForIndex)))
846 " to save imports lists\n");
857 auto ModuleCount =
Index.modulePaths().size();
861 auto GUIDPreservedSymbols =
862 computeGUIDPreservedSymbols(File, PreservedSymbols, TMBuilder.
TheTriple);
864 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
868 Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
878 auto &ExportList = ExportLists[ModuleIdentifier];
882 if (ExportList.
empty() && GUIDPreservedSymbols.
empty())
886 computePrevailingCopies(
Index, PrevailingCopy);
890 resolvePrevailingInIndex(
Index, ResolvedODR, GUIDPreservedSymbols,
896 Index, IsExported(ExportLists, GUIDPreservedSymbols),
897 IsPrevailing(PrevailingCopy));
900 promoteModule(TheModule,
Index,
false);
904 ModuleToDefinedGVSummaries[ModuleIdentifier],
908 ModuleToDefinedGVSummaries[ModuleIdentifier]);
918 optimizeModule(TheModule, *TMBuilder.
create(), OptLevel, Freestanding,
919 DebugPassManager,
nullptr);
931 Twine(
count) +
"." + ArchName +
".thinlto.o");
937 if (!CacheEntryPath.
empty()) {
941 return std::string(OutputPath.
str());
945 return std::string(OutputPath.
str());
949 errs() <<
"remark: can't link or copy from cached entry '" << CacheEntryPath
950 <<
"' to '" << OutputPath <<
"'\n";
958 return std::string(OutputPath.
str());
969 assert(ProducedBinaries.empty() &&
"The generator should not be reused");
970 if (SavedObjectsDirectoryPath.empty())
971 ProducedBinaries.resize(Modules.size());
978 ProducedBinaryFiles.resize(Modules.size());
985 for (
auto &
Mod : Modules) {
991 auto TheModule = loadModuleFromInput(
Mod.get(),
Context,
false,
995 auto OutputBuffer = codegenModule(*TheModule, *TMBuilder.
create());
996 if (SavedObjectsDirectoryPath.empty())
999 ProducedBinaryFiles[
count] =
1011 if (!SaveTempsDir.
empty()) {
1012 auto SaveTempPath = SaveTempsDir +
"index.bc";
1017 " to save optimized bitcode\n");
1023 auto ModuleMap = generateModuleMap(Modules);
1024 auto ModuleCount = Modules.size();
1028 Index->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
1033 for (
const auto &
M : Modules)
1034 computeGUIDPreservedSymbols(*
M, PreservedSymbols, TMBuilder.
TheTriple,
1035 GUIDPreservedSymbols);
1038 for (
const auto &
M : Modules)
1039 addUsedSymbolToPreservedGUID(*
M, GUIDPreservedSymbols);
1059 std::map<ValueInfo, std::vector<VTableSlotSummary>> LocalWPDTargetsMap;
1060 std::set<GlobalValue::GUID> ExportedGUIDs;
1062 for (
auto GUID : ExportedGUIDs)
1063 GUIDPreservedSymbols.
insert(GUID);
1079 computePrevailingCopies(*
Index, PrevailingCopy);
1083 resolvePrevailingInIndex(*
Index, ResolvedODR, GUIDPreservedSymbols,
1090 IsExported(ExportLists, GUIDPreservedSymbols),
1091 LocalWPDTargetsMap);
1093 *
Index, IsExported(ExportLists, GUIDPreservedSymbols),
1094 IsPrevailing(PrevailingCopy));
1101 for (
auto &
Module : Modules) {
1103 ExportLists[ModuleIdentifier];
1104 ImportLists[ModuleIdentifier];
1105 ResolvedODR[ModuleIdentifier];
1106 ModuleToDefinedGVSummaries[ModuleIdentifier];
1109 std::vector<BitcodeModule *> ModulesVec;
1110 ModulesVec.reserve(Modules.
size());
1111 for (
auto &
Mod : Modules)
1112 ModulesVec.push_back(&
Mod->getSingleBitcodeModule());
1118 TimeTraceScopeExit.release();
1123 for (
auto IndexCount : ModulesOrdering) {
1124 auto &
Mod = Modules[IndexCount];
1127 auto &ExportList = ExportLists[ModuleIdentifier];
1129 auto &DefinedGVSummaries = ModuleToDefinedGVSummaries[ModuleIdentifier];
1132 ModuleCacheEntry CacheEntry(CacheOptions.
Path, *
Index, ModuleIdentifier,
1133 ImportLists[ModuleIdentifier], ExportList,
1134 ResolvedODR[ModuleIdentifier],
1135 DefinedGVSummaries, OptLevel, Freestanding,
1137 auto CacheEntryPath = CacheEntry.getEntryPath();
1140 auto ErrOrBuffer = CacheEntry.tryLoadingBuffer();
1142 <<
" '" << CacheEntryPath <<
"' for buffer "
1143 <<
count <<
" " << ModuleIdentifier <<
"\n");
1147 if (SavedObjectsDirectoryPath.empty())
1151 count, CacheEntryPath, *ErrOrBuffer.get());
1162 if (!DiagFileOrErr) {
1163 errs() <<
"Error: " <<
toString(DiagFileOrErr.takeError()) <<
"\n";
1169 auto TheModule = loadModuleFromInput(
Mod.get(),
Context,
false,
1173 saveTempBitcode(*TheModule, SaveTempsDir,
count,
".0.original.bc");
1175 auto &ImportList = ImportLists[ModuleIdentifier];
1177 auto OutputBuffer = ProcessThinLTOModule(
1178 *TheModule, *
Index, ModuleMap, *TMBuilder.
create(), ImportList,
1179 ExportList, GUIDPreservedSymbols,
1180 ModuleToDefinedGVSummaries[ModuleIdentifier], CacheOptions,
1181 DisableCodeGen, SaveTempsDir, Freestanding, OptLevel,
count,
1185 CacheEntry.write(*OutputBuffer);
1187 if (SavedObjectsDirectoryPath.empty()) {
1189 if (!CacheEntryPath.empty()) {
1196 auto ReloadedBufferOrErr = CacheEntry.tryLoadingBuffer();
1197 if (
auto EC = ReloadedBufferOrErr.getError()) {
1199 errs() <<
"remark: can't reload cached file '" << CacheEntryPath
1200 <<
"': " << EC.message() <<
"\n";
1202 OutputBuffer =
std::move(*ReloadedBufferOrErr);
1209 count, CacheEntryPath, *OutputBuffer);
cl::opt< std::string > RemarksPasses("lto-pass-remarks-filter", cl::desc("Only record optimization remarks from passes whose " "names match the given regular expression"), cl::value_desc("regex"))
void enableDebugTypeODRUniquing()
void promote(Module &Module, ModuleSummaryIndex &Index, const lto::InputFile &File)
Perform promotion and renaming of exported internal functions, and additionally resolve weak and link...
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
CodeGenOpt::Level CGOptLevel
This is an optimization pass for GlobalISel generic memory operations.
Error handleErrors(Error E, HandlerTs &&... Hs)
Pass the ErrorInfo(s) contained in E to their respective handlers.
void reportAndResetTimings(raw_ostream *OutStream=nullptr)
If -time-passes has been specified, report the timings immediately and then reset the timers to zero.
void run()
Process all the modules that were added to the code generator in parallel.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
static const OptimizationLevel O1
Optimize quickly without destroying debuggability.
void crossReferenceSymbol(StringRef Name)
Adds to a list of all global symbols that are cross-referenced between ThinLTO files.
void thinLTOInternalizeModule(Module &TheModule, const GVSummaryMapTy &DefinedGlobals)
Internalize TheModule based on the information recorded in the summaries during global summary-based ...
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatile=false)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e....
std::string writeGeneratedObject(int count, StringRef CacheEntryPath, const MemoryBuffer &OutputBuffer)
Write temporary object file to SavedObjectDirectoryPath, write symlink to Cache directory if needed.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
A ThreadPool for asynchronous parallel execution on a defined number of threads.
void computeLTOCacheKey(SmallString< 40 > &Key, const lto::Config &Conf, const ModuleSummaryIndex &Index, StringRef ModuleID, const FunctionImporter::ImportMapTy &ImportList, const FunctionImporter::ExportSetTy &ExportList, const std::map< GlobalValue::GUID, GlobalValue::LinkageTypes > &ResolvedODR, const GVSummaryMapTy &DefinedGlobals, const std::set< GlobalValue::GUID > &CfiFunctionDefs={}, const std::set< GlobalValue::GUID > &CfiFunctionDecls={})
Computes a unique hash for the Module considering the current list of export/import and other global ...
CodeGenOpt::Level CGOptLevel
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT &&Pass)
bool renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, bool ClearDSOLocalOnDeclarations, SetVector< GlobalValue * > *GlobalsToImport=nullptr)
Perform in-place global value handling on the given Module for exported local functions renamed and p...
static const OptimizationLevel O2
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs)
Target - Wrapper for Target specific information.
void runWholeProgramDevirtOnIndex(ModuleSummaryIndex &Summary, std::set< GlobalValue::GUID > &ExportedGUIDs, std::map< ValueInfo, std::vector< VTableSlotSummary >> &LocalWPDTargetsMap)
Perform index-based whole program devirtualization on the Summary index.
cl::opt< std::string > RemarksFilename("lto-pass-remarks-output", cl::desc("Output filename for pass remarks"), cl::value_desc("filename"))
void registerCallbacks(PassInstrumentationCallbacks &PIC, FunctionAnalysisManager *FAM=nullptr)
Tunable parameters for passes in the default pipelines.
Helper to gather options relevant to the target machine creation.
Triple - Helper class for working with autoconf configuration names.
FunctionAnalysisManager FAM
CachePruningPolicy Policy
ThreadPoolStrategy heavyweight_hardware_concurrency(unsigned ThreadCount=0)
Returns a thread strategy for tasks requiring significant memory or other resources.
void crossModuleImport(Module &Module, ModuleSummaryIndex &Index, const lto::InputFile &File)
Perform cross-module importing for the module identified by ModuleIdentifier.
cl::opt< Optional< uint64_t >, false, remarks::HotnessThresholdParser > RemarksHotnessThreshold("lto-pass-remarks-hotness-threshold", cl::desc("Minimum profile count required for an " "optimization remark to be output." " Use 'auto' to apply the threshold from profile summary."), cl::value_desc("uint or 'auto'"), cl::init(0), cl::Hidden)
PassInstrumentationCallbacks PIC
void emitImports(Module &Module, StringRef OutputName, ModuleSummaryIndex &Index, const lto::InputFile &File)
Compute and emit the imported files for module at ModulePath.
bool Freestanding
Flag to indicate that the optimizer should not assume builtins are present on the target.
Implementation of the target library information.
cl::opt< bool > RemarksWithHotness("lto-pass-remarks-with-hotness", cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
std::pair< typename Base::iterator, bool > insert(StringRef key)
The function importer is automatically importing function from other modules based on the provided su...
Expected< std::unique_ptr< ToolOutputFile > > setupLLVMOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, Optional< uint64_t > RemarksHotnessThreshold=0, int Count=-1)
Setup optimization remarks.
Tagged union holding either a T or a Error.
std::string merge(const Triple &Other) const
Merge target triples.
void thinLTOResolvePrevailingInIndex(const lto::Config &C, ModuleSummaryIndex &Index, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, function_ref< void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)> recordNewLinkage, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols)
Resolve linkage for prevailing symbols in the Index.
LinkageTypes
An enumeration for the kinds of linkage for global values.
iterator find(StringRef Key)
void gatherImportedSummariesForModule(StringRef ModulePath, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, const FunctionImporter::ImportMapTy &ImportList, std::map< std::string, GVSummaryMapTy > &ModuleToSummariesForIndex)
Compute the set of summaries needed for a ThinLTO backend compilation of ModulePath.
std::pair< iterator, bool > insert(const ValueT &V)
static const OptimizationLevel O0
Disable as many optimizations as possible.
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
void consumeError(Error Err)
Consume a Error without doing anything.
std::error_code EmitImportsFiles(StringRef ModulePath, StringRef OutputFilename, const std::map< std::string, GVSummaryMapTy > &ModuleToSummariesForIndex)
Emit into OutputFilename the files module ModulePath will import from.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Function and variable summary information to aid decisions and implementation of importing.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool AreStatisticsEnabled()
Check if statistics are enabled.
llvm::Error writeFileAtomically(StringRef TempPathModel, StringRef FinalPath, StringRef Buffer)
Creates a unique file with name according to the given TempPathModel, writes content of Buffer to the...
const std::string & str() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, or DriverKit).
void internalize(Module &Module, ModuleSummaryIndex &Index, const lto::InputFile &File)
Perform internalization.
void timeTraceProfilerBegin(StringRef Name, StringRef Detail)
Manually begin a time section, with the given Name and Detail.
cl::opt< bool > LTODiscardValueNames("lto-discard-value-names", cl::desc("Strip names from Value during LTO (other than GlobalValue)."), cl::init(false), cl::Hidden)
ModuleAnalysisManager MAM
This class provides access to building LLVM's passes.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Manages the enabling and disabling of subtarget specific features.
void computeSyntheticCounts(ModuleSummaryIndex &Index)
Compute synthetic function entry counts.
void thinLTOInternalizeAndPromoteInIndex(ModuleSummaryIndex &Index, function_ref< bool(StringRef, ValueInfo)> isExported, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing)
Update the linkages in the given Index to mark exported values as external and non-exported values as...
LLVM_NODISCARD detail::scope_exit< typename std::decay< Callable >::type > make_scope_exit(Callable &&F)
std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
void thinLTOFinalizeInModule(Module &TheModule, const GVSummaryMapTy &DefinedGlobals, bool PropagateAttrs)
Based on the information recorded in the summaries during global summary-based analysis:
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Expected< file_t > openNativeFileForRead(const Twine &Name, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)
Opens the file with the given name in a read-only mode, returning its open file descriptor.
StringRef getArchName() const
Get the architecture (first) component of the triple.
StringRef getBuffer() const
This is the base abstract class for diagnostic reporting in the backend.
Interface for custom diagnostic printing.
ArchType getArch() const
Get the parsed architecture type of this triple.
void getDefaultSubtargetFeatures(const Triple &Triple)
Adds the default features for the specified target triple.
Base class for error info classes.
std::error_code create_hard_link(const Twine &to, const Twine &from)
Create a hard link from from to to, or return an error.
void preserveSymbol(StringRef Name)
Adds to a list of all global symbols that must exist in the final generated code.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Struct that holds a reference to a particular GUID in a global value summary.
cl::opt< std::string > RemarksFormat("lto-pass-remarks-format", cl::desc("The format used for serializing remarks (default: YAML)"), cl::value_desc("format"), cl::init("yaml"))
static void computeDeadSymbolsInIndex(ModuleSummaryIndex &Index, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols)
Analysis providing profile information.
void updateVCallVisibilityInIndex(ModuleSummaryIndex &Index, bool WholeProgramVisibilityEnabledInLTO, const DenseSet< GlobalValue::GUID > &DynamicExportSymbols)
If whole program visibility asserted, then upgrade all public vcall visibility metadata on vtable def...
PassBuilder PB(Machine, PassOpts->PTO, None, &PIC)
bool isWeakForLinker() const
std::string getString() const
Returns features as a string.
Implements a dense probed hash-table based set.
StringRef getName() const
Get a short "name" for the module.
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
This class provides an interface to register all the standard pass instrumentations and manages their...
bool exists(const basic_file_status &status)
Does file exist?
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
void computeDeadSymbolsWithConstProp(ModuleSummaryIndex &Index, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols, function_ref< PrevailingType(GlobalValue::GUID)> isPrevailing, bool ImportEnabled)
Compute dead symbols and run constant propagation in combined index after that.
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
This is an important class for using LLVM in a threaded context.
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build an ThinLTO default optimization pipeline to a pass manager.
initializer< Ty > init(const Ty &Val)
void gatherImportedSummariesForModule(Module &Module, ModuleSummaryIndex &Index, std::map< std::string, GVSummaryMapTy > &ModuleToSummariesForIndex, const lto::InputFile &File)
Compute the list of summaries needed for importing into module.
iterator find(const_arg_type_t< KeyT > Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Primary interface to the complete machine description for the target machine.
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
StandardInstrumentations SI(Debug, VerifyEach)
static const char * PreservedSymbols[]
std::error_code closeFile(file_t &F)
Close the file object.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
void updateIndexWPDForExports(ModuleSummaryIndex &Summary, function_ref< bool(StringRef, ValueInfo)> isExported, std::map< ValueInfo, std::vector< VTableSlotSummary >> &LocalWPDTargetsMap)
Call after cross-module importing to update the recorded single impl devirt target names for any loca...
std::vector< std::string > MAttrs
static bool isAvailableExternallyLinkage(LinkageTypes Linkage)
A Module instance is used to store all the information related to an LLVM module.
void PrintStatistics()
Print statistics to the file returned by CreateInfoOutputFile().
void WriteBitcodeToFile(const Module &M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
Write the specified module to the specified raw output stream.
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
StringSet - A wrapper for StringMap that provides set-like functionality.
Optional< Reloc::Model > RelocModel
StringRef - Represent a constant reference to a string, i.e.
So we should use XX3Form_Rcr to implement intrinsic Convert DP outs ins xscvdpsp No builtin are required Round &Convert QP DP(dword[1] is set to zero) No builtin are required Round to Quad Precision because you need to assign rounding mode in instruction Provide builtin(set f128:$vT,(int_ppc_vsx_xsrqpi f128:$vB))(set f128 yields< n x< ty > >< result > yields< ty >< result > No builtin are required Load Store load store see def memrix16 in PPCInstrInfo td Load Store Vector load store outs ins lxsdx set load store with conversion from to DP
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
auto async(Function &&F, Args &&...ArgList)
Asynchronous submission of a task to the pool.
reference get()
Returns a reference to the stored T value.
std::unique_ptr< ModuleSummaryIndex > linkCombinedIndex()
Produce the combined summary index from all the bitcode files: "thin-link".
static const OptimizationLevel O3
Optimize for fast execution as much as possible.
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Linkage
Describes symbol linkage.
A raw_ostream that writes to a file descriptor.
@ OF_UpdateAtime
Force files Atime to be updated on access.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
const CustomOperand< const MCSubtargetInfo & > Msg[]
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
std::vector< std::unique_ptr< GlobalValueSummary > > GlobalValueSummaryList
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void writeIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, const std::map< std::string, GVSummaryMapTy > *ModuleToSummariesForIndex=nullptr)
Write the specified module summary index to the given raw output stream, where it will be written in ...
const char * toString(DWARFSectionKind Kind)
void optimize(Module &Module)
Perform post-importing ThinLTO optimizations.
Lightweight error class with error context and mandatory checking.
PassManager manages ModulePassManagers.
bool thinLTOPropagateFunctionAttrs(ModuleSummaryIndex &Index, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing)
Propagate function attributes for function summaries along the index's callgraph during thinlink.
bool timeTraceProfilerEnabled()
Is the time trace profiler enabled, i.e. initialized?
LLVMContext & getContext() const
Get the global data context.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
void setDiscardValueNames(bool Discard)
Set the Context runtime configuration to discard all value name (but GlobalValue).
std::unique_ptr< TargetMachine > create() const
ModuleSummaryIndex buildModuleSummaryIndex(const Module &M, std::function< BlockFrequencyInfo *(const Function &F)> GetBFICallback, ProfileSummaryInfo *PSI, std::function< const StackSafetyInfo *(const Function &F)> GetSSICallback=[](const Function &F) -> const StackSafetyInfo *{ return nullptr;})
Direct function to compute a ModuleSummaryIndex from a given module.
bool is_directory(const basic_file_status &status)
Does status represent a directory?
void add(Pass *P) override
Add a pass to the queue of passes to run.
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
StringRef str() const
Explicit conversion to StringRef.
PIELevel::Level getPIELevel() const
Returns the PIE level (small or large model)
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs... ExtraArgs)
Run all of the passes in this manager over the given unit of IR.
@ ExternalLinkage
Externally visible function.
std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
Optional< Reloc::Model > RelocModel
Error takeError()
Take ownership of the stored error.
std::vector< int > generateModulesOrdering(ArrayRef< BitcodeModule * > R)
Produces a container ordering for optimal multi-threaded processing.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM)
Cross register the analysis managers through their proxies.
Represents either an error or a value T.
A raw_ostream that writes to an SmallVector or SmallString.
void remove_filename(SmallVectorImpl< char > &path, Style style=Style::native)
Remove the last component from path unless it is the root dir.
bool run(Module &M)
run - Execute all of the passes scheduled for execution.
void ComputeCrossModuleImport(const ModuleSummaryIndex &Index, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, StringMap< FunctionImporter::ImportMapTy > &ImportLists, StringMap< FunctionImporter::ExportSetTy > &ExportLists)
Compute all the imports and exports for every module in the Index.
void timeTraceProfilerEnd()
Manually end the last time section.
A container for analyses that lazily runs them and caches their results.
const char LLVMTargetMachineRef TM
bool pruneCache(StringRef Path, CachePruningPolicy Policy)
Peform pruning using the supplied policy, returns true if pruning occurred, i.e.
Pass * createObjCARCContractPass()
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
CGSCCAnalysisManager CGAM
Analysis pass providing the TargetLibraryInfo.
std::error_code copy_file(const Twine &From, const Twine &To)
Copy the contents of From to To.
bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM=None, CodeGenOpt::Level OL=CodeGenOpt::Default, bool JIT=false) const
createTargetMachine - Create a target specific machine implementation for the specified Triple.