Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump LLVM from 13.0.0 to 15.0.0 #901

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 39 additions & 49 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,26 @@ jobs=4
SVFHOME=$(pwd)
sysOS=$(uname -s)
arch=$(uname -m)
MacLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz"
UbuntuLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz"
UbuntuArmLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-aarch64-linux-gnu.tar.xz"
SourceLLVM="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-13.0.0.zip"
MacArmLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/clang+llvm-15.0.0-arm64-apple-darwin21.0.tar.xz"
MacLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/clang+llvm-15.0.0-x86_64-apple-darwin.tar.xz"
UbuntuArmLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/clang+llvm-15.0.0-aarch64-linux-gnu.tar.xz"
SourceLLVM="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-15.0.0.zip"
MacZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-osx-10.14.6.zip"
MacArmZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.9.1/z3-4.9.1-arm64-osx-11.0.zip"
UbuntuZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-ubuntu-16.04.zip"
SourceZ3="https://github.com/Z3Prover/z3/archive/refs/tags/z3-4.8.8.zip"

# Keep LLVM version suffix for version checking and better debugging
# keep the version consistent with LLVM_DIR in setup.sh and llvm_version in Dockerfile
LLVMHome="llvm-13.0.0.obj"
LLVMHome="llvm-15.0.0.obj"
Z3Home="z3.obj"


