Commit 9fe2f614 authored by Dr. Michael Petter's avatar Dr. Michael Petter
Browse files

compatible to LLVM 13

parent a77b5212
...@@ -8,13 +8,13 @@ Implementing an LLVM analysis framework based upon the Seidl Program Optimizatio ...@@ -8,13 +8,13 @@ Implementing an LLVM analysis framework based upon the Seidl Program Optimizatio
Install the LLVM packages from your distro's package manager, e.g. Ubuntu 20.04: Install the LLVM packages from your distro's package manager, e.g. Ubuntu 20.04:
# install the necessary LLVM packages # install the necessary LLVM packages
sudo apt install cmake clang libclang-10-dev llvm-10-dev sudo apt install cmake clang libclang-12-dev llvm-12-dev
# now continue by building the project # now continue by building the project
git clone https://versioncontrolseidl.in.tum.de/petter/llvm-abstractinterpretation.git git clone https://versioncontrolseidl.in.tum.de/petter/llvm-abstractinterpretation.git
cd llvm-abstractinterpretation cd llvm-abstractinterpretation
mkdir build mkdir build
cd build cd build
cmake -G "Unix Makefiles" -DPATH_TO_LLVM=/usr/lib/llvm-10 .. cmake -G "Unix Makefiles" -DPATH_TO_LLVM=/usr/lib/llvm-12 ..
make make
You can do this, however the precompiled LLVM binaries come without symbol names, thus debugging You can do this, however the precompiled LLVM binaries come without symbol names, thus debugging
...@@ -23,20 +23,20 @@ might be a little harder this way. Alterntively consider the following route: ...@@ -23,20 +23,20 @@ might be a little harder this way. Alterntively consider the following route:
### Build against custom downloaded LLVM Sources ### Build against custom downloaded LLVM Sources
Get the LLVM source code from [here](https://releases.llvm.org/download.html). Then get clang as well, into `llvm/tools`. Create a build directory somewhere, initialise CMake, and build. For example Get the LLVM source code from [here](https://releases.llvm.org/download.html). Then get clang as well, into `llvm/tools`. Create a build directory somewhere, initialise CMake, and build. For example
# From llvm-10.0.0-src, or whatever the version is now # From llvm-13.0.0-src, or whatever the version is now
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/llvm-10.0.0.src.tar.xz wget https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/llvm-13.0.0.src.tar.xz
tar xf llvm-10.0.0.src.tar.xz tar xf llvm-13.0.0.src.tar.xz
# now also download clang # now also download clang
cd llvm-10.0.0.src/tools cd llvm-13.0.0.src/tools
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang-10.0.0.src.tar.xz wget https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang-13.0.0.src.tar.xz
tar xf clang-10.0.0.src.tar.xz tar xf clang-13.0.0.src.tar.xz
mv clang-10.0.0.src clang mv clang-13.0.0.src clang
cd ../.. cd ../..
# now continue by building LLVM # now continue by building LLVM
mkdir llvm_build mkdir llvm_build
cd llvm_build cd llvm_build
# important: Don't forget to restrict to X86, otherwise prepare for a day of compiling # important: Don't forget to restrict to X86, otherwise prepare for a day of compiling
cmake ../llvm-10.0.0-src -DLLVM_TARGETS_TO_BUILD=X86 cmake ../llvm-13.0.0-src -DLLVM_TARGETS_TO_BUILD=X86
# 4x parallelized make, which will probably fail due to RAM consumption # 4x parallelized make, which will probably fail due to RAM consumption
make -j4 make -j4
# make -j1 in order to catch up, where the parallel make aborted # make -j1 in order to catch up, where the parallel make aborted
......
...@@ -355,7 +355,7 @@ void executeFixpointAlgorithm(Module const& M) { ...@@ -355,7 +355,7 @@ void executeFixpointAlgorithm(Module const& M) {
dbgs(0) << "Output filename: " << OutputFilename.c_str(); dbgs(0) << "Output filename: " << OutputFilename.c_str();
std::error_code ErrInfo; std::error_code ErrInfo;
llvm::raw_fd_ostream Result(OutputFilename.c_str(),ErrInfo,llvm::sys::fs::F_None); llvm::raw_fd_ostream Result(OutputFilename.c_str(),ErrInfo,(llvm::sys::fs::OpenFlags)0 );
StringRef sofar(""); StringRef sofar("");
Result << "{\n"; Result << "{\n";
for (auto const& [key, node]:nodes){ for (auto const& [key, node]:nodes){
......
...@@ -10,9 +10,9 @@ public: ...@@ -10,9 +10,9 @@ public:
static char ID; // Pass identification, replacement for typeid static char ID; // Pass identification, replacement for typeid
virtual bool runOnModule(llvm::Module& M); virtual bool runOnModule(llvm::Module& M) override;
virtual void getAnalysisUsage(llvm::AnalysisUsage &Info) const; virtual void getAnalysisUsage(llvm::AnalysisUsage &Info) const override;
}; };
} /* end of namespace pcpo */ } /* end of namespace pcpo */
#include "simple_interval.h" #include "simple_interval.h"
#include "llvm/ADT/SmallString.h"
namespace pcpo { namespace pcpo {
...@@ -255,8 +256,11 @@ llvm::raw_ostream& operator<<(llvm::raw_ostream& os, SimpleInterval a) { ...@@ -255,8 +256,11 @@ llvm::raw_ostream& operator<<(llvm::raw_ostream& os, SimpleInterval a) {
} else if(a.isTop()) { } else if(a.isTop()) {
os << "T"; os << "T";
} else { } else {
os << "[" << a.begin.toString(10, a.begin.getBitWidth() > 1) << ", " os << "[" ;
<< a.end.toString(10, a.begin.getBitWidth() > 1) << "]"; a.begin.print(os,a.begin.getBitWidth() > 1);
os << ", ";
a.end.print(os,a.begin.getBitWidth() > 1);
os << "]";
} }
return os; return os;
} }
...@@ -267,8 +271,12 @@ void SimpleInterval::printOut() const { ...@@ -267,8 +271,12 @@ void SimpleInterval::printOut() const {
} else if(state == TOP) { } else if(state == TOP) {
llvm::errs() << "T"; llvm::errs() << "T";
} else { } else {
llvm::errs() << "[" << begin.toString(10, begin.getBitWidth() > 1) << ", " llvm::SmallString<128> str;
<< end.toString(10, begin.getBitWidth() > 1) << "]"; begin.toString(str,10,true);
begin.toString(str,10, begin.getBitWidth() > 1);
llvm::errs() << "[" << str << ", ";
end.toString(str,10, begin.getBitWidth() > 1);
llvm::errs() << str << "]";
} }
llvm::errs() << '\n'; llvm::errs() << '\n';
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment