Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
LTOCodeGenerator.cpp
Go to the documentation of this file.
1//===-LTOCodeGenerator.cpp - LLVM Link Time Optimizer ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the Link Time Optimization library. This library is
10// intended to be used by linker to optimize code at link time.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/LTO/legacy/LTOCodeGenerator.h"
15
16#include "llvm/ADT/Statistic.h"
17#include "llvm/ADT/StringExtras.h"
18#include "llvm/Analysis/Passes.h"
19#include "llvm/Analysis/TargetLibraryInfo.h"
20#include "llvm/Analysis/TargetTransformInfo.h"
21#include "llvm/Bitcode/BitcodeWriter.h"
22#include "llvm/CodeGen/CommandFlags.h"
23#include "llvm/CodeGen/TargetSubtargetInfo.h"
24#include "llvm/Config/config.h"
25#include "llvm/IR/Constants.h"
26#include "llvm/IR/DataLayout.h"
27#include "llvm/IR/DebugInfo.h"
28#include "llvm/IR/DerivedTypes.h"
29#include "llvm/IR/DiagnosticInfo.h"
30#include "llvm/IR/DiagnosticPrinter.h"
31#include "llvm/IR/LLVMContext.h"
32#include "llvm/IR/LLVMRemarkStreamer.h"
33#include "llvm/IR/LegacyPassManager.h"
34#include "llvm/IR/Mangler.h"
35#include "llvm/IR/Module.h"
36#include "llvm/IR/PassTimingInfo.h"
37#include "llvm/IR/Verifier.h"
38#include "llvm/LTO/LTO.h"
39#include "llvm/LTO/LTOBackend.h"
40#include "llvm/LTO/legacy/LTOModule.h"
41#include "llvm/LTO/legacy/UpdateCompilerUsed.h"
42#include "llvm/Linker/Linker.h"
43#include "llvm/MC/MCAsmInfo.h"
44#include "llvm/MC/MCContext.h"
45#include "llvm/MC/TargetRegistry.h"
46#include "llvm/Remarks/HotnessThresholdParser.h"
47#include "llvm/Support/CommandLine.h"
48#include "llvm/Support/FileSystem.h"
49#include "llvm/Support/MemoryBuffer.h"
50#include "llvm/Support/Process.h"
51#include "llvm/Support/Signals.h"
52#include "llvm/Support/TargetSelect.h"
53#include "llvm/Support/ToolOutputFile.h"
54#include "llvm/Support/YAMLTraits.h"
55#include "llvm/Support/raw_ostream.h"
56#include "llvm/Target/TargetOptions.h"
57#include "llvm/TargetParser/Host.h"
58#include "llvm/TargetParser/SubtargetFeature.h"
59#include "llvm/Transforms/IPO.h"
60#include "llvm/Transforms/IPO/Internalize.h"
61#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
62#include "llvm/Transforms/ObjCARC.h"
63#include "llvm/Transforms/Utils/ModuleUtils.h"
64#include <optional>
65#include <system_error>
66using namespacellvm;
67
68constchar*LTOCodeGenerator::getVersionString() {
69return PACKAGE_NAME" version " PACKAGE_VERSION;
70}
71
72namespacellvm {
73cl::opt<bool>LTODiscardValueNames(
74"lto-discard-value-names",
75cl::desc("Strip names from Value during LTO (other than GlobalValue)."),
76#ifdefNDEBUG
77cl::init(true),
78#else
79cl::init(false),
80#endif
81cl::Hidden);
82
83cl::opt<bool>RemarksWithHotness(
84"lto-pass-remarks-with-hotness",
85cl::desc("With PGO, include profile count in optimization remarks"),
86cl::Hidden);
87
88cl::opt<std::optional<uint64_t>,false,remarks::HotnessThresholdParser>
89RemarksHotnessThreshold(
90"lto-pass-remarks-hotness-threshold",
91cl::desc("Minimum profile count required for an "
92"optimization remark to be output."
93" Use 'auto' to apply the threshold from profile summary."),
94cl::value_desc("uint or 'auto'"),cl::init(0),cl::Hidden);
95
96cl::opt<std::string>
97RemarksFilename("lto-pass-remarks-output",
98cl::desc("Output filename for pass remarks"),
99cl::value_desc("filename"));
100
101cl::opt<std::string>
102RemarksPasses("lto-pass-remarks-filter",
103cl::desc("Only record optimization remarks from passes whose "
104"names match the given regular expression"),
105cl::value_desc("regex"));
106
107cl::opt<std::string>RemarksFormat(
108"lto-pass-remarks-format",
109cl::desc("The format used for serializing remarks (default: YAML)"),
110cl::value_desc("format"),cl::init("yaml"));
111
112cl::opt<std::string>LTOStatsFile(
113"lto-stats-file",
114cl::desc("Save statistics to the specified file"),
115cl::Hidden);
116
117cl::opt<std::string>AIXSystemAssemblerPath(
118"lto-aix-system-assembler",
119cl::desc("Path to a system assembler, picked up on AIX only"),
120cl::value_desc("path"));
121
122cl::opt<bool>
123LTORunCSIRInstr("cs-profile-generate",
124cl::desc("Perform context sensitive PGO instrumentation"));
125
126cl::opt<std::string>
127LTOCSIRProfile("cs-profile-path",
128cl::desc("Context sensitive profile file path"));
129}// namespace llvm
130
131LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context)
132 : Context(Context), MergedModule(newModule("ld-temp.o", Context)),
133 TheLinker(newLinker(*MergedModule)) {
134 Context.setDiscardValueNames(LTODiscardValueNames);
135 Context.enableDebugTypeODRUniquing();
136
137 Config.CodeModel = std::nullopt;
138 Config.StatsFile =LTOStatsFile;
139 Config.RunCSIRInstr =LTORunCSIRInstr;
140 Config.CSIRProfile =LTOCSIRProfile;
141}
142
143LTOCodeGenerator::~LTOCodeGenerator() =default;
144
145voidLTOCodeGenerator::setAsmUndefinedRefs(LTOModule *Mod) {
146for (constStringRef &Undef :Mod->getAsmUndefinedRefs())
147 AsmUndefinedRefs.insert(Undef);
148}
149
150boolLTOCodeGenerator::addModule(LTOModule *Mod) {
151assert(&Mod->getModule().getContext() == &Context &&
152"Expected module in same context");
153
154bool ret = TheLinker->linkInModule(Mod->takeModule());
155setAsmUndefinedRefs(Mod);
156
157// We've just changed the input, so let's make sure we verify it.
158 HasVerifiedInput =false;
159
160return !ret;
161}
162
163voidLTOCodeGenerator::setModule(std::unique_ptr<LTOModule>Mod) {
164assert(&Mod->getModule().getContext() == &Context &&
165"Expected module in same context");
166
167 AsmUndefinedRefs.clear();
168
169 MergedModule =Mod->takeModule();
170 TheLinker = std::make_unique<Linker>(*MergedModule);
171setAsmUndefinedRefs(&*Mod);
172
173// We've just changed the input, so let's make sure we verify it.
174 HasVerifiedInput =false;
175}
176
177voidLTOCodeGenerator::setTargetOptions(constTargetOptions &Options) {
178 Config.Options =Options;
179}
180
181voidLTOCodeGenerator::setDebugInfo(lto_debug_modelDebug) {
182switch (Debug) {
183caseLTO_DEBUG_MODEL_NONE:
184 EmitDwarfDebugInfo =false;
185return;
186
187caseLTO_DEBUG_MODEL_DWARF:
188 EmitDwarfDebugInfo =true;
189return;
190 }
191llvm_unreachable("Unknown debug format!");
192}
193
194voidLTOCodeGenerator::setOptLevel(unsigned Level) {
195 Config.OptLevel = Level;
196 Config.PTO.LoopVectorization = Config.OptLevel > 1;
197 Config.PTO.SLPVectorization = Config.OptLevel > 1;
198 std::optional<CodeGenOptLevel> CGOptLevelOrNone =
199CodeGenOpt::getLevel(Config.OptLevel);
200assert(CGOptLevelOrNone &&"Unknown optimization level!");
201 Config.CGOptLevel = *CGOptLevelOrNone;
202}
203
204boolLTOCodeGenerator::writeMergedModules(StringRef Path) {
205if (!determineTarget())
206returnfalse;
207
208// We always run the verifier once on the merged module.
209 verifyMergedModuleOnce();
210
211// mark which symbols can not be internalized
212 applyScopeRestrictions();
213
214// create output file
215 std::error_code EC;
216ToolOutputFile Out(Path, EC,sys::fs::OF_None);
217if (EC) {
218 std::string ErrMsg ="could not open bitcode file for writing: ";
219 ErrMsg += Path.str() +": " + EC.message();
220 emitError(ErrMsg);
221returnfalse;
222 }
223
224// write bitcode to it
225WriteBitcodeToFile(*MergedModule, Out.os(), ShouldEmbedUselists);
226 Out.os().close();
227
228if (Out.os().has_error()) {
229 std::string ErrMsg ="could not write bitcode file: ";
230 ErrMsg += Path.str() +": " + Out.os().error().message();
231 emitError(ErrMsg);
232 Out.os().clear_error();
233returnfalse;
234 }
235
236 Out.keep();
237returntrue;
238}
239
240bool LTOCodeGenerator::useAIXSystemAssembler() {
241constauto &Triple = TargetMach->getTargetTriple();
242returnTriple.isOSAIX() && Config.Options.DisableIntegratedAS;
243}
244
245bool LTOCodeGenerator::runAIXSystemAssembler(SmallString<128> &AssemblyFile) {
246assert(useAIXSystemAssembler() &&
247"Runing AIX system assembler when integrated assembler is available!");
248
249// Set the system assembler path.
250SmallString<256> AssemblerPath("/usr/bin/as");
251if (!llvm::AIXSystemAssemblerPath.empty()) {
252if (llvm::sys::fs::real_path(llvm::AIXSystemAssemblerPath, AssemblerPath,
253/* expand_tilde */true)) {
254 emitError(
255"Cannot find the assembler specified by lto-aix-system-assembler");
256returnfalse;
257 }
258 }
259
260// Setup the LDR_CNTRL variable
261 std::string LDR_CNTRL_var ="LDR_CNTRL=MAXDATA32=0xA0000000@DSA";
262if (std::optional<std::string> V =sys::Process::GetEnv("LDR_CNTRL"))
263 LDR_CNTRL_var += ("@" + *V);
264
265// Prepare inputs for the assember.
266constauto &Triple = TargetMach->getTargetTriple();
267constchar *Arch =Triple.isArch64Bit() ?"-a64" :"-a32";
268 std::string ObjectFileName(AssemblyFile);
269 ObjectFileName[ObjectFileName.size() - 1] ='o';
270SmallVector<StringRef, 8>Args = {
271"/bin/env", LDR_CNTRL_var,
272 AssemblerPath, Arch,
273"-many","-o",
274 ObjectFileName,AssemblyFile};
275
276// Invoke the assembler.
277int RC =sys::ExecuteAndWait(Args[0], Args);
278
279// Handle errors.
280if (RC < -1) {
281 emitError("LTO assembler exited abnormally");
282returnfalse;
283 }
284if (RC < 0) {
285 emitError("Unable to invoke LTO assembler");
286returnfalse;
287 }
288if (RC > 0) {
289 emitError("LTO assembler invocation returned non-zero");
290returnfalse;
291 }
292
293// Cleanup.
294remove(AssemblyFile.c_str());
295
296// Fix the output file name.
297AssemblyFile = ObjectFileName;
298
299returntrue;
300}
301
302bool LTOCodeGenerator::compileOptimizedToFile(constchar **Name) {
303if (useAIXSystemAssembler())
304setFileType(CodeGenFileType::AssemblyFile);
305
306// make unique temp output file to put generated code
307SmallString<128>Filename;
308
309auto AddStream =
310 [&](size_t Task,
311constTwine &ModuleName) -> std::unique_ptr<CachedFileStream> {
312StringRefExtension(
313 Config.CGFileType ==CodeGenFileType::AssemblyFile ?"s" :"o");
314
315int FD;
316 std::error_codeEC =
317sys::fs::createTemporaryFile("lto-llvm",Extension, FD, Filename);
318if (EC)
319 emitError(EC.message());
320
321return std::make_unique<CachedFileStream>(
322 std::make_unique<llvm::raw_fd_ostream>(FD,true));
323 };
324
325bool genResult =compileOptimized(AddStream, 1);
326
327if (!genResult) {
328sys::fs::remove(Twine(Filename));
329returnfalse;
330 }
331
332// If statistics were requested, save them to the specified file or
333// print them out after codegen.
334if (StatsFile)
335PrintStatisticsJSON(StatsFile->os());
336elseif (AreStatisticsEnabled())
337PrintStatistics();
338
339if (useAIXSystemAssembler())
340if (!runAIXSystemAssembler(Filename))
341returnfalse;
342
343 NativeObjectPath =Filename.c_str();
344 *Name = NativeObjectPath.c_str();
345returntrue;
346}
347
348std::unique_ptr<MemoryBuffer>
349LTOCodeGenerator::compileOptimized() {
350constchar *name;
351if (!compileOptimizedToFile(&name))
352returnnullptr;
353
354// read .o file into memory buffer
355ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =MemoryBuffer::getFile(
356name,/*IsText=*/false,/*RequiresNullTerminator=*/false);
357if (std::error_code EC = BufferOrErr.getError()) {
358 emitError(EC.message());
359sys::fs::remove(NativeObjectPath);
360returnnullptr;
361 }
362
363// remove temp files
364sys::fs::remove(NativeObjectPath);
365
366return std::move(*BufferOrErr);
367}
368
369boolLTOCodeGenerator::compile_to_file(constchar **Name) {
370if (!optimize())
371returnfalse;
372
373return compileOptimizedToFile(Name);
374}
375
376std::unique_ptr<MemoryBuffer>LTOCodeGenerator::compile() {
377if (!optimize())
378returnnullptr;
379
380returncompileOptimized();
381}
382
383bool LTOCodeGenerator::determineTarget() {
384if (TargetMach)
385returntrue;
386
387 TripleStr = MergedModule->getTargetTriple();
388if (TripleStr.empty()) {
389 TripleStr =sys::getDefaultTargetTriple();
390 MergedModule->setTargetTriple(TripleStr);
391 }
392llvm::TripleTriple(TripleStr);
393
394// create target machine from info for merged modules
395 std::string ErrMsg;
396 MArch =TargetRegistry::lookupTarget(TripleStr, ErrMsg);
397if (!MArch) {
398 emitError(ErrMsg);
399returnfalse;
400 }
401
402// Construct LTOModule, hand over ownership of module and target. Use MAttr as
403// the default set of features.
404SubtargetFeatures Features(join(Config.MAttrs,""));
405 Features.getDefaultSubtargetFeatures(Triple);
406 FeatureStr = Features.getString();
407if (Config.CPU.empty())
408 Config.CPU =lto::getThinLTODefaultCPU(Triple);
409
410// If data-sections is not explicitly set or unset, set data-sections by
411// default to match the behaviour of lld and gold plugin.
412if (!codegen::getExplicitDataSections())
413 Config.Options.DataSections =true;
414
415 TargetMach = createTargetMachine();
416assert(TargetMach &&"Unable to create target machine");
417
418returntrue;
419}
420
421std::unique_ptr<TargetMachine> LTOCodeGenerator::createTargetMachine() {
422assert(MArch &&"MArch is not set!");
423return std::unique_ptr<TargetMachine>(MArch->createTargetMachine(
424 TripleStr, Config.CPU, FeatureStr, Config.Options, Config.RelocModel,
425 std::nullopt, Config.CGOptLevel));
426}
427
428// If a linkonce global is present in the MustPreserveSymbols, we need to make
429// sure we honor this. To force the compiler to not drop it, we add it to the
430// "llvm.compiler.used" global.
431void LTOCodeGenerator::preserveDiscardableGVs(
432Module &TheModule,
433llvm::function_ref<bool(constGlobalValue &)>mustPreserveGV) {
434 std::vector<GlobalValue *>Used;
435auto mayPreserveGlobal = [&](GlobalValue &GV) {
436if (!GV.isDiscardableIfUnused() || GV.isDeclaration() ||
437 !mustPreserveGV(GV))
438return;
439if (GV.hasAvailableExternallyLinkage())
440return emitWarning(
441 (Twine("Linker asked to preserve available_externally global: '") +
442 GV.getName() +"'").str());
443if (GV.hasInternalLinkage())
444return emitWarning((Twine("Linker asked to preserve internal global: '") +
445 GV.getName() +"'").str());
446Used.push_back(&GV);
447 };
448for (auto &GV : TheModule)
449 mayPreserveGlobal(GV);
450for (auto &GV : TheModule.globals())
451 mayPreserveGlobal(GV);
452for (auto &GV : TheModule.aliases())
453 mayPreserveGlobal(GV);
454
455if (Used.empty())
456return;
457
458appendToCompilerUsed(TheModule, Used);
459}
460
461void LTOCodeGenerator::applyScopeRestrictions() {
462if (ScopeRestrictionsDone)
463return;
464
465// Declare a callback for the internalize pass that will ask for every
466// candidate GlobalValue if it can be internalized or not.
467Mangler Mang;
468SmallString<64> MangledName;
469automustPreserveGV = [&](constGlobalValue &GV) ->bool {
470// Unnamed globals can't be mangled, but they can't be preserved either.
471if (!GV.hasName())
472returnfalse;
473
474// Need to mangle the GV as the "MustPreserveSymbols" StringSet is filled
475// with the linker supplied name, which on Darwin includes a leading
476// underscore.
477 MangledName.clear();
478 MangledName.reserve(GV.getName().size() + 1);
479 Mang.getNameWithPrefix(MangledName, &GV,/*CannotUsePrivateLabel=*/false);
480return MustPreserveSymbols.count(MangledName);
481 };
482
483// Preserve linkonce value on linker request
484 preserveDiscardableGVs(*MergedModule,mustPreserveGV);
485
486if (!ShouldInternalize)
487return;
488
489if (ShouldRestoreGlobalsLinkage) {
490// Record the linkage type of non-local symbols so they can be restored
491// prior
492// to module splitting.
493autoRecordLinkage = [&](constGlobalValue &GV) {
494if (!GV.hasAvailableExternallyLinkage() && !GV.hasLocalLinkage() &&
495 GV.hasName())
496 ExternalSymbols.insert(std::make_pair(GV.getName(), GV.getLinkage()));
497 };
498for (auto &GV : *MergedModule)
499RecordLinkage(GV);
500for (auto &GV : MergedModule->globals())
501RecordLinkage(GV);
502for (auto &GV : MergedModule->aliases())
503RecordLinkage(GV);
504 }
505
506// Update the llvm.compiler_used globals to force preserving libcalls and
507// symbols referenced from asm
508updateCompilerUsed(*MergedModule, *TargetMach, AsmUndefinedRefs);
509
510internalizeModule(*MergedModule,mustPreserveGV);
511
512 ScopeRestrictionsDone =true;
513}
514
515/// Restore original linkage for symbols that may have been internalized
516void LTOCodeGenerator::restoreLinkageForExternals() {
517if (!ShouldInternalize || !ShouldRestoreGlobalsLinkage)
518return;
519
520assert(ScopeRestrictionsDone &&
521"Cannot externalize without internalization!");
522
523if (ExternalSymbols.empty())
524return;
525
526autoexternalize = [this](GlobalValue &GV) {
527if (!GV.hasLocalLinkage() || !GV.hasName())
528return;
529
530autoI = ExternalSymbols.find(GV.getName());
531if (I == ExternalSymbols.end())
532return;
533
534 GV.setLinkage(I->second);
535 };
536
537llvm::for_each(MergedModule->functions(),externalize);
538llvm::for_each(MergedModule->globals(),externalize);
539llvm::for_each(MergedModule->aliases(),externalize);
540}
541
542void LTOCodeGenerator::verifyMergedModuleOnce() {
543// Only run on the first call.
544if (HasVerifiedInput)
545return;
546 HasVerifiedInput =true;
547
548bool BrokenDebugInfo =false;
549if (verifyModule(*MergedModule, &dbgs(), &BrokenDebugInfo))
550report_fatal_error("Broken module found, compilation aborted!");
551if (BrokenDebugInfo) {
552 emitWarning("Invalid debug info found, debug info will be stripped");
553StripDebugInfo(*MergedModule);
554 }
555}
556
557void LTOCodeGenerator::finishOptimizationRemarks() {
558if (DiagnosticOutputFile) {
559 DiagnosticOutputFile->keep();
560// FIXME: LTOCodeGenerator dtor is not invoked on Darwin
561 DiagnosticOutputFile->os().flush();
562 }
563}
564
565/// Optimize merged modules using various IPO passes
566boolLTOCodeGenerator::optimize() {
567if (!this->determineTarget())
568returnfalse;
569
570// libLTO parses options late, so re-set them here.
571 Context.setDiscardValueNames(LTODiscardValueNames);
572
573auto DiagFileOrErr =lto::setupLLVMOptimizationRemarks(
574 Context,RemarksFilename,RemarksPasses,RemarksFormat,
575RemarksWithHotness,RemarksHotnessThreshold);
576if (!DiagFileOrErr) {
577errs() <<"Error: " <<toString(DiagFileOrErr.takeError()) <<"\n";
578report_fatal_error("Can't get an output file for the remarks");
579 }
580 DiagnosticOutputFile = std::move(*DiagFileOrErr);
581
582// Setup output file to emit statistics.
583auto StatsFileOrErr =lto::setupStatsFile(LTOStatsFile);
584if (!StatsFileOrErr) {
585errs() <<"Error: " <<toString(StatsFileOrErr.takeError()) <<"\n";
586report_fatal_error("Can't get an output file for the statistics");
587 }
588 StatsFile = std::move(StatsFileOrErr.get());
589
590// Currently there is no support for enabling whole program visibility via a
591// linker option in the old LTO API, but this call allows it to be specified
592// via the internal option. Must be done before WPD invoked via the optimizer
593// pipeline run below.
594updatePublicTypeTestCalls(*MergedModule,
595/* WholeProgramVisibilityEnabledInLTO */false);
596updateVCallVisibilityInModule(
597 *MergedModule,
598/* WholeProgramVisibilityEnabledInLTO */false,
599// FIXME: These need linker information via a
600// TBD new interface.
601/*DynamicExportSymbols=*/{},
602/*ValidateAllVtablesHaveTypeInfos=*/false,
603/*IsVisibleToRegularObj=*/[](StringRef) {returntrue; });
604
605// We always run the verifier once on the merged module, the `DisableVerify`
606// parameter only applies to subsequent verify.
607 verifyMergedModuleOnce();
608
609// Mark which symbols can not be internalized
610 this->applyScopeRestrictions();
611
612// Add an appropriate DataLayout instance for this module...
613 MergedModule->setDataLayout(TargetMach->createDataLayout());
614
615if (!SaveIRBeforeOptPath.empty()) {
616 std::error_code EC;
617raw_fd_ostreamOS(SaveIRBeforeOptPath, EC,sys::fs::OF_None);
618if (EC)
619report_fatal_error(Twine("Failed to open ") + SaveIRBeforeOptPath +
620" to save optimized bitcode\n");
621WriteBitcodeToFile(*MergedModule,OS,
622/* ShouldPreserveUseListOrder */true);
623 }
624
625ModuleSummaryIndex CombinedIndex(false);
626 TargetMach = createTargetMachine();
627if (!opt(Config, TargetMach.get(), 0, *MergedModule,/*IsThinLTO=*/false,
628/*ExportSummary=*/&CombinedIndex,/*ImportSummary=*/nullptr,
629/*CmdArgs*/ std::vector<uint8_t>())) {
630 emitError("LTO middle-end optimizations failed");
631returnfalse;
632 }
633
634returntrue;
635}
636
637boolLTOCodeGenerator::compileOptimized(AddStreamFn AddStream,
638unsigned ParallelismLevel) {
639if (!this->determineTarget())
640returnfalse;
641
642// We always run the verifier once on the merged module. If it has already
643// been called in optimize(), this call will return early.
644 verifyMergedModuleOnce();
645
646// Re-externalize globals that may have been internalized to increase scope
647// for splitting
648 restoreLinkageForExternals();
649
650ModuleSummaryIndex CombinedIndex(false);
651
652 Config.CodeGenOnly =true;
653Error Err = backend(Config, AddStream, ParallelismLevel, *MergedModule,
654 CombinedIndex);
655assert(!Err &&"unexpected code-generation failure");
656 (void)Err;
657
658// If statistics were requested, save them to the specified file or
659// print them out after codegen.
660if (StatsFile)
661PrintStatisticsJSON(StatsFile->os());
662elseif (AreStatisticsEnabled())
663PrintStatistics();
664
665reportAndResetTimings();
666
667 finishOptimizationRemarks();
668
669returntrue;
670}
671
672voidLTOCodeGenerator::setCodeGenDebugOptions(ArrayRef<StringRef>Options) {
673for (StringRef Option :Options)
674 CodegenOptions.push_back(Option.str());
675}
676
677voidLTOCodeGenerator::parseCodeGenDebugOptions() {
678if (!CodegenOptions.empty())
679llvm::parseCommandLineOptions(CodegenOptions);
680}
681
682voidllvm::parseCommandLineOptions(std::vector<std::string> &Options) {
683if (!Options.empty()) {
684// ParseCommandLineOptions() expects argv[0] to be program name.
685 std::vector<const char *> CodegenArgv(1,"libLLVMLTO");
686for (std::string &Arg :Options)
687 CodegenArgv.push_back(Arg.c_str());
688cl::ParseCommandLineOptions(CodegenArgv.size(), CodegenArgv.data());
689 }
690}
691
692voidLTOCodeGenerator::DiagnosticHandler(constDiagnosticInfo &DI) {
693// Map the LLVM internal diagnostic severity to the LTO diagnostic severity.
694lto_codegen_diagnostic_severity_t Severity;
695switch (DI.getSeverity()) {
696caseDS_Error:
697 Severity =LTO_DS_ERROR;
698break;
699caseDS_Warning:
700 Severity =LTO_DS_WARNING;
701break;
702caseDS_Remark:
703 Severity =LTO_DS_REMARK;
704break;
705caseDS_Note:
706 Severity =LTO_DS_NOTE;
707break;
708 }
709// Create the string that will be reported to the external diagnostic handler.
710 std::string MsgStorage;
711raw_string_ostream Stream(MsgStorage);
712DiagnosticPrinterRawOStream DP(Stream);
713 DI.print(DP);
714 Stream.flush();
715
716// If this method has been called it means someone has set up an external
717// diagnostic handler. Assert on that.
718assert(DiagHandler &&"Invalid diagnostic handler");
719 (*DiagHandler)(Severity, MsgStorage.c_str(), DiagContext);
720}
721
722namespace{
723structLTODiagnosticHandler :publicDiagnosticHandler {
724LTOCodeGenerator *CodeGenerator;
725 LTODiagnosticHandler(LTOCodeGenerator *CodeGenPtr)
726 : CodeGenerator(CodeGenPtr) {}
727bool handleDiagnostics(constDiagnosticInfo &DI) override{
728 CodeGenerator->DiagnosticHandler(DI);
729returntrue;
730 }
731};
732}
733
734void
735LTOCodeGenerator::setDiagnosticHandler(lto_diagnostic_handler_tDiagHandler,
736void *Ctxt) {
737 this->DiagHandler = DiagHandler;
738 this->DiagContext = Ctxt;
739if (!DiagHandler)
740return Context.setDiagnosticHandler(nullptr);
741// Register the LTOCodeGenerator stub in the LLVMContext to forward the
742// diagnostic to the external DiagHandler.
743 Context.setDiagnosticHandler(std::make_unique<LTODiagnosticHandler>(this),
744true);
745}
746
747namespace{
748classLTODiagnosticInfo :publicDiagnosticInfo {
749constTwine &Msg;
750public:
751 LTODiagnosticInfo(constTwine &DiagMsg,DiagnosticSeverity Severity=DS_Error)
752 :DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
753voidprint(DiagnosticPrinter &DP) const override{ DP << Msg; }
754};
755}
756
757void LTOCodeGenerator::emitError(const std::string &ErrMsg) {
758if (DiagHandler)
759 (*DiagHandler)(LTO_DS_ERROR, ErrMsg.c_str(), DiagContext);
760else
761 Context.diagnose(LTODiagnosticInfo(ErrMsg));
762}
763
764void LTOCodeGenerator::emitWarning(const std::string &ErrMsg) {
765if (DiagHandler)
766 (*DiagHandler)(LTO_DS_WARNING, ErrMsg.c_str(), DiagContext);
767else
768 Context.diagnose(LTODiagnosticInfo(ErrMsg,DS_Warning));
769}
mustPreserveGV
static bool mustPreserveGV(const GlobalValue &GV)
Predicate for Internalize pass.
Definition:AMDGPUTargetMachine.cpp:730
opt
arm prera ldst opt
Definition:ARMLoadStoreOptimizer.cpp:2188
Passes.h
print
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Definition:ArchiveWriter.cpp:205
BitcodeWriter.h
CommandFlags.h
CommandLine.h
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DataLayout.h
Debug
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
Definition:Debug.cpp:108
DerivedTypes.h
DiagnosticInfo.h
DiagnosticPrinter.h
Name
std::string Name
Definition:ELFObjHandler.cpp:77
FileSystem.h
Host.h
HotnessThresholdParser.h
This file implements a simple parser to decode commandline option for remarks hotness threshold that ...
IPO.h
Module.h
Module.h This file contains the declarations for the Module class.
Internalize.h
LLVMContext.h
LLVMRemarkStreamer.h
LTOBackend.h
LTOCodeGenerator.h
LTOModule.h
LTO.h
Options
static LVOptions Options
Definition:LVOptions.cpp:25
LegacyPassManager.h
MCAsmInfo.h
MCContext.h
I
#define I(x, y, z)
Definition:MD5.cpp:58
Mangler.h
MemoryBuffer.h
ModuleUtils.h
PassTimingInfo.h
This header defines classes/functions to handle pass execution timing information with interfaces for...
Process.h
Provides a library for accessing information about this process and other processes on the operating ...
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
name
static const char * name
Definition:SMEABIPass.cpp:46
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
Signals.h
externalize
static void externalize(GlobalValue *GV)
Definition:SplitModule.cpp:221
Statistic.h
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
StringExtras.h
This file contains some functions that are useful when dealing with strings.
SubtargetFeature.h
TargetLibraryInfo.h
TargetOptions.h
TargetRegistry.h
TargetSelect.h
TargetSubtargetInfo.h
TargetTransformInfo.h
This pass exposes codegen information to IR-level passes.
DiagHandler
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
Definition:TextStub.cpp:1060
ToolOutputFile.h
UpdateCompilerUsed.h
Verifier.h
WholeProgramDevirt.h
YAMLTraits.h
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::DiagnosticInfo
This is the base abstract class for diagnostic reporting in the backend.
Definition:DiagnosticInfo.h:112
llvm::DiagnosticInfo::getSeverity
DiagnosticSeverity getSeverity() const
Definition:DiagnosticInfo.h:127
llvm::DiagnosticInfo::print
virtual void print(DiagnosticPrinter &DP) const =0
Print using the given DP a user-friendly message.
llvm::DiagnosticPrinterRawOStream
Basic diagnostic printer that uses an underlying raw_ostream.
Definition:DiagnosticPrinter.h:61
llvm::DiagnosticPrinter
Interface for custom diagnostic printing.
Definition:DiagnosticPrinter.h:31
llvm::ErrorOr
Represents either an error or a value T.
Definition:ErrorOr.h:56
llvm::ErrorOr::getError
std::error_code getError() const
Definition:ErrorOr.h:152
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition:Error.h:160
llvm::GlobalValue
Definition:GlobalValue.h:48
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::LLVMContext::enableDebugTypeODRUniquing
void enableDebugTypeODRUniquing()
Definition:LLVMContext.cpp:336
llvm::LLVMContext::diagnose
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Definition:LLVMContext.cpp:245
llvm::LLVMContext::setDiscardValueNames
void setDiscardValueNames(bool Discard)
Set the Context runtime configuration to discard all value name (but GlobalValue).
Definition:LLVMContext.cpp:345
llvm::LLVMContext::setDiagnosticHandler
void setDiagnosticHandler(std::unique_ptr< DiagnosticHandler > &&DH, bool RespectFilters=false)
setDiagnosticHandler - This method sets unique_ptr to object of DiagnosticHandler to provide custom d...
Definition:LLVMContext.cpp:127
llvm::Linker
This class provides the core functionality of linking in LLVM.
Definition:Linker.h:22
llvm::Mangler
Definition:Mangler.h:28
llvm::Mangler::getNameWithPrefix
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
Definition:Mangler.cpp:121
llvm::MemoryBuffer::getFile
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Definition:MemoryBuffer.cpp:260
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition:ModuleSummaryIndex.h:1345
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::PipelineTuningOptions::SLPVectorization
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
Definition:PassBuilder.h:58
llvm::PipelineTuningOptions::LoopVectorization
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
Definition:PassBuilder.h:54
llvm::SmallString
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition:SmallString.h:26
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition:SmallVector.h:663
llvm::SmallVectorImpl::clear
void clear()
Definition:SmallVector.h:610
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringMapImpl::empty
bool empty() const
Definition:StringMap.h:103
llvm::StringMap::clear
void clear()
Definition:StringMap.h:394
llvm::StringMap::end
iterator end()
Definition:StringMap.h:220
llvm::StringMap::find
iterator find(StringRef Key)
Definition:StringMap.h:233
llvm::StringMap::count
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition:StringMap.h:276
llvm::StringMap::insert
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition:StringMap.h:308
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringSet::insert
std::pair< typename Base::iterator, bool > insert(StringRef key)
Definition:StringSet.h:38
llvm::SubtargetFeatures
Manages the enabling and disabling of subtarget specific features.
Definition:SubtargetFeature.h:174
llvm::TargetOptions
Definition:TargetOptions.h:132
llvm::TargetOptions::DataSections
unsigned DataSections
Emit data into separate sections.
Definition:TargetOptions.h:270
llvm::TargetOptions::DisableIntegratedAS
unsigned DisableIntegratedAS
Disable the integrated assembler.
Definition:TargetOptions.h:264
llvm::Target::createTargetMachine
TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM=std::nullopt, CodeGenOptLevel OL=CodeGenOptLevel::Default, bool JIT=false) const
createTargetMachine - Create a target specific machine implementation for the specified Triple.
Definition:TargetRegistry.h:455
llvm::ToolOutputFile
This class contains a raw_fd_ostream and adds a few extra features commonly needed for compiler-like ...
Definition:ToolOutputFile.h:39
llvm::ToolOutputFile::keep
void keep()
Indicate that the tool's job wrt this output file has been successful and the file should not be dele...
Definition:ToolOutputFile.h:69
llvm::ToolOutputFile::os
raw_fd_ostream & os()
Return the contained raw_fd_ostream.
Definition:ToolOutputFile.h:62
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:Triple.h:44
llvm::Triple::isOSAIX
bool isOSAIX() const
Tests whether the OS is AIX.
Definition:Triple.h:741
llvm::Triple::isArch64Bit
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition:Triple.cpp:1734
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition:Twine.h:81
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition:STLFunctionalExtras.h:37
llvm::raw_fd_ostream
A raw_ostream that writes to a file descriptor.
Definition:raw_ostream.h:460
llvm::raw_fd_ostream::has_error
bool has_error() const
Return the value of the flag in this raw_fd_ostream indicating whether an output error has been encou...
Definition:raw_ostream.h:562
llvm::raw_fd_ostream::error
std::error_code error() const
Definition:raw_ostream.h:556
llvm::raw_fd_ostream::close
void close()
Manually flush the stream and close the file.
Definition:raw_ostream.cpp:804
llvm::raw_fd_ostream::clear_error
void clear_error()
Set the flag read by has_error() to false.
Definition:raw_ostream.h:573
llvm::raw_ostream::flush
void flush()
Definition:raw_ostream.h:198
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition:raw_ostream.h:661
llvm::remarks::HotnessThresholdParser
Definition:HotnessThresholdParser.h:46
llvm::sys::Process::GetEnv
static std::optional< std::string > GetEnv(StringRef name)
lto_debug_model
lto_debug_model
Definition:lto.h:79
lto_codegen_diagnostic_severity_t
lto_codegen_diagnostic_severity_t
Diagnostic severity.
Definition:lto.h:330
lto_diagnostic_handler_t
void(* lto_diagnostic_handler_t)(lto_codegen_diagnostic_severity_t severity, const char *diag, void *ctxt)
Diagnostic handler type.
Definition:lto.h:346
LTO_DEBUG_MODEL_DWARF
@ LTO_DEBUG_MODEL_DWARF
Definition:lto.h:81
LTO_DEBUG_MODEL_NONE
@ LTO_DEBUG_MODEL_NONE
Definition:lto.h:80
LTO_DS_REMARK
@ LTO_DS_REMARK
Definition:lto.h:333
LTO_DS_WARNING
@ LTO_DS_WARNING
Definition:lto.h:332
LTO_DS_NOTE
@ LTO_DS_NOTE
Definition:lto.h:334
LTO_DS_ERROR
@ LTO_DS_ERROR
Definition:lto.h:331
ObjCARC.h
DebugInfo.h
Linker.h
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition:AMDGPUMetadata.h:395
llvm::CodeGenOpt::getLevel
std::optional< CodeGenOptLevel > getLevel(int OL)
Get the Level identified by the integer OL.
Definition:CodeGen.h:65
llvm::M68k::MemAddrModeKind::V
@ V
llvm::MachO::RecordLinkage
RecordLinkage
Definition:Record.h:48
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Used
@ Used
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::ParseCommandLineOptions
bool ParseCommandLineOptions(int argc, const char *const *argv, StringRef Overview="", raw_ostream *Errs=nullptr, const char *EnvVar=nullptr, bool LongOptionsUseDoubleDash=false)
Definition:CommandLine.cpp:1444
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm::codegen::getExplicitDataSections
std::optional< bool > getExplicitDataSections()
llvm::codeview::CompileSym2Flags::EC
@ EC
llvm::logicalview::LVAttributeKind::Filename
@ Filename
llvm::lto::getThinLTODefaultCPU
StringLiteral getThinLTODefaultCPU(const Triple &TheTriple)
Definition:LTO.cpp:1721
llvm::lto::setupStatsFile
Expected< std::unique_ptr< ToolOutputFile > > setupStatsFile(StringRef StatsFilename)
Setups the output file for saving statistics.
Definition:LTO.cpp:2116
llvm::lto::setupLLVMOptimizationRemarks
Expected< std::unique_ptr< ToolOutputFile > > setupLLVMOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, std::optional< uint64_t > RemarksHotnessThreshold=0, int Count=-1)
Setup optimization remarks.
Definition:LTO.cpp:2091
llvm::sys::fs::real_path
std::error_code real_path(const Twine &path, SmallVectorImpl< char > &output, bool expand_tilde=false)
Collapse all .
llvm::sys::fs::OF_None
@ OF_None
Definition:FileSystem.h:750
llvm::sys::fs::remove
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
llvm::sys::fs::createTemporaryFile
std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None)
Create a file in the system temporary directory.
Definition:Path.cpp:863
llvm::sys::ExecuteAndWait
int ExecuteAndWait(StringRef Program, ArrayRef< StringRef > Args, std::optional< ArrayRef< StringRef > > Env=std::nullopt, ArrayRef< std::optional< StringRef > > Redirects={}, unsigned SecondsToWait=0, unsigned MemoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr, std::optional< ProcessStatistics > *ProcStat=nullptr, BitVector *AffinityMask=nullptr)
This function executes the program using the arguments provided.
Definition:Program.cpp:32
llvm::sys::getDefaultTargetTriple
std::string getDefaultTargetTriple()
getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produ...
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::RemarksFormat
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"))
Definition:ThinLTOCodeGenerator.cpp:85
llvm::for_each
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1732
llvm::LTODiscardValueNames
cl::opt< bool > LTODiscardValueNames("lto-discard-value-names", cl::desc("Strip names from Value during LTO (other than GlobalValue)."), cl::init(false), cl::Hidden)
Definition:ThinLTOCodeGenerator.cpp:79
llvm::WriteBitcodeToFile
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.
Definition:BitcodeWriter.cpp:5371
llvm::internalizeModule
bool internalizeModule(Module &TheModule, std::function< bool(const GlobalValue &)> MustPreserveGV)
Helper function to internalize functions and variables in a Module.
Definition:Internalize.h:77
llvm::LTOCSIRProfile
cl::opt< std::string > LTOCSIRProfile("cs-profile-path", cl::desc("Context sensitive profile file path"))
llvm::RemarksPasses
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"))
Definition:ThinLTOCodeGenerator.cpp:81
llvm::AddStreamFn
std::function< Expected< std::unique_ptr< CachedFileStream > >(unsigned Task, const Twine &ModuleName)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
Definition:Caching.h:42
llvm::updateCompilerUsed
void updateCompilerUsed(Module &TheModule, const TargetMachine &TM, const StringSet<> &AsmUndefinedRefs)
Find all globals in TheModule that are referenced in AsmUndefinedRefs, as well as the user-supplied f...
Definition:UpdateCompilerUsed.cpp:123
llvm::reportAndResetTimings
void reportAndResetTimings(raw_ostream *OutStream=nullptr)
If -time-passes has been specified, report the timings immediately and then reset the timers to zero.
Definition:PassTimingInfo.cpp:161
llvm::DK_Linker
@ DK_Linker
Definition:DiagnosticInfo.h:67
llvm::AIXSystemAssemblerPath
cl::opt< std::string > AIXSystemAssemblerPath("lto-aix-system-assembler", cl::desc("Path to a system assembler, picked up on AIX only"), cl::value_desc("path"))
llvm::updatePublicTypeTestCalls
void updatePublicTypeTestCalls(Module &M, bool WholeProgramVisibilityEnabledInLTO)
Definition:WholeProgramDevirt.cpp:886
llvm::CodeGenFileType::AssemblyFile
@ AssemblyFile
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition:Error.cpp:167
llvm::AreStatisticsEnabled
bool AreStatisticsEnabled()
Check if statistics are enabled.
Definition:Statistic.cpp:139
llvm::RemarksWithHotness
cl::opt< bool > RemarksWithHotness("lto-pass-remarks-with-hotness", cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden)
Definition:ThinLTOCodeGenerator.cpp:82
llvm::RemarksFilename
cl::opt< std::string > RemarksFilename("lto-pass-remarks-output", cl::desc("Output filename for pass remarks"), cl::value_desc("filename"))
Definition:ThinLTOCodeGenerator.cpp:80
llvm::parseCommandLineOptions
void parseCommandLineOptions(std::vector< std::string > &Options)
A convenience function that calls cl::ParseCommandLineOptions on the given set of options.
Definition:LTOCodeGenerator.cpp:682
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition:raw_ostream.cpp:907
llvm::StripDebugInfo
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
Definition:DebugInfo.cpp:608
llvm::ModRefInfo::Mod
@ Mod
The access may modify the value stored in memory.
llvm::PrintStatistics
void PrintStatistics()
Print statistics to the file returned by CreateInfoOutputFile().
Definition:Statistic.cpp:229
llvm::appendToCompilerUsed
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
Definition:ModuleUtils.cpp:161
llvm::DiagnosticSeverity
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
Definition:DiagnosticInfo.h:49
llvm::DS_Remark
@ DS_Remark
Definition:DiagnosticInfo.h:52
llvm::DS_Warning
@ DS_Warning
Definition:DiagnosticInfo.h:51
llvm::DS_Note
@ DS_Note
Definition:DiagnosticInfo.h:55
llvm::DS_Error
@ DS_Error
Definition:DiagnosticInfo.h:50
llvm::RemarksHotnessThreshold
cl::opt< std::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)
Definition:ThinLTOCodeGenerator.cpp:84
llvm::toString
const char * toString(DWARFSectionKind Kind)
Definition:DWARFUnitIndex.h:67
llvm::LTOStatsFile
cl::opt< std::string > LTOStatsFile("lto-stats-file", cl::desc("Save statistics to the specified file"), cl::Hidden)
llvm::PrintStatisticsJSON
void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.
Definition:Statistic.cpp:203
llvm::LTORunCSIRInstr
cl::opt< bool > LTORunCSIRInstr("cs-profile-generate", cl::desc("Perform context sensitive PGO instrumentation"))
llvm::updateVCallVisibilityInModule
void updateVCallVisibilityInModule(Module &M, bool WholeProgramVisibilityEnabledInLTO, const DenseSet< GlobalValue::GUID > &DynamicExportSymbols, bool ValidateAllVtablesHaveTypeInfos, function_ref< bool(StringRef)> IsVisibleToRegularObj)
If whole program visibility asserted, then upgrade all public vcall visibility metadata on vtable def...
Definition:WholeProgramDevirt.cpp:860
llvm::verifyModule
bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
Definition:Verifier.cpp:7312
raw_ostream.h
NDEBUG
#define NDEBUG
Definition:regutils.h:48
Extension
Definition:AArch64AsmParser.cpp:3727
ModuleName
Definition:ItaniumDemangle.h:1097
llvm::DiagnosticHandler
This is the base class for diagnostic handling in LLVM.
Definition:DiagnosticHandler.h:24
llvm::LTOCodeGenerator
C++ class which implements the opaque lto_code_gen_t type.
Definition:LTOCodeGenerator.h:72
llvm::LTOCodeGenerator::optimize
bool optimize()
Optimizes the merged module.
Definition:LTOCodeGenerator.cpp:566
llvm::LTOCodeGenerator::compile
std::unique_ptr< MemoryBuffer > compile()
As with compile_to_file(), this function compiles the merged module into single output file.
Definition:LTOCodeGenerator.cpp:376
llvm::LTOCodeGenerator::setModule
void setModule(std::unique_ptr< LTOModule > M)
Set the destination module.
Definition:LTOCodeGenerator.cpp:163
llvm::LTOCodeGenerator::compile_to_file
bool compile_to_file(const char **Name)
Compile the merged module into a single output file; the path to output file is returned to the calle...
Definition:LTOCodeGenerator.cpp:369
llvm::LTOCodeGenerator::parseCodeGenDebugOptions
void parseCodeGenDebugOptions()
Parse the options set in setCodeGenDebugOptions.
Definition:LTOCodeGenerator.cpp:677
llvm::LTOCodeGenerator::setOptLevel
void setOptLevel(unsigned OptLevel)
Definition:LTOCodeGenerator.cpp:194
llvm::LTOCodeGenerator::setAsmUndefinedRefs
void setAsmUndefinedRefs(struct LTOModule *)
Definition:LTOCodeGenerator.cpp:145
llvm::LTOCodeGenerator::setDiagnosticHandler
void setDiagnosticHandler(lto_diagnostic_handler_t, void *)
Definition:LTOCodeGenerator.cpp:735
llvm::LTOCodeGenerator::setFileType
void setFileType(CodeGenFileType FT)
Set the file type to be emitted (assembly or object code).
Definition:LTOCodeGenerator.h:97
llvm::LTOCodeGenerator::setTargetOptions
void setTargetOptions(const TargetOptions &Options)
Definition:LTOCodeGenerator.cpp:177
llvm::LTOCodeGenerator::setCodeGenDebugOptions
void setCodeGenDebugOptions(ArrayRef< StringRef > Opts)
Pass options to the driver and optimization passes.
Definition:LTOCodeGenerator.cpp:672
llvm::LTOCodeGenerator::LTOCodeGenerator
LTOCodeGenerator(LLVMContext &Context)
Definition:LTOCodeGenerator.cpp:131
llvm::LTOCodeGenerator::compileOptimized
std::unique_ptr< MemoryBuffer > compileOptimized()
Compiles the merged optimized module into a single output file.
Definition:LTOCodeGenerator.cpp:349
llvm::LTOCodeGenerator::addModule
bool addModule(struct LTOModule *)
Merge given module.
Definition:LTOCodeGenerator.cpp:150
llvm::LTOCodeGenerator::setDebugInfo
void setDebugInfo(lto_debug_model)
Definition:LTOCodeGenerator.cpp:181
llvm::LTOCodeGenerator::~LTOCodeGenerator
~LTOCodeGenerator()
llvm::LTOCodeGenerator::writeMergedModules
bool writeMergedModules(StringRef Path)
Write the merged module to the file specified by the given path.
Definition:LTOCodeGenerator.cpp:204
llvm::LTOCodeGenerator::DiagnosticHandler
void DiagnosticHandler(const DiagnosticInfo &DI)
Definition:LTOCodeGenerator.cpp:692
llvm::LTOCodeGenerator::getVersionString
static const char * getVersionString()
Definition:LTOCodeGenerator.cpp:68
llvm::LTOModule
C++ class which implements the opaque lto_module_t type.
Definition:LTOModule.h:38
llvm::TargetRegistry::lookupTarget
static const Target * lookupTarget(StringRef Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
Definition:TargetRegistry.cpp:154
llvm::cl::desc
Definition:CommandLine.h:409
llvm::cl::value_desc
Definition:CommandLine.h:418
llvm::lto::Config::StatsFile
std::string StatsFile
Statistics output file path.
Definition:Config.h:174
llvm::lto::Config::CodeModel
std::optional< CodeModel::Model > CodeModel
Definition:Config.h:56
llvm::lto::Config::CodeGenOnly
bool CodeGenOnly
Disable entirely the optimizer, including importing for ThinLTO.
Definition:Config.h:68
llvm::lto::Config::MAttrs
std::vector< std::string > MAttrs
Definition:Config.h:50
llvm::lto::Config::CGOptLevel
CodeGenOptLevel CGOptLevel
Definition:Config.h:57
llvm::lto::Config::PTO
PipelineTuningOptions PTO
Tunable parameters for passes in the default pipelines.
Definition:Config.h:198
llvm::lto::Config::CPU
std::string CPU
Definition:Config.h:48
llvm::lto::Config::Options
TargetOptions Options
Definition:Config.h:49
llvm::lto::Config::RunCSIRInstr
bool RunCSIRInstr
Run PGO context sensitive IR instrumentation.
Definition:Config.h:71
llvm::lto::Config::OptLevel
unsigned OptLevel
Definition:Config.h:59
llvm::lto::Config::CSIRProfile
std::string CSIRProfile
Context Sensitive PGO profile path.
Definition:Config.h:121
llvm::lto::Config::RelocModel
std::optional< Reloc::Model > RelocModel
Definition:Config.h:55
llvm::lto::Config::CGFileType
CodeGenFileType CGFileType
Definition:Config.h:58

Generated on Fri Jul 18 2025 11:43:17 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp