From 7f1560ed76fed633775fd265741b2d7cc2482889 Mon Sep 17 00:00:00 2001 From: Jack Anthony Date: Sat, 13 Jan 2018 09:43:16 +0000 Subject: [PATCH 1/3] Update for LLVM 5.0.0 --- include/Util/DataFlowUtil.h | 4 ++-- lib/MSSA/MemSSA.cpp | 6 +++--- lib/MemoryModel/PAGBuilder.cpp | 4 ++-- lib/Util/DataFlowUtil.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/Util/DataFlowUtil.h b/include/Util/DataFlowUtil.h index b441d7760..b51d544aa 100644 --- a/include/Util/DataFlowUtil.h +++ b/include/Util/DataFlowUtil.h @@ -207,7 +207,7 @@ class PTACFInfoBuilder { /*! * Iterated dominance frontier */ -class IteratedDominanceFrontier: public llvm::DominanceFrontierBase { +class IteratedDominanceFrontier: public llvm::DominanceFrontierBase { private: const llvm::DominanceFrontier *DF; @@ -218,7 +218,7 @@ class IteratedDominanceFrontier: public llvm::DominanceFrontierBase(false), DF(NULL) { + llvm::DominanceFrontierBase(), DF(NULL) { } virtual ~IteratedDominanceFrontier() { diff --git a/lib/MSSA/MemSSA.cpp b/lib/MSSA/MemSSA.cpp index eff9623df..1643986e7 100644 --- a/lib/MSSA/MemSSA.cpp +++ b/lib/MSSA/MemSSA.cpp @@ -236,13 +236,13 @@ void MemSSA::insertPHI(const Function& fun) { while (!bbs.empty()) { const BasicBlock* bb = bbs.back(); bbs.pop_back(); - DominanceFrontierBase::const_iterator it = df->find(const_cast(bb)); + DominanceFrontierBase::const_iterator it = df->find(const_cast(bb)); if(it == df->end()) { wrnMsg("bb not in the dominance frontier map??"); continue; } - const DominanceFrontierBase::DomSetType& domSet = it->second; - for (DominanceFrontierBase::DomSetType::const_iterator bit = + const DominanceFrontierBase::DomSetType& domSet = it->second; + for (DominanceFrontierBase::DomSetType::const_iterator bit = domSet.begin(); bit != domSet.end(); ++bit) { const BasicBlock* pbb = *bit; // if we never insert this phi node before diff --git a/lib/MemoryModel/PAGBuilder.cpp b/lib/MemoryModel/PAGBuilder.cpp index 43dc1a3f3..7f6af6cd5 100644 --- a/lib/MemoryModel/PAGBuilder.cpp +++ b/lib/MemoryModel/PAGBuilder.cpp @@ -985,7 +985,7 @@ void PAGBuilder::handleExtCall(CallSite cs, const Function *callee) { /// apr_thread_create has 2 arg. assert((forkedFun->arg_size() <= 2) && "Size of formal parameter of start routine should be one"); if(forkedFun->arg_size() <= 2 && forkedFun->arg_size() >= 1) { - const Argument* formalParm = &(forkedFun->getArgumentList().front()); + const Argument* formalParm = &(*forkedFun->arg_begin()); /// Connect actual parameter to formal parameter of the start routine if(isa(actualParm->getType()) && isa(formalParm->getType()) ) pag->addThreadForkEdge(pag->getValueNode(actualParm), pag->getValueNode(formalParm),inst); @@ -1008,7 +1008,7 @@ void PAGBuilder::handleExtCall(CallSite cs, const Function *callee) { /// The task function of hare_parallel_for has 3 args. assert((taskFunc->arg_size() == 3) && "Size of formal parameter of hare_parallel_for's task routine should be 3"); const Value* actualParm = getTaskDataAtHareParForSite(inst); - const Argument* formalParm = &(taskFunc->getArgumentList().front()); + const Argument* formalParm = &(*taskFunc->arg_begin()); /// Connect actual parameter to formal parameter of the start routine if(isa(actualParm->getType()) && isa(formalParm->getType()) ) pag->addThreadForkEdge(pag->getValueNode(actualParm), pag->getValueNode(formalParm),inst); diff --git a/lib/Util/DataFlowUtil.cpp b/lib/Util/DataFlowUtil.cpp index 7068088c5..0e084561c 100644 --- a/lib/Util/DataFlowUtil.cpp +++ b/lib/Util/DataFlowUtil.cpp @@ -40,7 +40,7 @@ void IteratedDominanceFrontier::calculate(llvm::BasicBlock * bb, DomSetType worklist; - DominanceFrontierBase::const_iterator it = DF.find(bb); + DominanceFrontierBase::const_iterator it = DF.find(bb); assert(it != DF.end()); worklist.insert(it->second.begin(), it->second.end()); From 10f28a8d1c9d04b3597b5cbb2b1cc75a209e10b4 Mon Sep 17 00:00:00 2001 From: Jack Anthony Date: Sat, 17 Mar 2018 11:18:31 +0000 Subject: [PATCH 2/3] Update for LLVM 6.0.0 --- include/MemoryModel/PointsToDFDS.h | 2 +- include/Util/GraphUtil.h | 2 +- lib/MemoryModel/PointerAnalysis.cpp | 2 +- lib/Util/AnalysisUtil.cpp | 12 +++++++----- tests/runtest.sh | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/MemoryModel/PointsToDFDS.h b/include/MemoryModel/PointsToDFDS.h index 2d84f77d5..a4e17b542 100644 --- a/include/MemoryModel/PointsToDFDS.h +++ b/include/MemoryModel/PointsToDFDS.h @@ -200,7 +200,7 @@ class DFPTData : public PTData { PTData::dumpPts(this->ptsMap); /// dump points-to of address-taken variables std::error_code ErrInfo; - llvm::tool_output_file F("svfg_pts.data", ErrInfo, llvm::sys::fs::F_None); + llvm::ToolOutputFile F("svfg_pts.data", ErrInfo, llvm::sys::fs::F_None); if (!ErrInfo) { llvm::raw_fd_ostream & osm = F.os(); NodeBS locs; diff --git a/include/Util/GraphUtil.h b/include/Util/GraphUtil.h index 545c76916..de8cc1042 100644 --- a/include/Util/GraphUtil.h +++ b/include/Util/GraphUtil.h @@ -58,7 +58,7 @@ class GraphPrinter { std::string Filename = GraphName + ".dot"; O << "Writing '" << Filename << "'..."; std::error_code ErrInfo; - tool_output_file F(Filename.c_str(), ErrInfo, sys::fs::F_None); + ToolOutputFile F(Filename.c_str(), ErrInfo, sys::fs::F_None); if (!ErrInfo) { // dump the ValueFlowGraph here diff --git a/lib/MemoryModel/PointerAnalysis.cpp b/lib/MemoryModel/PointerAnalysis.cpp index 49e0cf17d..c9d3d7cbc 100644 --- a/lib/MemoryModel/PointerAnalysis.cpp +++ b/lib/MemoryModel/PointerAnalysis.cpp @@ -341,7 +341,7 @@ void BVDataPTAImpl::writeToFile(const string& filename) { outs() << "Storing pointer analysis results to '" << filename << "'..."; error_code err; - tool_output_file F(filename.c_str(), err, sys::fs::F_None); + ToolOutputFile F(filename.c_str(), err, sys::fs::F_None); if (err) { outs() << " error opening file for writing!\n"; F.os().clear_error(); diff --git a/lib/Util/AnalysisUtil.cpp b/lib/Util/AnalysisUtil.cpp index 6c1f43e27..2bd435ccc 100644 --- a/lib/Util/AnalysisUtil.cpp +++ b/lib/Util/AnalysisUtil.cpp @@ -29,7 +29,7 @@ #include "Util/AnalysisUtil.h" -#include // for FindAllocaDbgDeclare +#include // for FindDbgAddrUses #include // for GlobalVariable #include // for Module #include // for TerminatorInst @@ -300,10 +300,12 @@ std::string analysisUtil::getSourceLoc(const Value* val) { raw_string_ostream rawstr(str); if (const Instruction *inst = dyn_cast(val)) { if (isa(inst)) { - DbgDeclareInst* DDI = llvm::FindAllocaDbgDeclare(const_cast(inst)); - if (DDI) { - DIVariable *DIVar = cast(DDI->getVariable()); - rawstr << "ln: " << DIVar->getLine() << " fl: " << DIVar->getFilename(); + for (DbgInfoIntrinsic *DII : FindDbgAddrUses(const_cast(inst))) { + if (DbgDeclareInst *DDI = dyn_cast(DII)) { + DIVariable *DIVar = cast(DDI->getVariable()); + rawstr << "ln: " << DIVar->getLine() << " fl: " << DIVar->getFilename(); + break; + } } } else if (MDNode *N = inst->getMetadata("dbg")) { // Here I is an LLVM instruction diff --git a/tests/runtest.sh b/tests/runtest.sh index 7e526659f..0f1b5e1df 100755 --- a/tests/runtest.sh +++ b/tests/runtest.sh @@ -9,7 +9,7 @@ ################################################ ##remember to run ./setup script before running testings -CLANGFLAG='-g -c -emit-llvm -I.' +CLANGFLAG='-Xclang -disable-O0-optnone -g -c -emit-llvm -I.' LLVMOPTFLAG='-mem2reg -mergereturn' TESTWITHOPT=$1 From 5099b9951fea796fad059dc2302d5d8176322f04 Mon Sep 17 00:00:00 2001 From: Jack Anthony Date: Sat, 17 Mar 2018 11:54:41 +0000 Subject: [PATCH 3/3] Updated .travis.yml and build.sh for LLVM 6.0.0 --- .travis.yml | 20 ++++++++++---------- build.sh | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 495d25911..94c6cc867 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,32 +4,32 @@ os: linux addons: apt: sources: - - llvm-toolchain-trusty-4.0 + - llvm-toolchain-trusty-6.0 packages: - - llvm-4.0 - - llvm-4.0-dev - - clang-4.0 + - llvm-6.0 + - llvm-6.0-dev + - clang-6.0 matrix: include: - os: osx env: - - CXX=clang++ PATH=/usr/local/opt/llvm@4/bin:$PATH LLVM_DIR=/usr/local/opt/llvm@4 LDFLAGS:=-L/usr/local/opt/llvm@4/lib CPPFLAGS=-I/usr/local/opt/llvm@4/include + - CXX=clang++ PATH=/usr/local/opt/llvm@6/bin:$PATH LLVM_DIR=/usr/local/opt/llvm@6 LDFLAGS:=-L/usr/local/opt/llvm@6/lib CPPFLAGS=-I/usr/local/opt/llvm@6/include - CONFIG_ARGS="-DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++" - install: brew install llvm@4 + install: brew install llvm@6 cache: directories: ~/Library/Caches/Homebrew/ - os: osx env: - - CXX=clang++ PATH=/usr/local/opt/llvm@4/bin:$PATH LLVM_DIR=/usr/local/opt/llvm@4 LDFLAGS:=-L/usr/local/opt/llvm@4/lib CPPFLAGS=-I/usr/local/opt/llvm@4/include + - CXX=clang++ PATH=/usr/local/opt/llvm@6/bin:$PATH LLVM_DIR=/usr/local/opt/llvm@6 LDFLAGS:=-L/usr/local/opt/llvm@6/lib CPPFLAGS=-I/usr/local/opt/llvm@6/include - CONFIG_ARGS="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++" - install: brew install llvm@4 + install: brew install llvm@6 cache: directories: ~/Library/Caches/Homebrew/ env: global: - - CC=clang-4.0 CXX=clang++-4.0 + - CC=clang-6.0 CXX=clang++-6.0 - PATH=$TRAVIS_BUILD_DIR/cmake-3.8.1-Linux-x86_64/bin:$PATH - - LLVM_DIR=/usr/lib/llvm-4.0 + - LLVM_DIR=/usr/lib/llvm-6.0 matrix: - CONFIG_ARGS="-DCMAKE_BUILD_TYPE:STRING=Debug" - CONFIG_ARGS= diff --git a/build.sh b/build.sh index 03ab15e8e..d5e752b60 100755 --- a/build.sh +++ b/build.sh @@ -5,8 +5,8 @@ ######### # Please change the following home directories of your LLVM builds ######## -LLVMRELEASE=/home/ysui/llvm-4.0.0/llvm-4.0.0.obj -LLVMDEBUG=/home/ysui/llvm-4.0.0/llvm-4.0.0.dbg +LLVMRELEASE=/home/ysui/llvm-6.0.0/llvm-6.0.0.obj +LLVMDEBUG=/home/ysui/llvm-6.0.0/llvm-6.0.0.dbg if [[ $1 == 'debug' ]] then