#include "clang/Basic/Version.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/LTO/LTO.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ArchiveWriter.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/OffloadBinary.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
#include "llvm/Remarks/HotnessThresholdParser.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/WithColor.h"
usingnamespacellvm;
usingnamespacellvm::opt;
usingnamespacellvm::object;
static cl::opt<bool> RemarksWithHotness(
"pass-remarks-with-hotness",
cl::desc("With PGO, include profile count in optimization remarks"),
cl::Hidden);
static cl::opt<std::optional<uint64_t>, false, remarks::HotnessThresholdParser>
RemarksHotnessThreshold(
"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("N or 'auto'"), cl::init(0), cl::Hidden);
static cl::opt<std::string>
RemarksFilename("pass-remarks-output",
cl::desc("Output filename for pass remarks"),
cl::value_desc("filename"));
static cl::opt<std::string>
RemarksPasses("pass-remarks-filter",
cl::desc("Only record optimization remarks from passes whose "
"names match the given regular expression"),
cl::value_desc("regex"));
static cl::opt<std::string> RemarksFormat(
"pass-remarks-format",
cl::desc("The format used for serializing remarks (default: YAML)"),
cl::value_desc("format"), cl::init("yaml"));
static cl::list<std::string>
PassPlugins("load-pass-plugin",
cl::desc("Load passes from plugin library"));
static void printVersion(raw_ostream &OS) { … }
static const char *Executable;
static SmallVector<SmallString<128>> TempFiles;
static codegen::RegisterCodeGenFlags CodeGenFlags;
namespace {
enum WrapperFlags { … };
enum ID { … };
#define PREFIX …
#include "NVLinkOpts.inc"
#undef PREFIX
static constexpr OptTable::Info InfoTable[] = …;
class WrapperOptTable : public opt::GenericOptTable { … };
const OptTable &getOptTable() { … }
[[noreturn]] void reportError(Error E) { … }
void diagnosticHandler(const DiagnosticInfo &DI) { … }
Expected<StringRef> createTempFile(const ArgList &Args, const Twine &Prefix,
StringRef Extension) { … }
Expected<std::string> findProgram(const ArgList &Args, StringRef Name,
ArrayRef<StringRef> Paths) { … }
std::optional<std::string> findFile(StringRef Dir, StringRef Root,
const Twine &Name) { … }
std::optional<std::string>
findFromSearchPaths(StringRef Name, StringRef Root,
ArrayRef<StringRef> SearchPaths) { … }
std::optional<std::string>
searchLibraryBaseName(StringRef Name, StringRef Root,
ArrayRef<StringRef> SearchPaths) { … }
std::optional<std::string> searchLibrary(StringRef Input, StringRef Root,
ArrayRef<StringRef> SearchPaths) { … }
void printCommands(ArrayRef<StringRef> CmdArgs) { … }
struct Symbol { … };
Expected<StringRef> runPTXAs(StringRef File, const ArgList &Args) { … }
Expected<std::unique_ptr<lto::LTO>> createLTO(const ArgList &Args) { … }
Expected<bool> getSymbolsFromBitcode(MemoryBufferRef Buffer,
StringMap<Symbol> &SymTab, bool IsLazy) { … }
Expected<bool> getSymbolsFromObject(ObjectFile &ObjFile,
StringMap<Symbol> &SymTab, bool IsLazy) { … }
Expected<bool> getSymbols(MemoryBufferRef Buffer, StringMap<Symbol> &SymTab,
bool IsLazy) { … }
Expected<SmallVector<StringRef>> getInput(const ArgList &Args) { … }
Error runNVLink(ArrayRef<StringRef> Files, const ArgList &Args) { … }
}
int main(int argc, char **argv) { … }