Skip to content

Commit

Permalink
Merge pull request #567 from xushengj/LLVM14
Browse files Browse the repository at this point in the history
Add support for LLVM 13 release
  • Loading branch information
yuleisui authored Dec 4, 2021
2 parents 08e2e4f + dc58ea5 commit 2a63f63
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 50 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/github-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,29 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, macos-latest]
os: [ubuntu-18.04, macos-11]
steps:
# checkout the repo
- uses: actions/checkout@v2
# setup the environment
# setup the environment
- name: mac-setup
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 12.5.1
- name: mac-setup-workaround
if: runner.os == 'macOS'
run: ln -sfn /Applications/Xcode_12.5.1.app /Applications/Xcode.app
- name: ubuntu-setup
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install cmake gcc g++ nodejs doxygen graphviz
- name: env-setup
run: |
echo $RUNNER_OS
if [ "$RUNNER_OS" = "Linux" ]; then sudo apt-get update ; fi
if [ "$RUNNER_OS" = "Linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test ; fi
if [ "$RUNNER_OS" = "Linux" ]; then sudo apt-get update ; fi
if [ "$RUNNER_OS" = "Linux" ]; then sudo apt-get install cmake gcc g++ nodejs doxygen graphviz; fi
if [ "$RUNNER_OS" = "macOS" ]; then export SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk" ; fi
if [ "${{github.event_name}}" = "push" ] && [ "${{github.ref == 'refs/heads/master' }}" ]; then
git config --global user.email ${{secrets.npm_email}}
git config --global user.name "GitHub Actions Build"
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4.3)
cmake_minimum_required(VERSION 3.13.4)

project("SVF")

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV DEBIAN_FRONTEND noninteractive
RUN set -e

# Define LLVM version.
ENV llvm_version=12.0.0
ENV llvm_version=13.0.0

# Define home directory
ENV HOME=/home/SVF-tools
Expand Down
9 changes: 6 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
########
SVFHOME=$(pwd)
sysOS=$(uname -s)
MacLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz"
UbuntuLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz"
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"
MacZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-osx-10.14.6.zip"
UbuntuZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-ubuntu-16.04.zip"
MacCTIR="https://github.com/mbarbar/ctir/releases/download/ctir-10.c3/ctir-clang-v10.c3-macos10.15.zip"
UbuntuCTIR="https://github.com/mbarbar/ctir/releases/download/ctir-10.c3/ctir-clang-v10.c3-ubuntu18.04.zip"
LLVMHome="llvm-12.0.0.obj"

# 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"
Z3Home="z3.obj"
CTIRHome="ctir.obj"

Expand Down
3 changes: 2 additions & 1 deletion include/Graphs/GraphPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <system_error>
#include <llvm/Support/ToolOutputFile.h>
#include <llvm/Support/FileSystem.h> // for file open flag
#include <llvm/ADT/GraphTraits.h>

namespace llvm
{
Expand All @@ -60,7 +61,7 @@ class GraphPrinter
std::string Filename = GraphName + ".dot";
O << "Writing '" << Filename << "'...";
std::error_code ErrInfo;
llvm::ToolOutputFile F(Filename.c_str(), ErrInfo, llvm::sys::fs::F_None);
llvm::ToolOutputFile F(Filename.c_str(), ErrInfo, llvm::sys::fs::OF_None);

if (!ErrInfo)
{
Expand Down
2 changes: 1 addition & 1 deletion include/MemoryModel/MutablePointsToDS.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ class MutableDFPTData : public DFPTData<Key, KeySet, Data, DataSet>
mutPTData.dumpPTData();
/// dump points-to of address-taken variables
std::error_code ErrInfo;
ToolOutputFile F("svfg_pts.data", ErrInfo, llvm::sys::fs::F_None);
ToolOutputFile F("svfg_pts.data", ErrInfo, llvm::sys::fs::OF_None);
if (!ErrInfo)
{
raw_fd_ostream & osm = F.os();
Expand Down
8 changes: 4 additions & 4 deletions include/MemoryModel/PointerAnalysisImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,15 @@ class CondPTAImpl : public PointerAnalysis
CPtSet cpts2;
expandFIObjs(pts2,cpts2);
if (containBlackHoleNode(cpts1) || containBlackHoleNode(cpts2))
return llvm::MayAlias;
return llvm::AliasResult::MayAlias;
else if(this->getAnalysisTy()==PathS_DDA && contains(cpts1,cpts2) && contains(cpts2,cpts1))
{
return llvm::MustAlias;
return llvm::AliasResult::MustAlias;
}
else if(overlap(cpts1,cpts2))
return llvm::MayAlias;
return llvm::AliasResult::MayAlias;
else
return llvm::NoAlias;
return llvm::AliasResult::NoAlias;
}
/// Test blk node for cpts
inline bool containBlackHoleNode(const CPtSet& cpts)
Expand Down
2 changes: 1 addition & 1 deletion include/Util/BasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class CallSite {
unsigned arg_size() const { return CB->arg_size(); }
bool arg_empty() const { return CB->arg_empty(); }
Value *getArgOperand(unsigned i) const { return CB->getArgOperand(i); }
unsigned getNumArgOperands() const { return CB->getNumArgOperands(); }
unsigned getNumArgOperands() const { return CB->arg_size(); }
Function *getCalledFunction() const { return CB->getCalledFunction(); }
Value *getCalledValue() const { return CB->getCalledOperand(); }
Function *getCaller() const { return CB->getCaller(); }
Expand Down
2 changes: 1 addition & 1 deletion lib/DDA/DDAPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ AliasResult DDAPass::alias(const Value* V1, const Value* V2)
return _pta->alias(V1,V2);
}

return llvm::MayAlias;
return llvm::AliasResult::MayAlias;
}

/*!
Expand Down
14 changes: 7 additions & 7 deletions lib/MemoryModel/PointerAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,24 +592,24 @@ void PointerAnalysis::validateSuccessTests(std::string fun)
bool checkSuccessful = false;
if (fun == aliasTestMayAlias || fun == aliasTestMayAliasMangled)
{
if (aliasRes == llvm::MayAlias || aliasRes == llvm::MustAlias)
if (aliasRes == llvm::AliasResult::MayAlias || aliasRes == llvm::AliasResult::MustAlias)
checkSuccessful = true;
}
else if (fun == aliasTestNoAlias || fun == aliasTestNoAliasMangled)
{
if (aliasRes == llvm::NoAlias)
if (aliasRes == llvm::AliasResult::NoAlias)
checkSuccessful = true;
}
else if (fun == aliasTestMustAlias || fun == aliasTestMustAliasMangled)
{
// change to must alias when our analysis support it
if (aliasRes == llvm::MayAlias || aliasRes == llvm::MustAlias)
if (aliasRes == llvm::AliasResult::MayAlias || aliasRes == llvm::AliasResult::MustAlias)
checkSuccessful = true;
}
else if (fun == aliasTestPartialAlias || fun == aliasTestPartialAliasMangled)
{
// change to partial alias when our analysis support it
if (aliasRes == llvm::MayAlias)
if (aliasRes == llvm::AliasResult::MayAlias)
checkSuccessful = true;
}
else
Expand Down Expand Up @@ -650,7 +650,7 @@ void PointerAnalysis::validateExpectedFailureTests(std::string fun)
checkFun->getLLVMFun()->user_end(); i != e; ++i)
if (CallInst *call = SVFUtil::dyn_cast<CallInst>(*i))
{
assert(call->getNumArgOperands() == 2
assert(call->arg_size() == 2
&& "arguments should be two pointers!!");
Value* V1 = call->getArgOperand(0);
Value* V2 = call->getArgOperand(1);
Expand All @@ -660,13 +660,13 @@ void PointerAnalysis::validateExpectedFailureTests(std::string fun)
if (fun == aliasTestFailMayAlias || fun == aliasTestFailMayAliasMangled)
{
// change to must alias when our analysis support it
if (aliasRes == llvm::NoAlias)
if (aliasRes == llvm::AliasResult::NoAlias)
expectedFailure = true;
}
else if (fun == aliasTestFailNoAlias || fun == aliasTestFailNoAliasMangled)
{
// change to partial alias when our analysis support it
if (aliasRes == llvm::MayAlias || aliasRes == llvm::PartialAlias || aliasRes == llvm::MustAlias)
if (aliasRes == llvm::AliasResult::MayAlias || aliasRes == llvm::AliasResult::PartialAlias || aliasRes == llvm::AliasResult::MustAlias)
expectedFailure = true;
}
else
Expand Down
6 changes: 3 additions & 3 deletions lib/MemoryModel/PointerAnalysisImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void BVDataPTAImpl::writeToFile(const string& filename)
outs() << "Storing pointer analysis results to '" << filename << "'...";

error_code err;
ToolOutputFile F(filename.c_str(), err, llvm::sys::fs::F_None);
ToolOutputFile F(filename.c_str(), err, llvm::sys::fs::OF_None);
if (err)
{
outs() << " error opening file for writing!\n";
Expand Down Expand Up @@ -477,7 +477,7 @@ AliasResult BVDataPTAImpl::alias(const PointsTo& p1, const PointsTo& p2)
expandFIObjs(p2,pts2);

if (containBlackHoleNode(pts1) || containBlackHoleNode(pts2) || pts1.intersects(pts2))
return llvm::MayAlias;
return llvm::AliasResult::MayAlias;
else
return llvm::NoAlias;
return llvm::AliasResult::NoAlias;
}
2 changes: 1 addition & 1 deletion lib/SVF-FE/Graph2Json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void ICFGPrinter::printICFGToJson(const std::string& filename)
{
outs() << "write symbols to '" << filename << "'...";
std::error_code err;
ToolOutputFile F(filename.c_str(), err, llvm::sys::fs::F_None);
ToolOutputFile F(filename.c_str(), err, llvm::sys::fs::OF_None);
if (err)
{
outs() << " error opening file for writing!\n";
Expand Down
2 changes: 1 addition & 1 deletion lib/SVF-FE/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ void LLVMModuleSet::dumpModulesToFile(const std::string suffix)
OutputFilename = moduleName + suffix;

std::error_code EC;
raw_fd_ostream OS(OutputFilename.c_str(), EC, llvm::sys::fs::F_None);
raw_fd_ostream OS(OutputFilename.c_str(), EC, llvm::sys::fs::OF_None);

#if (LLVM_VERSION_MAJOR >= 7)
WriteBitcodeToFile(mod, OS);
Expand Down
12 changes: 6 additions & 6 deletions lib/Util/TypeBasedHeapCloning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,37 +656,37 @@ void TypeBasedHeapCloning::validateTBHCTests(SVFModule*)
if (fn->getName() == PointerAnalysis::aliasTestMayAlias
|| fn->getName() == PointerAnalysis::aliasTestMayAliasMangled)
{
passed = res == llvm::MayAlias || res == llvm::MustAlias;
passed = res == llvm::AliasResult::MayAlias || res == llvm::AliasResult::MustAlias;
testName = PointerAnalysis::aliasTestMayAlias;
}
else if (fn->getName() == PointerAnalysis::aliasTestNoAlias
|| fn->getName() == PointerAnalysis::aliasTestNoAliasMangled)
{
passed = res == llvm::NoAlias;
passed = res == llvm::AliasResult::NoAlias;
testName = PointerAnalysis::aliasTestNoAlias;
}
else if (fn->getName() == PointerAnalysis::aliasTestMustAlias
|| fn->getName() == PointerAnalysis::aliasTestMustAliasMangled)
{
passed = res == llvm::MustAlias || res == llvm::MayAlias;
passed = res == llvm::AliasResult::MustAlias || res == llvm::AliasResult::MayAlias;
testName = PointerAnalysis::aliasTestMustAlias;
}
else if (fn->getName() == PointerAnalysis::aliasTestPartialAlias
|| fn->getName() == PointerAnalysis::aliasTestPartialAliasMangled)
{
passed = res == llvm::MayAlias || res == llvm::PartialAlias;
passed = res == llvm::AliasResult::MayAlias || res == llvm::AliasResult::PartialAlias;
testName = PointerAnalysis::aliasTestPartialAlias;
}
else if (fn->getName() == PointerAnalysis::aliasTestFailMayAlias
|| fn->getName() == PointerAnalysis::aliasTestFailMayAliasMangled)
{
passed = res != llvm::MayAlias && res != llvm::MustAlias && res != llvm::PartialAlias;
passed = res != llvm::AliasResult::MayAlias && res != llvm::AliasResult::MustAlias && res != llvm::AliasResult::PartialAlias;
testName = PointerAnalysis::aliasTestFailMayAlias;
}
else if (fn->getName() == PointerAnalysis::aliasTestFailNoAlias
|| fn->getName() == PointerAnalysis::aliasTestFailNoAliasMangled)
{
passed = res != llvm::NoAlias;
passed = res != llvm::AliasResult::NoAlias;
testName = PointerAnalysis::aliasTestFailNoAlias;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/WPA/FlowSensitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,10 @@ void FlowSensitive::countAliases(Set<std::pair<NodeID, NodeID>> cmp, unsigned *m

switch (alias(p, q))
{
case llvm::NoAlias:
case llvm::AliasResult::NoAlias:
++(*noAliases);
break;
case llvm::MayAlias:
case llvm::AliasResult::MayAlias:
++(*mayAliases);
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions lib/WPA/FlowSensitiveTBHC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,10 @@ void FlowSensitiveTBHC::countAliases(Set<std::pair<NodeID, NodeID>> cmp, unsigne

switch (alias(aPts, bPts))
{
case llvm::NoAlias:
case llvm::AliasResult::NoAlias:
++(*noAliases);
break;
case llvm::MayAlias:
case llvm::AliasResult::MayAlias:
++(*mayAliases);
break;
default:
Expand Down
14 changes: 7 additions & 7 deletions lib/WPA/WPAPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void WPAPass::PrintAliasPairs(PointerAnalysis* pta)
AliasResult WPAPass::alias(const Value* V1, const Value* V2)
{

AliasResult result = llvm::MayAlias;
AliasResult result = llvm::AliasResult::MayAlias;

PAG* pag = _pta->getPAG();

Expand All @@ -217,25 +217,25 @@ AliasResult WPAPass::alias(const Value* V1, const Value* V2)
if (Options::AliasRule.getBits() == 0 || Options::AliasRule.isSet(Veto))
{
/// Return NoAlias if any PTA gives NoAlias result
result = llvm::MayAlias;
result = llvm::AliasResult::MayAlias;

for (PTAVector::const_iterator it = ptaVector.begin(), eit = ptaVector.end();
it != eit; ++it)
{
if ((*it)->alias(V1, V2) == llvm::NoAlias)
result = llvm::NoAlias;
if ((*it)->alias(V1, V2) == llvm::AliasResult::NoAlias)
result = llvm::AliasResult::NoAlias;
}
}
else if (Options::AliasRule.isSet(Conservative))
{
/// Return MayAlias if any PTA gives MayAlias result
result = llvm::NoAlias;
result = llvm::AliasResult::NoAlias;

for (PTAVector::const_iterator it = ptaVector.begin(), eit = ptaVector.end();
it != eit; ++it)
{
if ((*it)->alias(V1, V2) == llvm::MayAlias)
result = llvm::MayAlias;
if ((*it)->alias(V1, V2) == llvm::AliasResult::MayAlias)
result = llvm::AliasResult::MayAlias;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function set_llvm {
[ -n "$LLVM_DIR" ] && return 0

# use local download directory
LLVM_DIR="$SVF_DIR/llvm-12.0.0.obj"
LLVM_DIR="$SVF_DIR/llvm-13.0.0.obj"
[ -d "$LLVM_DIR" ] && return 0

# ... otherwise don't set LLVM_DIR
Expand Down

0 comments on commit 2a63f63

Please sign in to comment.