LLVM dependence graphs
This is a LLVM
opt
pass for creating Program Dependence Graphs.
LLVM
builds.
- 1.68
cmake
-based build system. Using git clone --recursive
should take care of everything.None.
git clone --recursive
this repo.cd
into it.cmake
and cmake --build .
with that appropriate options.utils/scripts/build
subdirectory.exports_local_*
scripts using the CC
and CXX
variables for my currentexport one of the exports_deps_*
scripts, depending on the kind of setup you are interested in.
cmake -DCMAKE_INSTALL_PREFIX=[path-to-install] -P cmake_install.cmake
Omitting CMAKE_INSTALL_PREFIX
will use the ../install/
directory relative to the build directory.
lit
-based tests can be run with cmake --build . --target check
./run_unit_tests.sh
(see the script for details).opt -load [path to plugin]/libLLVMPedigreePass.so -pedigree foo.bc -o foo.out.bc
clang -Xclang -load -Xclang [path to plugin]/libLLVMPedigreePass.so foo.c -o foo
A first step towards customization is to search for the pattern [Ss]keleton]
and replace as with the desired name. A
general good approach is to prefix everything with the name of the pass, especially in languages that do not offer some
sort of namespace capability like cmake
.
Another customization that needs to be take care of in the case of creating a new project based on this template is the
use of cmake-utils. There are 3 options:
The shared object containing the pass is dynamically loaded by opt
. This poses a restriction on its build dependency
upon opt
and its transient dependency to the C++
library it is linked against. So, it is recommended to performreadelf -d $(which opt)
and note which implementation of the C++
library it uses
(libc++
or libstdc++
). Then, you can influence which C++
library your pass uses with theCMAKE_CXX_FLAGS
and the -stdlib
flag for LLVM
.
The main problem stems from the binary incompatibility (ABI) between the two implementations, although they are API
compatible since they adhere to the ISO standard. For this reason, libc++
uses the inlined namespace std::__1
, which
will show up in the errors when you have your pass built against libstdc++
and try to load it using an opt
built
against libc++
.
When LLVM
is build with BUILD_SHARED_LIBS=OFF
, opt
cannot load dynamically any pass built as a shared object,
complaining about multiply defined symbols, since it contains everything in its executable. The only workaround is to
build your pass in the LLVM
tree (resulting in a static archive, also included in the opt
executable).
When the build script uses LLVM
cmake
utility functions the lib
shared library prefix is omitted.
travis-ci
support.