diff options
author | Lang Hames <lhames@gmail.com> | 2023-03-24 14:43:32 -0700 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2023-03-24 16:05:51 -0700 |
commit | 01bdd8cffcaf97636b5fb6ee4933e62c872528d3 (patch) | |
tree | 0772636872c51eb4cac1deaf7da73b5dda2944cf /llvm/tools/llvm-jitlink/llvm-jitlink.cpp | |
parent | 0430324289f2f0206a03a124b86eece8d007b09e (diff) | |
download | llvm-01bdd8cffcaf97636b5fb6ee4933e62c872528d3.zip llvm-01bdd8cffcaf97636b5fb6ee4933e62c872528d3.tar.gz llvm-01bdd8cffcaf97636b5fb6ee4933e62c872528d3.tar.bz2 |
[llvm-jitlink] Rename -show-graph option to -show-graphs, make it a regex.
The original -show-graph option dumped the LinkGraph for all graphs loaded into
the session, but can make it difficult to see small graphs (e.g. reduced test
cases) among the surrounding larger files (especially the ORC runtime).
The new -show-graphs option takes a regex and dumps only those graphs matching
the regex. This allows testcases to specify exactly which graphs to dump.
Diffstat (limited to 'llvm/tools/llvm-jitlink/llvm-jitlink.cpp')
-rw-r--r-- | llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp index 15b26a8..48df846 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -50,6 +50,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" +#include "llvm/Support/Regex.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/Timer.h" @@ -175,10 +176,11 @@ static cl::opt<bool> ShowAddrs( cl::desc("Print registered symbol, section, got and stub addresses"), cl::init(false), cl::cat(JITLinkCategory)); -static cl::opt<bool> ShowLinkGraph( - "show-graph", - cl::desc("Print the link graph after fixups have been applied"), - cl::init(false), cl::cat(JITLinkCategory)); +static cl::opt<std::string> ShowLinkGraphs( + "show-graphs", + cl::desc("Takes a posix regex and prints the link graphs of all files " + "matching that regex after fixups have been applied"), + cl::Optional, cl::cat(JITLinkCategory)); static cl::opt<bool> ShowSizes( "show-sizes", @@ -1062,6 +1064,9 @@ Session::Session(std::unique_ptr<ExecutorProcessControl> EPC, Error &Err) // external. for (auto &DefName : HarnessDefinitions) HarnessExternals.erase(DefName.getKey()); + + if (!ShowLinkGraphs.empty()) + ShowGraphsRegex = Regex(ShowLinkGraphs); } void Session::dumpSessionInfo(raw_ostream &OS) { @@ -1086,10 +1091,14 @@ void Session::modifyPassConfig(const Triple &TT, inconvertibleErrorCode()); }); - if (ShowLinkGraph) - PassConfig.PostFixupPasses.push_back([](LinkGraph &G) -> Error { - outs() << "Link graph \"" << G.getName() << "\" post-fixup:\n"; - G.dump(outs()); + if (ShowGraphsRegex) + PassConfig.PostFixupPasses.push_back([this](LinkGraph &G) -> Error { + // Print graph if ShowLinkGraphs is specified-but-empty, or if + // it contains the given graph. + if (ShowGraphsRegex->match(G.getName())) { + outs() << "Link graph \"" << G.getName() << "\" post-fixup:\n"; + G.dump(outs()); + } return Error::success(); }); |