Lines Matching +full:- +full:- +full:with +full:- +full:config
1 //===- LTO.cpp ------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #include "Config.h"
22 #include "llvm/LTO/Config.h"
37 return lto::getThinLTOOutputFile(modulePath, config->thinLTOPrefixReplaceOld,
38 config->thinLTOPrefixReplaceNew);
41 static lto::Config createConfig() {
42 lto::Config c;
44 c.Options.EmitAddrsig = config->icfLevel == ICFLevel::safe;
45 for (StringRef C : config->mllvmOpts)
55 c.AlwaysEmitRegularLTOObj = !config->ltoObjPath.empty();
57 c.TimeTraceEnabled = config->timeTraceEnabled;
58 c.TimeTraceGranularity = config->timeTraceGranularity;
59 c.DebugPassManager = config->ltoDebugPassManager;
60 c.CSIRProfile = std::string(config->csProfilePath);
61 c.RunCSIRInstr = config->csProfileGenerate;
62 c.PGOWarnMismatch = config->pgoWarnMismatch;
63 c.OptLevel = config->ltoo;
64 c.CGOptLevel = config->ltoCgo;
65 if (config->saveTemps)
66 checkError(c.addSaveTemps(config->outputFile.str() + ".",
85 if (!config->thinLTOIndexOnlyArg.empty())
86 indexFile = openFile(config->thinLTOIndexOnlyArg);
91 if (config->thinLTOIndexOnly) {
93 std::string(config->thinLTOPrefixReplaceOld),
94 std::string(config->thinLTOPrefixReplaceNew),
95 std::string(config->thinLTOPrefixReplaceNativeObject),
96 config->thinLTOEmitImportsFiles, indexFile.get(), onIndexWrite);
99 llvm::heavyweight_hardware_concurrency(config->thinLTOJobs),
100 onIndexWrite, config->thinLTOEmitIndexFiles,
101 config->thinLTOEmitImportsFiles);
110 if (config->thinLTOEmitIndexFiles)
119 config->outputType != MH_EXECUTE || config->exportDynamic;
128 // flags an undefined in IR with a definition in ASM as prevailing.
131 r.Prevailing = !objSym.isUndefined() && sym->getFile() == &f;
135 defined->isExternal() && !defined->privateExtern && exportDynamic;
137 !defined->isExternalWeakDef() && !defined->interposable;
139 r.ExportDynamic = !common->privateExtern && exportDynamic;
144 sym->isUsedInRegularObj || (r.Prevailing && r.ExportDynamic);
146 // Un-define the symbol so that we don't get duplicate symbol errors when we
149 replaceSymbol<Undefined>(sym, sym->getName(), sym->getFile(),
154 checkError(ltoObj->add(std::move(f.obj), resols));
165 if (!f->lazy)
166 linkedBitCodeFiles.insert(f->getName());
170 if (!f->lazy)
172 if (linkedBitCodeFiles.contains(f->getName()))
175 replaceThinLTOSuffix(getThinLTOOutputFile(f->obj->getName()));
183 if (config->thinLTOEmitImportsFiles)
192 unsigned maxTasks = ltoObj->getMaxTasks();
196 // The -cache_path_lto option specifies the path to a directory in which
200 if (!config->thinLTOCacheDir.empty())
201 cache = check(localCache("ThinLTO", "Thin", config->thinLTOCacheDir,
208 checkError(ltoObj->run(
215 // Emit empty index files for non-indexed files
219 if (config->thinLTOEmitImportsFiles)
223 if (config->thinLTOEmitIndexFiles)
226 // In ThinLTO mode, Clang passes a temporary directory in -object_path_lto,
229 if (!config->ltoObjPath.empty()) {
230 if (std::error_code ec = fs::create_directories(config->ltoObjPath))
231 fatal("cannot create LTO object path " + config->ltoObjPath + ": " +
234 if (!fs::is_directory(config->ltoObjPath)) {
239 fatal("-object_path_lto must specify a directory when using ThinLTO");
245 if (!config->ltoObjPath.empty()) {
246 filePath = config->ltoObjPath;
249 getArchitectureName(config->arch()) +
255 // ThinLTO with index only option is required to generate only the index
258 if (config->thinLTOIndexOnly) {
259 if (!config->ltoObjPath.empty())
262 indexFile->close();
266 if (!config->thinLTOCacheDir.empty())
267 pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy, files);
273 // race with the cache pruner.
277 objBuf = files[i]->getBuffer();
278 cachePath = files[i]->getBufferIdentifier();
286 if (config->saveTemps)
288 config->outputFile + ((i == 0) ? "" : Twine(i)) + ".lto.o");
292 if (!config->ltoObjPath.empty()) {