22 if (!Library.isValid())
24 Filename +
"': " +
Error,
27 PassPlugin
P{Filename.str(), Library};
31 intptr_t getDetailsFn =
32 (intptr_t)Library.getAddressOfSymbol(
"llvmGetPassPluginInfo");
38 Filename +
"'. Is this a legacy plugin?",
45 Twine(
"Wrong API version on plugin '") + Filename +
"'. Got version " +
46 Twine(
P.Info.APIVersion) +
", supported version is " +
57 if (!Index.try_emplace(Info.PluginName,
I).second)
59 Twine(Info.PluginName) +
"'");
63 for (
const std::string &Arg : Args) {
68 auto It = Index.find(Name);
69 if (It == Index.end())
71 "' is loaded, in -plugin-arg=" + Arg);
72 PluginArgs[It->second].
push_back(Rest.data());
74 for (
auto [Info, PArgs] :
zip_equal(Infos, PluginArgs)) {
77 if (!Info.ParseArguments)
79 "' does not accept arguments");
80 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_NOT_EXPORTED::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK llvmGetPassPluginInfo()
The public entry point for a pass plugin.
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.
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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
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...
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.