c++ - LLVM: Clang does not run Pass if CallGraphWrapperPass is a requirement -
i wrote following pass llvm.
using namespace llvm; namespace { struct skeletonpass : public functionpass { static char id; skeletonpass() : functionpass(id) {} void getanalysisusage(analysisusage &au) const { au.addrequired<callgraphwrapperpass>(); au.setpreservesall(); } virtual bool runonfunction(function &f) { errs() << "function: " << f.getname() << "!\n"; callgraph &cg = getanalysis<callgraphwrapperpass>().getcallgraph(); return false; } }; } char skeletonpass::id = 0; static registerpass<skeletonpass> x("skeleton", "text");
if execute code
opt -load ./libskeletonpass.so -skeleton test.bc > /dev/null
i correct output. (test.bc can neglected)
according great blog, next command
clang -xclang -load -xclang ./libskeletonpass.so test.c
should work, long replace last line with:
static void registerskeletonpass(const passmanagerbuilder &, legacy::passmanagerbase &pm) { pm.add(new skeletonpass()); } static registerstandardpasses registermypass(passmanagerbuilder::ep_earlyaspossible, registerskeletonpass);
the problem clang crashes , returns error:
... clang-3.8: error: unable execute command: segmentation fault (core dumped) clang-3.8: error: clang frontend command failed due signal (use -v see invocation) ...
without callgraphwrapperpass references clang executes pass correct.
i'm new llvm, there missed?
system: linux 4.4.0 (64bit)
clang version: 3.8.1
the solution change ep_earlyaspossible ep_enabledonoptlevel0.
Comments
Post a Comment