aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llc/llc.cpp56
-rw-r--r--llvm/tools/llvm-gpu-loader/amdhsa.cpp4
-rw-r--r--llvm/tools/llvm-gpu-loader/llvm-gpu-loader.h4
-rw-r--r--llvm/tools/llvm-gpu-loader/nvptx.cpp4
-rw-r--r--llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp6
-rw-r--r--llvm/tools/llvm-offload-binary/CMakeLists.txt13
-rw-r--r--llvm/tools/llvm-offload-binary/llvm-offload-binary.cpp258
-rw-r--r--llvm/tools/llvm-profgen/ProfiledBinary.cpp21
-rw-r--r--llvm/tools/llvm-profgen/ProfiledBinary.h16
9 files changed, 333 insertions, 49 deletions
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index a2327fb..7551a80 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -67,26 +67,25 @@ static codegen::RegisterCodeGenFlags CGF;
// and back-end code generation options are specified with the target machine.
//
static cl::opt<std::string>
-InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
+ InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
static cl::list<std::string>
InstPrinterOptions("M", cl::desc("InstPrinter options"));
static cl::opt<std::string>
-InputLanguage("x", cl::desc("Input language ('ir' or 'mir')"));
+ InputLanguage("x", cl::desc("Input language ('ir' or 'mir')"));
-static cl::opt<std::string>
-OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));
+static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
+ cl::value_desc("filename"));
static cl::opt<std::string>
- SplitDwarfOutputFile("split-dwarf-output",
- cl::desc(".dwo output filename"),
+ SplitDwarfOutputFile("split-dwarf-output", cl::desc(".dwo output filename"),
cl::value_desc("filename"));
static cl::opt<unsigned>
-TimeCompilations("time-compilations", cl::Hidden, cl::init(1u),
- cl::value_desc("N"),
- cl::desc("Repeat compilation N times for timing"));
+ TimeCompilations("time-compilations", cl::Hidden, cl::init(1u),
+ cl::value_desc("N"),
+ cl::desc("Repeat compilation N times for timing"));
static cl::opt<bool> TimeTrace("time-trace", cl::desc("Record time trace"));
@@ -123,7 +122,7 @@ static cl::opt<char>
cl::Prefix, cl::init('2'));
static cl::opt<std::string>
-TargetTriple("mtriple", cl::desc("Override target triple for module"));
+ TargetTriple("mtriple", cl::desc("Override target triple for module"));
static cl::opt<std::string> SplitDwarfFile(
"split-dwarf-file",
@@ -167,6 +166,11 @@ static cl::opt<bool> DiscardValueNames(
cl::desc("Discard names from Value (other than GlobalValue)."),
cl::init(false), cl::Hidden);
+static cl::opt<bool>
+ PrintMIR2VecVocab("print-mir2vec-vocab", cl::Hidden,
+ cl::desc("Print MIR2Vec vocabulary contents"),
+ cl::init(false));
+
static cl::list<std::string> IncludeDirs("I", cl::desc("include search path"));
static cl::opt<bool> RemarksWithHotness(
@@ -409,8 +413,8 @@ int main(int argc, char **argv) {
return 0;
}
-static bool addPass(PassManagerBase &PM, const char *argv0,
- StringRef PassName, TargetPassConfig &TPC) {
+static bool addPass(PassManagerBase &PM, const char *argv0, StringRef PassName,
+ TargetPassConfig &TPC) {
if (PassName == "none")
return false;
@@ -610,7 +614,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
// Figure out where we are going to send the output.
std::unique_ptr<ToolOutputFile> Out =
GetOutputStream(TheTarget->getName(), TheTriple.getOS(), argv[0]);
- if (!Out) return 1;
+ if (!Out)
+ return 1;
// Ensure the filename is passed down to CodeViewDebug.
Target->Options.ObjectFilenameForDebug = Out->outputFilename();
@@ -623,7 +628,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
if (!SplitDwarfOutputFile.empty()) {
std::error_code EC;
DwoOut = std::make_unique<ToolOutputFile>(SplitDwarfOutputFile, EC,
- sys::fs::OF_None);
+ sys::fs::OF_None);
if (EC)
reportError(EC.message(), SplitDwarfOutputFile);
}
@@ -725,12 +730,25 @@ static int compileModule(char **argv, LLVMContext &Context) {
}
TPC.setInitialized();
PM.add(createPrintMIRPass(*OS));
+
+ // Add MIR2Vec vocabulary printer if requested
+ if (PrintMIR2VecVocab) {
+ PM.add(createMIR2VecVocabPrinterLegacyPass(errs()));
+ }
+
PM.add(createFreeMachineFunctionPass());
- } else if (Target->addPassesToEmitFile(
- PM, *OS, DwoOut ? &DwoOut->os() : nullptr,
- codegen::getFileType(), NoVerify, MMIWP)) {
- if (!HasMCErrors)
- reportError("target does not support generation of this file type");
+ } else {
+ if (Target->addPassesToEmitFile(PM, *OS, DwoOut ? &DwoOut->os() : nullptr,
+ codegen::getFileType(), NoVerify,
+ MMIWP)) {
+ if (!HasMCErrors)
+ reportError("target does not support generation of this file type");
+ }
+
+ // Add MIR2Vec vocabulary printer if requested
+ if (PrintMIR2VecVocab) {
+ PM.add(createMIR2VecVocabPrinterLegacyPass(errs()));
+ }
}
Target->getObjFileLowering()->Initialize(MMIWP->getMMI().getContext(),
diff --git a/llvm/tools/llvm-gpu-loader/amdhsa.cpp b/llvm/tools/llvm-gpu-loader/amdhsa.cpp
index be1b6b7..5715058 100644
--- a/llvm/tools/llvm-gpu-loader/amdhsa.cpp
+++ b/llvm/tools/llvm-gpu-loader/amdhsa.cpp
@@ -192,7 +192,7 @@ hsa_status_t launch_kernel(hsa_agent_t dev_agent, hsa_executable_t executable,
// Initialize all the arguments (explicit and implicit) to zero, then set the
// explicit arguments to the values created above.
std::memset(args, 0, args_size);
- std::memcpy(args, &kernel_args, sizeof(args_t));
+ std::memcpy(args, &kernel_args, std::is_empty_v<args_t> ? 0 : sizeof(args_t));
// Initialize the necessary implicit arguments to the proper values.
int dims = 1 + (params.num_blocks_y * params.num_threads_y != 1) +
@@ -563,7 +563,7 @@ int load_amdhsa(int argc, const char **argv, const char **envp, void *image,
// Save the return value and perform basic clean-up.
int ret = *static_cast<int *>(host_ret);
- end_args_t fini_args = {ret};
+ end_args_t fini_args = {};
if (hsa_status_t err = launch_kernel(
dev_agent, executable, kernargs_pool, coarsegrained_pool, queue,
server, single_threaded_params, "_end.kd", fini_args,
diff --git a/llvm/tools/llvm-gpu-loader/llvm-gpu-loader.h b/llvm/tools/llvm-gpu-loader/llvm-gpu-loader.h
index ed34d0b..08861c2 100644
--- a/llvm/tools/llvm-gpu-loader/llvm-gpu-loader.h
+++ b/llvm/tools/llvm-gpu-loader/llvm-gpu-loader.h
@@ -41,9 +41,7 @@ struct start_args_t {
};
/// The arguments to the '_end' kernel.
-struct end_args_t {
- int argc;
-};
+struct end_args_t {};
/// Generic interface to load the \p image and launch execution of the _start
/// kernel on the target device. Copies \p argc and \p argv to the device.
diff --git a/llvm/tools/llvm-gpu-loader/nvptx.cpp b/llvm/tools/llvm-gpu-loader/nvptx.cpp
index 781a045..82b4552 100644
--- a/llvm/tools/llvm-gpu-loader/nvptx.cpp
+++ b/llvm/tools/llvm-gpu-loader/nvptx.cpp
@@ -177,7 +177,7 @@ CUresult launch_kernel(CUmodule binary, CUstream stream, rpc::Server &server,
handle_error(err);
// Set up the arguments to the '_start' kernel on the GPU.
- uint64_t args_size = sizeof(args_t);
+ uint64_t args_size = std::is_empty_v<args_t> ? 0 : sizeof(args_t);
void *args_config[] = {CU_LAUNCH_PARAM_BUFFER_POINTER, &kernel_args,
CU_LAUNCH_PARAM_BUFFER_SIZE, &args_size,
CU_LAUNCH_PARAM_END};
@@ -342,7 +342,7 @@ int load_nvptx(int argc, const char **argv, const char **envp, void *image,
if (CUresult err = cuStreamSynchronize(stream))
handle_error(err);
- end_args_t fini_args = {host_ret};
+ end_args_t fini_args = {};
if (CUresult err =
launch_kernel(binary, stream, server, single_threaded_params, "_end",
fini_args, print_resource_usage))
diff --git a/llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp b/llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
index dca64af..fa56d0d 100644
--- a/llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
+++ b/llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
@@ -182,8 +182,8 @@ int AssembleOneInput(const uint8_t *Data, size_t Size) {
const unsigned OutputAsmVariant = 0;
std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
- MCInstPrinter *IP = TheTarget->createMCInstPrinter(Triple(TripleName), OutputAsmVariant,
- *MAI, *MCII, *MRI);
+ std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
+ Triple(TripleName), OutputAsmVariant, *MAI, *MCII, *MRI));
if (!IP) {
errs()
<< "error: unable to create instruction printer for target triple '"
@@ -204,7 +204,7 @@ int AssembleOneInput(const uint8_t *Data, size_t Size) {
std::unique_ptr<MCStreamer> Str;
if (FileType == OFT_AssemblyFile) {
- Str.reset(TheTarget->createAsmStreamer(Ctx, std::move(FOut), IP,
+ Str.reset(TheTarget->createAsmStreamer(Ctx, std::move(FOut), std::move(IP),
std::move(CE), std::move(MAB)));
} else {
assert(FileType == OFT_ObjectFile && "Invalid file type!");
diff --git a/llvm/tools/llvm-offload-binary/CMakeLists.txt b/llvm/tools/llvm-offload-binary/CMakeLists.txt
new file mode 100644
index 0000000..6f46f1b
--- /dev/null
+++ b/llvm/tools/llvm-offload-binary/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS
+ BinaryFormat
+ Object
+ Support)
+
+add_llvm_tool(llvm-offload-binary
+ llvm-offload-binary.cpp
+
+ DEPENDS
+ intrinsics_gen
+ )
+# Legacy binary name to be removed at a later release.
+add_llvm_tool_symlink(clang-offload-packager llvm-offload-binary)
diff --git a/llvm/tools/llvm-offload-binary/llvm-offload-binary.cpp b/llvm/tools/llvm-offload-binary/llvm-offload-binary.cpp
new file mode 100644
index 0000000..e22d13b
--- /dev/null
+++ b/llvm/tools/llvm-offload-binary/llvm-offload-binary.cpp
@@ -0,0 +1,258 @@
+//===-- llvm-offload-binary.cpp - offload binary management utility -------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This tool takes several device object files and bundles them into a single
+// binary image using a custom binary format. This is intended to be used to
+// embed many device files into an application to create a fat binary. It also
+// supports extracting these files from a known location.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt<bool> Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+static cl::OptionCategory OffloadBinaryCategory("llvm-offload-binary options");
+
+static cl::opt<std::string> OutputFile("o", cl::desc("Write output to <file>."),
+ cl::value_desc("file"),
+ cl::cat(OffloadBinaryCategory));
+
+static cl::opt<std::string> InputFile(cl::Positional,
+ cl::desc("Extract from <file>."),
+ cl::value_desc("file"),
+ cl::cat(OffloadBinaryCategory));
+
+static cl::list<std::string>
+ DeviceImages("image",
+ cl::desc("List of key and value arguments. Required keywords "
+ "are 'file' and 'triple'."),
+ cl::value_desc("<key>=<value>,..."),
+ cl::cat(OffloadBinaryCategory));
+
+static cl::opt<bool>
+ CreateArchive("archive",
+ cl::desc("Write extracted files to a static archive"),
+ cl::cat(OffloadBinaryCategory));
+
+/// Path of the current binary.
+static const char *PackagerExecutable;
+
+// Get a map containing all the arguments for the image. Repeated arguments will
+// be placed in a comma separated list.
+static DenseMap<StringRef, StringRef> getImageArguments(StringRef Image,
+ StringSaver &Saver) {
+ DenseMap<StringRef, StringRef> Args;
+ for (StringRef Arg : llvm::split(Image, ",")) {
+ auto [Key, Value] = Arg.split("=");
+ auto [It, Inserted] = Args.try_emplace(Key, Value);
+ if (!Inserted)
+ It->second = Saver.save(It->second + "," + Value);
+ }
+
+ return Args;
+}
+
+static Error writeFile(StringRef Filename, StringRef Data) {
+ Expected<std::unique_ptr<FileOutputBuffer>> OutputOrErr =
+ FileOutputBuffer::create(Filename, Data.size());
+ if (!OutputOrErr)
+ return OutputOrErr.takeError();
+ std::unique_ptr<FileOutputBuffer> Output = std::move(*OutputOrErr);
+ llvm::copy(Data, Output->getBufferStart());
+ if (Error E = Output->commit())
+ return E;
+ return Error::success();
+}
+
+static Error bundleImages() {
+ SmallVector<char, 1024> BinaryData;
+ raw_svector_ostream OS(BinaryData);
+ for (StringRef Image : DeviceImages) {
+ BumpPtrAllocator Alloc;
+ StringSaver Saver(Alloc);
+ DenseMap<StringRef, StringRef> Args = getImageArguments(Image, Saver);
+
+ if (!Args.count("file"))
+ return createStringError(inconvertibleErrorCode(),
+ "'file' is a required image arguments");
+
+ // Permit using multiple instances of `file` in a single string.
+ for (auto &File : llvm::split(Args["file"], ",")) {
+ OffloadBinary::OffloadingImage ImageBinary{};
+
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ObjectOrErr =
+ llvm::MemoryBuffer::getFileOrSTDIN(File);
+ if (std::error_code EC = ObjectOrErr.getError())
+ return errorCodeToError(EC);
+
+ // Clang uses the '.o' suffix for LTO bitcode.
+ if (identify_magic((*ObjectOrErr)->getBuffer()) == file_magic::bitcode)
+ ImageBinary.TheImageKind = object::IMG_Bitcode;
+ else if (sys::path::has_extension(File))
+ ImageBinary.TheImageKind =
+ getImageKind(sys::path::extension(File).drop_front());
+ else
+ ImageBinary.TheImageKind = IMG_None;
+ ImageBinary.Image = std::move(*ObjectOrErr);
+ for (const auto &[Key, Value] : Args) {
+ if (Key == "kind") {
+ ImageBinary.TheOffloadKind = getOffloadKind(Value);
+ } else if (Key != "file") {
+ ImageBinary.StringData[Key] = Value;
+ }
+ }
+ llvm::SmallString<0> Buffer = OffloadBinary::write(ImageBinary);
+ if (Buffer.size() % OffloadBinary::getAlignment() != 0)
+ return createStringError(inconvertibleErrorCode(),
+ "Offload binary has invalid size alignment");
+ OS << Buffer;
+ }
+ }
+
+ if (Error E = writeFile(OutputFile,
+ StringRef(BinaryData.begin(), BinaryData.size())))
+ return E;
+ return Error::success();
+}
+
+static Error unbundleImages() {
+ ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
+ MemoryBuffer::getFileOrSTDIN(InputFile);
+ if (std::error_code EC = BufferOrErr.getError())
+ return createFileError(InputFile, EC);
+ std::unique_ptr<MemoryBuffer> Buffer = std::move(*BufferOrErr);
+
+ // This data can be misaligned if extracted from an archive.
+ if (!isAddrAligned(Align(OffloadBinary::getAlignment()),
+ Buffer->getBufferStart()))
+ Buffer = MemoryBuffer::getMemBufferCopy(Buffer->getBuffer(),
+ Buffer->getBufferIdentifier());
+
+ SmallVector<OffloadFile> Binaries;
+ if (Error Err = extractOffloadBinaries(*Buffer, Binaries))
+ return Err;
+
+ // Try to extract each device image specified by the user from the input file.
+ for (StringRef Image : DeviceImages) {
+ BumpPtrAllocator Alloc;
+ StringSaver Saver(Alloc);
+ auto Args = getImageArguments(Image, Saver);
+
+ SmallVector<const OffloadBinary *> Extracted;
+ for (const OffloadFile &File : Binaries) {
+ const auto *Binary = File.getBinary();
+ // We handle the 'file' and 'kind' identifiers differently.
+ bool Match = llvm::all_of(Args, [&](auto &Arg) {
+ const auto [Key, Value] = Arg;
+ if (Key == "file")
+ return true;
+ if (Key == "kind")
+ return Binary->getOffloadKind() == getOffloadKind(Value);
+ return Binary->getString(Key) == Value;
+ });
+ if (Match)
+ Extracted.push_back(Binary);
+ }
+
+ if (Extracted.empty())
+ continue;
+
+ if (CreateArchive) {
+ if (!Args.count("file"))
+ return createStringError(inconvertibleErrorCode(),
+ "Image must have a 'file' argument.");
+
+ SmallVector<NewArchiveMember> Members;
+ for (const OffloadBinary *Binary : Extracted)
+ Members.emplace_back(MemoryBufferRef(
+ Binary->getImage(),
+ Binary->getMemoryBufferRef().getBufferIdentifier()));
+
+ if (Error E = writeArchive(
+ Args["file"], Members, SymtabWritingMode::NormalSymtab,
+ Archive::getDefaultKind(), true, false, nullptr))
+ return E;
+ } else if (auto It = Args.find("file"); It != Args.end()) {
+ if (Extracted.size() > 1)
+ WithColor::warning(errs(), PackagerExecutable)
+ << "Multiple inputs match to a single file, '" << It->second
+ << "'\n";
+ if (Error E = writeFile(It->second, Extracted.back()->getImage()))
+ return E;
+ } else {
+ uint64_t Idx = 0;
+ for (const OffloadBinary *Binary : Extracted) {
+ StringRef Filename =
+ Saver.save(sys::path::stem(InputFile) + "-" + Binary->getTriple() +
+ "-" + Binary->getArch() + "." + std::to_string(Idx++) +
+ "." + getImageKindName(Binary->getImageKind()));
+ if (Error E = writeFile(Filename, Binary->getImage()))
+ return E;
+ }
+ }
+ }
+
+ return Error::success();
+}
+
+int main(int argc, const char **argv) {
+ sys::PrintStackTraceOnErrorSignal(argv[0]);
+ cl::HideUnrelatedOptions(OffloadBinaryCategory);
+ cl::ParseCommandLineOptions(
+ argc, argv,
+ "A utility for bundling several object files into a single binary.\n"
+ "The output binary can then be embedded into the host section table\n"
+ "to create a fatbinary containing offloading code.\n");
+
+ if (sys::path::stem(argv[0]).ends_with("clang-offload-packager"))
+ WithColor::warning(errs(), PackagerExecutable)
+ << "'clang-offload-packager' is deprecated. Use 'llvm-offload-binary' "
+ "instead.\n";
+
+ if (Help || (OutputFile.empty() && InputFile.empty())) {
+ cl::PrintHelpMessage();
+ return EXIT_SUCCESS;
+ }
+
+ PackagerExecutable = argv[0];
+ auto reportError = [argv](Error E) {
+ logAllUnhandledErrors(std::move(E), WithColor::error(errs(), argv[0]));
+ return EXIT_FAILURE;
+ };
+
+ if (!InputFile.empty() && !OutputFile.empty())
+ return reportError(
+ createStringError(inconvertibleErrorCode(),
+ "Packaging to an output file and extracting from an "
+ "input file are mutually exclusive."));
+
+ if (!OutputFile.empty()) {
+ if (Error Err = bundleImages())
+ return reportError(std::move(Err));
+ } else if (!InputFile.empty()) {
+ if (Error Err = unbundleImages())
+ return reportError(std::move(Err));
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index 6865e36..94728ce 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -250,14 +250,12 @@ void ProfiledBinary::load() {
DisassembleFunctionSet.insert_range(DisassembleFunctions);
- if (auto *ELFObj = dyn_cast<ELFObjectFileBase>(Obj)) {
- checkPseudoProbe(ELFObj);
- if (UsePseudoProbes)
- populateElfSymbolAddressList(ELFObj);
+ checkPseudoProbe(Obj);
+ if (UsePseudoProbes)
+ populateSymbolAddressList(Obj);
- if (ShowDisassemblyOnly)
- decodePseudoProbe(ELFObj);
- }
+ if (ShowDisassemblyOnly)
+ decodePseudoProbe(Obj);
// Disassemble the text sections.
disassemble(Obj);
@@ -417,7 +415,7 @@ void ProfiledBinary::setPreferredTextSegmentAddresses(const ObjectFile *Obj) {
llvm_unreachable("invalid object format");
}
-void ProfiledBinary::checkPseudoProbe(const ELFObjectFileBase *Obj) {
+void ProfiledBinary::checkPseudoProbe(const ObjectFile *Obj) {
if (UseDwarfCorrelation)
return;
@@ -440,7 +438,7 @@ void ProfiledBinary::checkPseudoProbe(const ELFObjectFileBase *Obj) {
UsePseudoProbes = HasProbeDescSection && HasPseudoProbeSection;
}
-void ProfiledBinary::decodePseudoProbe(const ELFObjectFileBase *Obj) {
+void ProfiledBinary::decodePseudoProbe(const ObjectFile *Obj) {
if (!UsePseudoProbes)
return;
@@ -511,7 +509,7 @@ void ProfiledBinary::decodePseudoProbe(const ELFObjectFileBase *Obj) {
void ProfiledBinary::decodePseudoProbe() {
OwningBinary<Binary> OBinary = unwrapOrError(createBinary(Path), Path);
Binary &ExeBinary = *OBinary.getBinary();
- auto *Obj = cast<ELFObjectFileBase>(&ExeBinary);
+ auto *Obj = cast<ObjectFile>(&ExeBinary);
decodePseudoProbe(Obj);
}
@@ -809,8 +807,7 @@ void ProfiledBinary::checkUseFSDiscriminator(
}
}
-void ProfiledBinary::populateElfSymbolAddressList(
- const ELFObjectFileBase *Obj) {
+void ProfiledBinary::populateSymbolAddressList(const ObjectFile *Obj) {
// Create a mapping from virtual address to symbol GUID and the other way
// around.
StringRef FileName = Obj->getFileName();
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.h b/llvm/tools/llvm-profgen/ProfiledBinary.h
index e82fbab..5a814b7 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.h
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -228,19 +228,19 @@ class ProfiledBinary {
// A list of binary functions that have samples.
std::unordered_set<const BinaryFunction *> ProfiledFunctions;
- // GUID to Elf symbol start address map
+ // GUID to symbol start address map
DenseMap<uint64_t, uint64_t> SymbolStartAddrs;
// These maps are for temporary use of warning diagnosis.
DenseSet<int64_t> AddrsWithMultipleSymbols;
DenseSet<std::pair<uint64_t, uint64_t>> AddrsWithInvalidInstruction;
- // Start address to Elf symbol GUID map
+ // Start address to symbol GUID map
std::unordered_multimap<uint64_t, uint64_t> StartAddrToSymMap;
// An ordered map of mapping function's start address to function range
- // relevant info. Currently to determine if the offset of ELF is the start of
- // a real function, we leverage the function range info from DWARF.
+ // relevant info. Currently to determine if the offset of ELF/COFF is the
+ // start of a real function, we leverage the function range info from DWARF.
std::map<uint64_t, FuncRange> StartAddrToFuncRangeMap;
// Address to context location map. Used to expand the context.
@@ -335,9 +335,9 @@ class ProfiledBinary {
void setPreferredTextSegmentAddresses(const object::COFFObjectFile *Obj,
StringRef FileName);
- void checkPseudoProbe(const object::ELFObjectFileBase *Obj);
+ void checkPseudoProbe(const object::ObjectFile *Obj);
- void decodePseudoProbe(const object::ELFObjectFileBase *Obj);
+ void decodePseudoProbe(const object::ObjectFile *Obj);
void checkUseFSDiscriminator(
const object::ObjectFile *Obj,
@@ -353,8 +353,8 @@ class ProfiledBinary {
// Load debug info from DWARF unit.
void loadSymbolsFromDWARFUnit(DWARFUnit &CompilationUnit);
- // Create elf symbol to its start address mapping.
- void populateElfSymbolAddressList(const object::ELFObjectFileBase *O);
+ // Create symbol to its start address mapping.
+ void populateSymbolAddressList(const object::ObjectFile *O);
// A function may be spilt into multiple non-continuous address ranges. We use
// this to set whether start a function range is the real entry of the