summaryrefslogtreecommitdiff
path: root/include/llvm/LTO/LTO.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/LTO/LTO.h')
-rw-r--r--include/llvm/LTO/LTO.h47
1 files changed, 32 insertions, 15 deletions
diff --git a/include/llvm/LTO/LTO.h b/include/llvm/LTO/LTO.h
index 534d9b6f3f2a2..ca0a8b64523ac 100644
--- a/include/llvm/LTO/LTO.h
+++ b/include/llvm/LTO/LTO.h
@@ -1,9 +1,8 @@
//===-LTO.h - LLVM Link Time Optimizer ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -21,6 +20,7 @@
#include "llvm/ADT/StringSet.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/RemarkStreamer.h"
#include "llvm/LTO/Config.h"
#include "llvm/Linker/IRMover.h"
#include "llvm/Object/IRSymtab.h"
@@ -51,7 +51,8 @@ void thinLTOResolvePrevailingInIndex(
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing,
function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
- recordNewLinkage);
+ recordNewLinkage,
+ const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols);
/// Update the linkages in the given \p Index to mark exported values
/// as external and non-exported values as internal. The ThinLTO backends
@@ -84,8 +85,13 @@ std::string getThinLTOOutputFile(const std::string &Path,
/// Setup optimization remarks.
Expected<std::unique_ptr<ToolOutputFile>>
-setupOptimizationRemarks(LLVMContext &Context, StringRef LTORemarksFilename,
- bool LTOPassRemarksWithHotness, int Count = -1);
+setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,
+ StringRef RemarksPasses, StringRef RemarksFormat,
+ bool RemarksWithHotness, int Count = -1);
+
+/// Setups the output file for saving statistics.
+Expected<std::unique_ptr<ToolOutputFile>>
+setupStatsFile(StringRef StatsFilename);
class LTO;
struct SymbolResolution;
@@ -110,6 +116,7 @@ private:
std::vector<std::pair<size_t, size_t>> ModuleSymIndices;
StringRef TargetTriple, SourceFileName, COFFLinkerOpts;
+ std::vector<StringRef> DependentLibraries;
std::vector<StringRef> ComdatTable;
public:
@@ -131,6 +138,7 @@ public:
using irsymtab::Symbol::isWeak;
using irsymtab::Symbol::isIndirect;
using irsymtab::Symbol::getName;
+ using irsymtab::Symbol::getIRName;
using irsymtab::Symbol::getVisibility;
using irsymtab::Symbol::canBeOmittedFromSymbolTable;
using irsymtab::Symbol::isTLS;
@@ -140,6 +148,7 @@ public:
using irsymtab::Symbol::getCOFFWeakExternalFallback;
using irsymtab::Symbol::getSectionName;
using irsymtab::Symbol::isExecutable;
+ using irsymtab::Symbol::isUsed;
};
/// A range over the symbols in this InputFile.
@@ -148,6 +157,9 @@ public:
/// Returns linker options specified in the input file.
StringRef getCOFFLinkerOpts() const { return COFFLinkerOpts; }
+ /// Returns dependent library specifiers from the input file.
+ ArrayRef<StringRef> getDependentLibraries() const { return DependentLibraries; }
+
/// Returns the path to the InputFile.
StringRef getName() const;
@@ -160,6 +172,9 @@ public:
// Returns a table with all the comdats used by this file.
ArrayRef<StringRef> getComdatTable() const { return ComdatTable; }
+ // Returns the only BitcodeModule from InputFile.
+ BitcodeModule &getSingleBitcodeModule();
+
private:
ArrayRef<Symbol> module_symbols(unsigned I) const {
const auto &Indices = ModuleSymIndices[I];
@@ -183,8 +198,8 @@ public:
/// the fly.
///
/// Stream callbacks must be thread safe.
-typedef std::function<std::unique_ptr<NativeObjectStream>(unsigned Task)>
- AddStreamFn;
+using AddStreamFn =
+ std::function<std::unique_ptr<NativeObjectStream>(unsigned Task)>;
/// This is the type of a native object cache. To request an item from the
/// cache, pass a unique string as the Key. For hits, the cached file will be
@@ -198,17 +213,16 @@ typedef std::function<std::unique_ptr<NativeObjectStream>(unsigned Task)>
///
/// if (AddStreamFn AddStream = Cache(Task, Key))
/// ProduceContent(AddStream);
-typedef std::function<AddStreamFn(unsigned Task, StringRef Key)>
- NativeObjectCache;
+using NativeObjectCache =
+ std::function<AddStreamFn(unsigned Task, StringRef Key)>;
/// A ThinBackend defines what happens after the thin-link phase during ThinLTO.
/// The details of this type definition aren't important; clients can only
/// create a ThinBackend using one of the create*ThinBackend() functions below.
-typedef std::function<std::unique_ptr<ThinBackendProc>(
+using ThinBackend = std::function<std::unique_ptr<ThinBackendProc>(
Config &C, ModuleSummaryIndex &CombinedIndex,
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
- AddStreamFn AddStream, NativeObjectCache Cache)>
- ThinBackend;
+ AddStreamFn AddStream, NativeObjectCache Cache)>;
/// This ThinBackend runs the individual backend jobs in-process.
ThinBackend createInProcessThinBackend(unsigned ParallelismLevel);
@@ -397,7 +411,10 @@ private:
const SymbolResolution *&ResI, const SymbolResolution *ResE);
Error runRegularLTO(AddStreamFn AddStream);
- Error runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache);
+ Error runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
+ const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols);
+
+ Error checkPartiallySplit();
mutable bool CalledGetMaxTasks = false;