23 if (!Library.isValid())
25 Filename +
"': " +
Error,
28 PassPlugin
P{Filename.str(), Library};
32 intptr_t getDetailsFn =
33 (intptr_t)Library.getAddressOfSymbol(
"llvmGetPassPluginInfo");
39 Filename +
"'. Is this a legacy plugin?",
46 Twine(
"Wrong API version on plugin '") + Filename +
"'. Got version " +
47 Twine(
P.Info.APIVersion) +
", supported version is " +
59 if (Info.PreCodeGenCallback)
60 return Info.PreCodeGenCallback(TM, M, OS, DwoOS, CGFT, DisableVerify,
61 DisableSimplifyLibCalls, MSI,
70 if (!Index.try_emplace(Info.PluginName,
I).second)
72 Twine(Info.PluginName) +
"'");
76 for (
const std::string &Arg : Args) {
81 auto It = Index.find(Name);
82 if (It == Index.end())
84 "' is loaded, in -plugin-arg=" + Arg);
85 PluginArgs[It->second].
push_back(Rest.data());
87 for (
auto [Info, PArgs] :
zip_equal(Infos, PluginArgs)) {
90 if (!Info.ParseArguments)
92 "' does not accept arguments");
93 if (
Error E = Info.ParseArguments(PArgs))
This file defines the DenseMap class.
#define LLVM_PLUGIN_API_VERSION
\macro LLVM_PLUGIN_API_VERSION Identifies the API version understood by this plugin.
LLVM_ABI_EXPORT::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK llvmGetPassPluginInfo()
The public entry point for a pass plugin.
Defines the virtual file system interface vfs::FileSystem.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
Class to hold module path string table and global value map, and encapsulate methods for operating on...
A Module instance is used to store all the information related to an LLVM module.
LLVM_ABI bool invokePreCodeGenCallback(TargetMachine &TM, Module &M, raw_pwrite_stream &OS, raw_pwrite_stream *DwoOS, CodeGenFileType CGFT, bool DisableVerify, bool DisableSimplifyLibCalls, const ModuleSummaryIndex *MSI, IntrusiveRefCntPtr< vfs::FileSystem > VFS) const
Invoke the pre-codegen callback.
static LLVM_ABI Expected< PassPlugin > load(StringRef Filename)
Attempts to load a pass plugin from a given file.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Primary interface to the complete machine description for the target machine.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
An abstract base class for streams implementations that also support a pwrite operation.
static LLVM_ABI DynamicLibrary getPermanentLibrary(const char *filename, std::string *errMsg=nullptr)
This function permanently loads the dynamic library at the given path using the library load operatio...
This is an optimization pass for GlobalISel generic memory operations.
detail::zippy< detail::zip_first, T, U, Args... > zip_equal(T &&t, U &&u, Args &&...args)
zip iterator that assumes that all iteratees have the same length.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
LLVM_ABI Error passPluginArguments(ArrayRef< PassPluginLibraryInfo > Infos, ArrayRef< std::string > Args)
Passes each "<PluginName>,<arg>" in Args to the ParseArguments callback of the extension in Infos wit...
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.