# Downloads $1 (URL) to $2 (target destination) using wget or curl,
# depending on OS.
# E.g. generic_download_file www.url.com/my.zip loc/my.zip
function generic_download_file {
if [ $# -ne 2 ]
then
if [ $# -ne 2 ]; then
echo "$0: bad args to generic_download_file!"
exit 1
fi
Expand Down Expand Up @@ -115,7 +114,7 @@ function build_llvm_from_source {
mkdir llvm-build
cd llvm-build
# /*/ is a dirty hack to get llvm-project-llvmorg-version...
cmake -DCMAKE_INSTALL_PREFIX="$SVFHOME/$LLVMHome" ../llvm-source/*/llvm
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$SVFHOME/$LLVMHome" ../llvm-source/*/llvm
make -j${jobs}
make install

Expand All @@ -132,27 +131,23 @@ OSDisplayName=""
# Set OS-specific values, mainly URLs to download binaries from.
# M1 Macs give back arm64, some Linuxes can give aarch64 for arm architecture
#######
if [[ $sysOS == "Darwin" ]]
then
if [[ "$arch" == "arm64" ]]
then
urlZ3="$MacArmZ3"
urlLLVM="llvm does not have osx arm pre-built libs"
if [[ $sysOS == "Darwin" ]]; then
if [[ "$arch" == "arm64" ]]; then
urlZ3="$MacArmZ3"
urlLLVM="$MacArmLLVM"
OSDisplayName="macOS arm64"
else
else
urlZ3="$MacZ3"
urlLLVM="$MacLLVM"
OSDisplayName="macOS x86"
fi
elif [[ $sysOS == "Linux" ]]
then
if [[ "$arch" == "aarch64" ]]
then
urlLLVM="$UbuntuArmLLVM"
elif [[ $sysOS == "Linux" ]]; then
if [[ "$arch" == "aarch64" ]]; then
urlLLVM="$UbuntuArmLLVM"
urlZ3="z3 does not have x86 arm pre-built libs"
OSDisplayName="Ubuntu arm64"
else
urlLLVM="$UbuntuLLVM"
else
urlLLVM="x86_64 Linux does not have pre-built LLVM libs"
urlZ3="$UbuntuZ3"
OSDisplayName="Ubuntu x86"
fi
Expand All @@ -163,14 +158,13 @@ fi
########
# Download LLVM if need be.
#######
if [ ! -d "$LLVM_DIR" ]
then
if [ ! -d "$LLVMHome" ]
then
if [ "$sysOS" = "Darwin" ] && [ "$arch" = "arm64" ] # only mac arm build from source
then
if [ ! -d "$LLVM_DIR" ]; then
if [ ! -d "$LLVMHome" ]; then
if [[ "$sysOS" = "Linux" && "$arch" = "x86_64" ]]; then
# x86_64 Linux has to build LLVM from source
build_llvm_from_source
else # everything else downloads pre-built lib includ osx "arm64"
else
# everything else downloads pre-built lib includ osx "arm64"
echo "Downloading LLVM binary for $OSDisplayName"
generic_download_file "$urlLLVM" llvm.tar.xz
check_xz
Expand All @@ -191,10 +185,11 @@ then
if [ ! -d "$Z3Home" ]
then
# M1 Macs give back arm64, some Linuxes can give aarch64.
if [ "$sysOS" = "Linux" ] && [ "$arch" = "aarch64" ] # only linux arm build from source
then
if [[ "$sysOS" = "Linux" && "$arch" = "aarch64" ]]; then
# only linux arm build from source
build_z3_from_source
else # everything else downloads pre-built lib includ osx "arm64"
else
# everything else downloads pre-built lib includ osx "arm64"
echo "Downloading Z3 binary for $OSDisplayName"
generic_download_file "$urlZ3" z3.zip
check_unzip
Expand All @@ -214,30 +209,25 @@ echo "Z3_DIR=$Z3_DIR"
########
# Build SVF
########
if [[ $1 == 'debug' ]]
then
rm -rf ./'Debug-build'
mkdir ./'Debug-build'
cd ./'Debug-build'
cmake -D CMAKE_BUILD_TYPE:STRING=Debug ../
if [[ $1 =~ [Dd]ebug ]]; then
build_type='Debug'
else
rm -rf ./'Release-build'
mkdir ./'Release-build'
cd ./'Release-build'
cmake ../
fi
build_type='Release'
fi
build_dir="./${build_type}-build"

rm -rf "${build_dir}"
mkdir "${build_dir}"
cd "${build_dir}"
cmake -D CMAKE_BUILD_TYPE:STRING=$build_type ../

make -j ${jobs}

########
# Set up environment variables of SVF
########
cd ../
if [[ $1 == 'debug' ]]
then
. ./setup.sh debug
else
. ./setup.sh
fi
source ./setup.sh "${build_type}"

#########
# Optionally, you can also specify a CXX_COMPILER and your $LLVM_HOME for your build
Expand Down
72 changes: 48 additions & 24 deletions include/Graphs/ConsGNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,103 +259,127 @@ class ConstraintNode : public GenericConsNodeTy
storeInEdges.insert(inEdge);
addIncomingEdge(inEdge);
}
inline void addIncomingDirectEdge(ConstraintEdge* inEdge)
inline bool addIncomingDirectEdge(ConstraintEdge* inEdge)
{
assert(inEdge->getDstID() == this->getId());
bool added1 = directInEdges.insert(inEdge).second;
bool added2 = addIncomingEdge(inEdge);
assert(added1 && added2 && "edge not added, duplicated adding!!");
bool both_added = added1 & added2;
assert(both_added && "edge not added, duplicated adding!!");
return both_added;
}
inline void addOutgoingAddrEdge(AddrCGEdge* outEdge)
{
addressOutEdges.insert(outEdge);
addOutgoingEdge(outEdge);
}
inline void addOutgoingLoadEdge(LoadCGEdge* outEdge)
inline bool addOutgoingLoadEdge(LoadCGEdge* outEdge)
{
bool added1 = loadOutEdges.insert(outEdge).second;
bool added2 = addOutgoingEdge(outEdge);
assert(added1 && added2 && "edge not added, duplicated adding!!");
bool both_added = added1 & added2;
assert(both_added && "edge not added, duplicated adding!!");
return both_added;
}
inline void addOutgoingStoreEdge(StoreCGEdge* outEdge)
inline bool addOutgoingStoreEdge(StoreCGEdge* outEdge)
{
bool added1 = storeOutEdges.insert(outEdge).second;
bool added2 = addOutgoingEdge(outEdge);
assert(added1 && added2 && "edge not added, duplicated adding!!");
bool both_added = added1 & added2;
assert(both_added && "edge not added, duplicated adding!!");
return both_added;
}
inline void addOutgoingDirectEdge(ConstraintEdge* outEdge)
inline bool addOutgoingDirectEdge(ConstraintEdge* outEdge)
{
assert(outEdge->getSrcID() == this->getId());
bool added1 = directOutEdges.insert(outEdge).second;
bool added2 = addOutgoingEdge(outEdge);
assert(added1 && added2 && "edge not added, duplicated adding!!");
bool both_added = added1 & added2;
assert(both_added && "edge not added, duplicated adding!!");
return both_added;
}
//@}

/// Remove constraint graph edges
//{@
inline void removeOutgoingAddrEdge(AddrCGEdge* outEdge)
inline bool removeOutgoingAddrEdge(AddrCGEdge* outEdge)
{
u32_t num1 = addressOutEdges.erase(outEdge);
u32_t num2 = removeOutgoingEdge(outEdge);
assert((num1 && num2) && "edge not in the set, can not remove!!!");
bool removed = (num1 > 0) & (num2 > 0);
assert(removed && "edge not in the set, can not remove!!!");
return removed;
}

inline void removeIncomingAddrEdge(AddrCGEdge* inEdge)
inline bool removeIncomingAddrEdge(AddrCGEdge* inEdge)
{
u32_t num1 = addressInEdges.erase(inEdge);
u32_t num2 = removeIncomingEdge(inEdge);
assert((num1 && num2) && "edge not in the set, can not remove!!!");
bool removed = (num1 > 0) & (num2 > 0);
assert(removed && "edge not in the set, can not remove!!!");
return removed;
}

inline void removeOutgoingDirectEdge(ConstraintEdge* outEdge)
inline bool removeOutgoingDirectEdge(ConstraintEdge* outEdge)
{
if (SVFUtil::isa<GepCGEdge>(outEdge))
gepOutEdges.erase(outEdge);
else
copyOutEdges.erase(outEdge);
u32_t num1 = directOutEdges.erase(outEdge);
u32_t num2 = removeOutgoingEdge(outEdge);
assert((num1 && num2) && "edge not in the set, can not remove!!!");
bool removed = (num1 > 0) & (num2 > 0);
assert(removed && "edge not in the set, can not remove!!!");
return removed;
}

inline void removeIncomingDirectEdge(ConstraintEdge* inEdge)
inline bool removeIncomingDirectEdge(ConstraintEdge* inEdge)
{
if (SVFUtil::isa<GepCGEdge>(inEdge))
gepInEdges.erase(inEdge);
else
copyInEdges.erase(inEdge);
u32_t num1 = directInEdges.erase(inEdge);
u32_t num2 = removeIncomingEdge(inEdge);
assert((num1 && num2) && "edge not in the set, can not remove!!!");
bool removed = (num1 > 0) & (num2 > 0);
assert(removed && "edge not in the set, can not remove!!!");
return removed;
}

inline void removeOutgoingLoadEdge(LoadCGEdge* outEdge)
inline bool removeOutgoingLoadEdge(LoadCGEdge* outEdge)
{
u32_t num1 = loadOutEdges.erase(outEdge);
u32_t num2 = removeOutgoingEdge(outEdge);
assert((num1 && num2) && "edge not in the set, can not remove!!!");
bool removed = (num1 > 0) & (num2 > 0);
assert(removed && "edge not in the set, can not remove!!!");
return removed;
}

inline void removeIncomingLoadEdge(LoadCGEdge* inEdge)
inline bool removeIncomingLoadEdge(LoadCGEdge* inEdge)
{
u32_t num1 = loadInEdges.erase(inEdge);
u32_t num2 = removeIncomingEdge(inEdge);
assert((num1 && num2) && "edge not in the set, can not remove!!!");
bool removed = (num1 > 0) & (num2 > 0);
assert(removed && "edge not in the set, can not remove!!!");
return removed;
}

inline void removeOutgoingStoreEdge(StoreCGEdge* outEdge)
inline bool removeOutgoingStoreEdge(StoreCGEdge* outEdge)
{
u32_t num1 = storeOutEdges.erase(outEdge);
u32_t num2 = removeOutgoingEdge(outEdge);
assert((num1 && num2) && "edge not in the set, can not remove!!!");
bool removed = (num1 > 0) & (num2 > 0);
assert(removed && "edge not in the set, can not remove!!!");
return removed;
}

inline void removeIncomingStoreEdge(StoreCGEdge* inEdge)
inline bool removeIncomingStoreEdge(StoreCGEdge* inEdge)
{
u32_t num1 = storeInEdges.erase(inEdge);
u32_t num2 = removeIncomingEdge(inEdge);
assert((num1 && num2) && "edge not in the set, can not remove!!!");
bool removed = (num1 > 0) & (num2 > 0);
assert(removed && "edge not in the set, can not remove!!!");
return removed;
}
//@}

Expand Down
6 changes: 4 additions & 2 deletions include/Graphs/GenericGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,15 @@ class GenericNode
{
iterator it = InEdges.find(edge);
assert(it != InEdges.end() && "can not find in edge in SVFG node");
return InEdges.erase(edge);
InEdges.erase(it);
return 1;
}
inline u32_t removeOutgoingEdge(EdgeType* edge)
{
iterator it = OutEdges.find(edge);
assert(it != OutEdges.end() && "can not find out edge in SVFG node");
return OutEdges.erase(edge);
OutEdges.erase(it);
return 1;
}
///@}

Expand Down
5 changes: 3 additions & 2 deletions include/Graphs/ICFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ class ICFG : public GenericICFGTy
{
bool added1 = edge->getDstNode()->addIncomingEdge(edge);
bool added2 = edge->getSrcNode()->addOutgoingEdge(edge);
assert(added1 && added2 && "edge not added??");
return true;
bool all_added = added1 && added2;
assert(all_added && "ICFGEdge not added?");
return all_added;
}

/// Add a ICFG node
Expand Down
14 changes: 7 additions & 7 deletions include/Graphs/SVFGOPT.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,23 +261,23 @@ class SVFGOPT : public SVFG
{
PAGNodeToDefMapTy::iterator it = PAGNodeToDefMap.find(pagNode);
assert(it != PAGNodeToDefMap.end() && "a SVFIR node doesn't have definition before");
PAGNodeToDefMap[pagNode] = node->getId();
it->second = node->getId();
}

/// Set def-site of actual-in/formal-out.
///@{
inline void setActualINDef(NodeID ai, NodeID def)
{
NodeIDToNodeIDMap::const_iterator it = actualInToDefMap.find(ai);
assert(it == actualInToDefMap.end() && "can not set actual-in's def twice");
actualInToDefMap[ai] = def;
bool inserted = actualInToDefMap.emplace(ai, def).second;
(void) inserted; // Make compiler happy
assert(inserted && "can not set actual-in's def twice");
defNodes.set(def);
}
inline void setFormalOUTDef(NodeID fo, NodeID def)
{
NodeIDToNodeIDMap::const_iterator it = formalOutToDefMap.find(fo);
assert(it == formalOutToDefMap.end() && "can not set formal-out's def twice");
formalOutToDefMap[fo] = def;
bool inserted = formalOutToDefMap.emplace(fo, def).second;
(void) inserted;
assert(inserted && "can not set formal-out's def twice");
defNodes.set(def);
}
///@}
Expand Down
5 changes: 3 additions & 2 deletions include/Graphs/VFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,9 @@ class VFG : public GenericVFGTy
{
bool added1 = edge->getDstNode()->addIncomingEdge(edge);
bool added2 = edge->getSrcNode()->addOutgoingEdge(edge);
assert(added1 && added2 && "edge not added??");
return true;
bool both_added = added1 & added2;
assert(both_added && "VFGEdge not added??");
return both_added;
}

protected:
Expand Down
Loading