Update prebuilt Clang to r416183b from Android.
https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef
clang 12.0.5 (based on r416183b) from build 7284624.
Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/include/llvm/LTO/Config.h b/linux-x64/clang/include/llvm/LTO/Config.h
index fb107e3..1a7595d 100644
--- a/linux-x64/clang/include/llvm/LTO/Config.h
+++ b/linux-x64/clang/include/llvm/LTO/Config.h
@@ -1,4 +1,4 @@
-//===-Config.h - LLVM Link Time Optimizer Configuration -------------------===//
+//===-Config.h - LLVM Link Time Optimizer Configuration ---------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,9 +14,13 @@
#ifndef LLVM_LTO_CONFIG_H
#define LLVM_LTO_CONFIG_H
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Config/llvm-config.h"
#include "llvm/IR/DiagnosticInfo.h"
+#include "llvm/IR/GlobalValue.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/CodeGen.h"
-#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <functional>
@@ -38,15 +42,16 @@
std::string CPU;
TargetOptions Options;
std::vector<std::string> MAttrs;
+ std::vector<std::string> PassPlugins;
Optional<Reloc::Model> RelocModel = Reloc::PIC_;
Optional<CodeModel::Model> CodeModel = None;
CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default;
- TargetMachine::CodeGenFileType CGFileType = TargetMachine::CGFT_ObjectFile;
+ CodeGenFileType CGFileType = CGFT_ObjectFile;
unsigned OptLevel = 2;
bool DisableVerify = false;
/// Use the new pass manager
- bool UseNewPM = false;
+ bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER;
/// Flag to indicate that the optimizer should not assume builtins are present
/// on the target.
@@ -58,6 +63,15 @@
/// Run PGO context sensitive IR instrumentation.
bool RunCSIRInstr = false;
+ /// Asserts whether we can assume whole program visibility during the LTO
+ /// link.
+ bool HasWholeProgramVisibility = false;
+
+ /// Always emit a Regular LTO object even when it is empty because no Regular
+ /// LTO modules were linked. This option is useful for some build system which
+ /// want to know a priori all possible output files.
+ bool AlwaysEmitRegularLTOObj = false;
+
/// If this field is set, the set of passes run in the middle-end optimizer
/// will be the one specified by the string. Only works with the new pass
/// manager as the old one doesn't have this ability.
@@ -100,16 +114,31 @@
std::string SplitDwarfOutput;
/// Optimization remarks file path.
- std::string RemarksFilename = "";
+ std::string RemarksFilename;
/// Optimization remarks pass filter.
- std::string RemarksPasses = "";
+ std::string RemarksPasses;
/// Whether to emit optimization remarks with hotness informations.
bool RemarksWithHotness = false;
+ /// The minimum hotness value a diagnostic needs in order to be included in
+ /// optimization diagnostics.
+ ///
+ /// The threshold is an Optional value, which maps to one of the 3 states:
+ /// 1. 0 => threshold disabled. All emarks will be printed.
+ /// 2. positive int => manual threshold by user. Remarks with hotness exceed
+ /// threshold will be printed.
+ /// 3. None => 'auto' threshold by user. The actual value is not
+ /// available at command line, but will be synced with
+ /// hotness threhold from profile summary during
+ /// compilation.
+ ///
+ /// If threshold option is not specified, it is disabled by default.
+ llvm::Optional<uint64_t> RemarksHotnessThreshold = 0;
+
/// The format used for serializing remarks (default: YAML).
- std::string RemarksFormat = "";
+ std::string RemarksFormat;
/// Whether to emit the pass manager debuggging informations.
bool DebugPassManager = false;
@@ -117,6 +146,15 @@
/// Statistics output file path.
std::string StatsFile;
+ /// Specific thinLTO modules to compile.
+ std::vector<std::string> ThinLTOModulesToCompile;
+
+ /// Time trace enabled.
+ bool TimeTraceEnabled = false;
+
+ /// Time trace granularity.
+ unsigned TimeTraceGranularity = 500;
+
bool ShouldDiscardValueNames = true;
DiagnosticHandlerFunction DiagHandler;
@@ -126,6 +164,9 @@
/// with llvm-lto2.
std::unique_ptr<raw_ostream> ResolutionFile;
+ /// Tunable parameters for passes in the default pipelines.
+ PipelineTuningOptions PTO;
+
/// The following callbacks deal with tasks, which normally represent the
/// entire optimization and code generation pipeline for what will become a
/// single native object file. Each task has a unique identifier between 0 and
@@ -183,8 +224,9 @@
///
/// It is called regardless of whether the backend is in-process, although it
/// is not called from individual backend processes.
- using CombinedIndexHookFn =
- std::function<bool(const ModuleSummaryIndex &Index)>;
+ using CombinedIndexHookFn = std::function<bool(
+ const ModuleSummaryIndex &Index,
+ const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols)>;
CombinedIndexHookFn CombinedIndexHook;
/// This is a convenience function that configures this Config object to write
@@ -226,7 +268,7 @@
setDiscardValueNames(C.ShouldDiscardValueNames);
enableDebugTypeODRUniquing();
setDiagnosticHandler(
- llvm::make_unique<LTOLLVMDiagnosticHandler>(&DiagHandler), true);
+ std::make_unique<LTOLLVMDiagnosticHandler>(&DiagHandler), true);
}
DiagnosticHandlerFunction DiagHandler;
};
diff --git a/linux-x64/clang/include/llvm/LTO/LTO.h b/linux-x64/clang/include/llvm/LTO/LTO.h
index ca0a8b6..4f16913 100644
--- a/linux-x64/clang/include/llvm/LTO/LTO.h
+++ b/linux-x64/clang/include/llvm/LTO/LTO.h
@@ -17,28 +17,24 @@
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringSet.h"
-#include "llvm/IR/DiagnosticInfo.h"
+#include "llvm/Bitcode/BitcodeReader.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"
#include "llvm/Support/Error.h"
-#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/thread.h"
-#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/IPO/FunctionImport.h"
namespace llvm {
-class BitcodeModule;
class Error;
+class IRMover;
class LLVMContext;
class MemoryBufferRef;
class Module;
-class Target;
class raw_pwrite_stream;
+class Target;
+class ToolOutputFile;
/// Resolve linkage for prevailing symbols in the \p Index. Linkage changes
/// recorded in the index and the ThinLTO backends must apply the changes to
@@ -59,7 +55,9 @@
/// must apply the changes to the Module via thinLTOInternalizeModule.
void thinLTOInternalizeAndPromoteInIndex(
ModuleSummaryIndex &Index,
- function_ref<bool(StringRef, GlobalValue::GUID)> isExported);
+ function_ref<bool(StringRef, ValueInfo)> isExported,
+ function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
+ isPrevailing);
/// Computes a unique hash for the Module considering the current list of
/// export/import and other global analysis results.
@@ -84,15 +82,19 @@
const std::string &NewPrefix);
/// Setup optimization remarks.
-Expected<std::unique_ptr<ToolOutputFile>>
-setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,
- StringRef RemarksPasses, StringRef RemarksFormat,
- bool RemarksWithHotness, int Count = -1);
+Expected<std::unique_ptr<ToolOutputFile>> setupLLVMOptimizationRemarks(
+ LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses,
+ StringRef RemarksFormat, bool RemarksWithHotness,
+ Optional<uint64_t> RemarksHotnessThreshold = 0, int Count = -1);
/// Setups the output file for saving statistics.
Expected<std::unique_ptr<ToolOutputFile>>
setupStatsFile(StringRef StatsFilename);
+/// Produces a container ordering for optimal multi-threaded processing. Returns
+/// ordered indices to elements in the input array.
+std::vector<int> generateModulesOrdering(ArrayRef<BitcodeModule *> R);
+
class LTO;
struct SymbolResolution;
class ThinBackendProc;
@@ -220,12 +222,13 @@
/// The details of this type definition aren't important; clients can only
/// create a ThinBackend using one of the create*ThinBackend() functions below.
using ThinBackend = std::function<std::unique_ptr<ThinBackendProc>(
- Config &C, ModuleSummaryIndex &CombinedIndex,
+ const Config &C, ModuleSummaryIndex &CombinedIndex,
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
AddStreamFn AddStream, NativeObjectCache Cache)>;
/// This ThinBackend runs the individual backend jobs in-process.
-ThinBackend createInProcessThinBackend(unsigned ParallelismLevel);
+/// The default value means to use one job per hardware core (not hyper-thread).
+ThinBackend createInProcessThinBackend(ThreadPoolStrategy Parallelism);
/// This ThinBackend writes individual module indexes to files, instead of
/// running the individual backend jobs. This backend is for distributed builds
@@ -296,14 +299,19 @@
/// Cache) for each task identifier.
Error run(AddStreamFn AddStream, NativeObjectCache Cache = nullptr);
+ /// Static method that returns a list of libcall symbols that can be generated
+ /// by LTO but might not be visible from bitcode symbol table.
+ static ArrayRef<const char*> getRuntimeLibcallSymbols();
+
private:
Config Conf;
struct RegularLTOState {
- RegularLTOState(unsigned ParallelCodeGenParallelismLevel, Config &Conf);
+ RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
+ const Config &Conf);
struct CommonResolution {
uint64_t Size = 0;
- unsigned Align = 0;
+ MaybeAlign Align;
/// Record if at least one instance of the common was marked as prevailing
bool Prevailing = false;
};
@@ -323,14 +331,20 @@
std::vector<GlobalValue *> Keep;
};
std::vector<AddedModule> ModsWithSummaries;
+ bool EmptyCombinedModule = true;
} RegularLTO;
+ using ModuleMapType = MapVector<StringRef, BitcodeModule>;
+
struct ThinLTOState {
ThinLTOState(ThinBackend Backend);
ThinBackend Backend;
ModuleSummaryIndex CombinedIndex;
- MapVector<StringRef, BitcodeModule> ModuleMap;
+ // The full set of bitcode modules in input order.
+ ModuleMapType ModuleMap;
+ // The bitcode modules to compile, if specified by the LTO Config.
+ Optional<ModuleMapType> ModulesToCompile;
DenseMap<GlobalValue::GUID, StringRef> PrevailingModuleForGUID;
} ThinLTO;
diff --git a/linux-x64/clang/include/llvm/LTO/LTOBackend.h b/linux-x64/clang/include/llvm/LTO/LTOBackend.h
index 4ff8a19..824c7d1 100644
--- a/linux-x64/clang/include/llvm/LTO/LTOBackend.h
+++ b/linux-x64/clang/include/llvm/LTO/LTOBackend.h
@@ -33,18 +33,44 @@
namespace lto {
+/// Runs middle-end LTO optimizations on \p Mod.
+bool opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod,
+ bool IsThinLTO, ModuleSummaryIndex *ExportSummary,
+ const ModuleSummaryIndex *ImportSummary,
+ const std::vector<uint8_t> &CmdArgs);
+
/// Runs a regular LTO backend. The regular LTO backend can also act as the
/// regular LTO phase of ThinLTO, which may need to access the combined index.
-Error backend(Config &C, AddStreamFn AddStream,
+Error backend(const Config &C, AddStreamFn AddStream,
unsigned ParallelCodeGenParallelismLevel,
std::unique_ptr<Module> M, ModuleSummaryIndex &CombinedIndex);
/// Runs a ThinLTO backend.
-Error thinBackend(Config &C, unsigned Task, AddStreamFn AddStream, Module &M,
- const ModuleSummaryIndex &CombinedIndex,
+Error thinBackend(const Config &C, unsigned Task, AddStreamFn AddStream,
+ Module &M, const ModuleSummaryIndex &CombinedIndex,
const FunctionImporter::ImportMapTy &ImportList,
const GVSummaryMapTy &DefinedGlobals,
- MapVector<StringRef, BitcodeModule> &ModuleMap);
+ MapVector<StringRef, BitcodeModule> &ModuleMap,
+ const std::vector<uint8_t> &CmdArgs = std::vector<uint8_t>());
+
+Error finalizeOptimizationRemarks(
+ std::unique_ptr<ToolOutputFile> DiagOutputFile);
+
+/// Returns the BitcodeModule that is ThinLTO.
+BitcodeModule *findThinLTOModule(MutableArrayRef<BitcodeModule> BMs);
+
+/// Variant of the above.
+Expected<BitcodeModule> findThinLTOModule(MemoryBufferRef MBRef);
+
+/// Distributed ThinLTO: load the referenced modules, keeping their buffers
+/// alive in the provided OwnedImportLifetimeManager. Returns false if the
+/// operation failed.
+bool loadReferencedModules(
+ const Module &M, const ModuleSummaryIndex &CombinedIndex,
+ FunctionImporter::ImportMapTy &ImportList,
+ MapVector<llvm::StringRef, llvm::BitcodeModule> &ModuleMap,
+ std::vector<std::unique_ptr<llvm::MemoryBuffer>>
+ &OwnedImportsLifetimeManager);
}
}
diff --git a/linux-x64/clang/include/llvm/LTO/legacy/LTOCodeGenerator.h b/linux-x64/clang/include/llvm/LTO/legacy/LTOCodeGenerator.h
index d3cb4c8..d7ccc0d 100644
--- a/linux-x64/clang/include/llvm/LTO/legacy/LTOCodeGenerator.h
+++ b/linux-x64/clang/include/llvm/LTO/legacy/LTOCodeGenerator.h
@@ -35,11 +35,13 @@
#define LLVM_LTO_LTOCODEGENERATOR_H
#include "llvm-c/lto.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Module.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Target/TargetMachine.h"
@@ -87,11 +89,11 @@
void setCodePICModel(Optional<Reloc::Model> Model) { RelocModel = Model; }
/// Set the file type to be emitted (assembly or object code).
- /// The default is TargetMachine::CGFT_ObjectFile.
- void setFileType(TargetMachine::CodeGenFileType FT) { FileType = FT; }
+ /// The default is CGFT_ObjectFile.
+ void setFileType(CodeGenFileType FT) { FileType = FT; }
- void setCpu(StringRef MCpu) { this->MCpu = MCpu; }
- void setAttr(StringRef MAttr) { this->MAttr = MAttr; }
+ void setCpu(StringRef MCpu) { this->MCpu = std::string(MCpu); }
+ void setAttr(StringRef MAttr) { this->MAttr = std::string(MAttr); }
void setOptLevel(unsigned OptLevel);
void setShouldInternalize(bool Value) { ShouldInternalize = Value; }
@@ -113,7 +115,7 @@
ShouldRestoreGlobalsLinkage = Value;
}
- void addMustPreserveSymbol(StringRef Sym) { MustPreserveSymbols[Sym] = 1; }
+ void addMustPreserveSymbol(StringRef Sym) { MustPreserveSymbols.insert(Sym); }
/// Pass options to the driver and optimization passes.
///
@@ -121,7 +123,7 @@
/// name is misleading). This function should be called before
/// LTOCodeGenerator::compilexxx(), and
/// LTOCodeGenerator::writeMergedModules().
- void setCodeGenDebugOptions(StringRef Opts);
+ void setCodeGenDebugOptions(ArrayRef<StringRef> Opts);
/// Parse the options set in setCodeGenDebugOptions.
///
@@ -238,7 +240,7 @@
bool ShouldInternalize = EnableLTOInternalization;
bool ShouldEmbedUselists = false;
bool ShouldRestoreGlobalsLinkage = false;
- TargetMachine::CodeGenFileType FileType = TargetMachine::CGFT_ObjectFile;
+ CodeGenFileType FileType = CGFT_ObjectFile;
std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
bool Freestanding = false;
std::unique_ptr<ToolOutputFile> StatsFile = nullptr;
diff --git a/linux-x64/clang/include/llvm/LTO/legacy/LTOModule.h b/linux-x64/clang/include/llvm/LTO/legacy/LTOModule.h
index 84b9b8c..310447d 100644
--- a/linux-x64/clang/include/llvm/LTO/legacy/LTOModule.h
+++ b/linux-x64/clang/include/llvm/LTO/legacy/LTOModule.h
@@ -48,8 +48,6 @@
std::string LinkerOpts;
- std::string DependentLibraries;
-
std::unique_ptr<Module> Mod;
MemoryBufferRef MBRef;
ModuleSymbolTable SymTab;
@@ -165,6 +163,10 @@
static const char *getDependentLibrary(lto::InputFile *input, size_t index, size_t *size);
+ Expected<uint32_t> getMachOCPUType() const;
+
+ Expected<uint32_t> getMachOCPUSubType() const;
+
private:
/// Parse metadata from the module
// FIXME: it only parses "llvm.linker.options" metadata at the moment