diff --git a/.gitignore b/.gitignore index 844f28b45..2965d1b03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ Release/ Debug/ build/ +build* html/ Release+Asserts/ Debug+Asserts/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 636653206..a9622b537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include) + add_subdirectory(lib) add_subdirectory(tools) diff --git a/include/MSSA/SVFG.h b/include/MSSA/SVFG.h index ef1391eaf..58559a087 100644 --- a/include/MSSA/SVFG.h +++ b/include/MSSA/SVFG.h @@ -634,6 +634,7 @@ struct GraphTraits > : public GraphTraits struct GraphTraits : public GraphTraits* > { + typedef SVFGNode *NodeRef; }; } diff --git a/include/MSSA/SVFGBuilder.h b/include/MSSA/SVFGBuilder.h index 7d77c101b..c28935f76 100644 --- a/include/MSSA/SVFGBuilder.h +++ b/include/MSSA/SVFGBuilder.h @@ -43,7 +43,7 @@ class MemSSADF : public llvm::DominanceFrontier { bool runOnDT(llvm::DominatorTree& dt) { releaseMemory(); - getBase().analyze(dt); + analyze(dt); return false; } }; diff --git a/include/MemoryModel/CHA.h b/include/MemoryModel/CHA.h index ac109ec2e..d3c7d7c13 100644 --- a/include/MemoryModel/CHA.h +++ b/include/MemoryModel/CHA.h @@ -249,6 +249,7 @@ struct GraphTraits > : public GraphTraits struct GraphTraits : public GraphTraits* > { + typedef CHNode *NodeRef; }; } diff --git a/include/MemoryModel/ConsG.h b/include/MemoryModel/ConsG.h index f749322af..a07696b57 100644 --- a/include/MemoryModel/ConsG.h +++ b/include/MemoryModel/ConsG.h @@ -314,6 +314,7 @@ struct GraphTraits > : public GraphTraits struct GraphTraits : public GraphTraits* > { + typedef ConstraintNode *NodeRef; }; } diff --git a/include/MemoryModel/PAG.h b/include/MemoryModel/PAG.h index 45a3c2b77..0477c72bc 100644 --- a/include/MemoryModel/PAG.h +++ b/include/MemoryModel/PAG.h @@ -685,6 +685,7 @@ template<> struct GraphTraits > : public GraphTraits struct GraphTraits : public GraphTraits* > { + typedef PAGNode *NodeRef; }; } #endif /* PAG_H_ */ diff --git a/include/MemoryModel/PAGNode.h b/include/MemoryModel/PAGNode.h index 81cf94dc0..072ab9f30 100644 --- a/include/MemoryModel/PAGNode.h +++ b/include/MemoryModel/PAGNode.h @@ -341,8 +341,8 @@ class GepValPN: public ValPN { /// Return name of a LLVM value const std::string getValueName() { if (value && value->hasName()) - return value->getName().str() + "_" + llvm::utostr_32(getOffset()); - return "offset_" + llvm::utostr_32(getOffset()); + return value->getName().str() + "_" + llvm::utostr(getOffset()); + return "offset_" + llvm::utostr(getOffset()); } const llvm::Type *getType() const { diff --git a/include/SABER/DoubleFreeChecker.h b/include/SABER/DoubleFreeChecker.h index c529d1425..7a667b789 100644 --- a/include/SABER/DoubleFreeChecker.h +++ b/include/SABER/DoubleFreeChecker.h @@ -58,7 +58,7 @@ class DoubleFreeChecker : public LeakChecker { } /// Get pass name - virtual const char* getPassName() const { + virtual llvm::StringRef getPassName() const { return "Double Free Analysis"; } diff --git a/include/SABER/FileChecker.h b/include/SABER/FileChecker.h index ec56fee10..4efc268fb 100644 --- a/include/SABER/FileChecker.h +++ b/include/SABER/FileChecker.h @@ -59,7 +59,7 @@ class FileChecker : public LeakChecker { } /// Get pass name - virtual const char* getPassName() const { + virtual llvm::StringRef getPassName() const { return "File Open/Close Analysis"; } diff --git a/include/SABER/LeakChecker.h b/include/SABER/LeakChecker.h index 92598cd66..7a0c27ab8 100644 --- a/include/SABER/LeakChecker.h +++ b/include/SABER/LeakChecker.h @@ -69,7 +69,7 @@ class LeakChecker : public SrcSnkDDA, public llvm::ModulePass { } /// Get pass name - virtual const char* getPassName() const { + virtual llvm::StringRef getPassName() const { return "Static Memory Leak Analysis"; } diff --git a/include/Util/BreakConstantExpr.h b/include/Util/BreakConstantExpr.h index 042a11600..2eb86a5fc 100644 --- a/include/Util/BreakConstantExpr.h +++ b/include/Util/BreakConstantExpr.h @@ -36,7 +36,7 @@ class BreakConstantGEPs : public llvm::ModulePass { public: static char ID; BreakConstantGEPs() : ModulePass(ID) {} - const char *getPassName() const { + llvm::StringRef getPassName() const { return "Remove Constant GEP Expressions"; } virtual bool runOnModule (llvm::Module & M); @@ -62,7 +62,7 @@ class MergeFunctionRets : public llvm::ModulePass { public: static char ID; MergeFunctionRets() : ModulePass(ID) {} - const char *getPassName() const { + llvm::StringRef getPassName() const { return "unify function exit into one dummy exit basic block"; } virtual bool runOnModule (llvm::Module & M) { diff --git a/include/Util/DataFlowUtil.h b/include/Util/DataFlowUtil.h index cc36c1a78..a91b74446 100644 --- a/include/Util/DataFlowUtil.h +++ b/include/Util/DataFlowUtil.h @@ -174,10 +174,11 @@ class PTACFInfoBuilder { llvm::Function* fun = const_cast(f); FunToPostDTMap::iterator it = funToPDTMap.find(fun); if(it==funToPDTMap.end()) { - llvm::PostDominatorTree* postDT = new llvm::PostDominatorTree(); + llvm::PostDominatorTreeWrapperPass* postDT = new llvm::PostDominatorTreeWrapperPass(); postDT->runOnFunction(*fun); - funToPDTMap[fun] = postDT; - return postDT; + llvm::PostDominatorTree * PDT = &(postDT->getPostDomTree()); + funToPDTMap[fun] = PDT; + return PDT; } else return it->second; @@ -225,7 +226,7 @@ class IteratedDominanceFrontier: public llvm::DominanceFrontierBase(); + // AU.addRequired(); } // virtual bool runOnFunction(llvm::Function &m) { diff --git a/include/Util/GEPTypeBridgeIterator.h b/include/Util/GEPTypeBridgeIterator.h new file mode 100644 index 000000000..a13328ae1 --- /dev/null +++ b/include/Util/GEPTypeBridgeIterator.h @@ -0,0 +1,127 @@ +// GEPTypeBridgeIterator +// +// +#ifndef SVF_GEPTYPEBRIDGEITERATOR_H +#define SVF_GEPTYPEBRIDGEITERATOR_H + +#include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/Operator.h" +#include "llvm/IR/User.h" +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/IR/GetElementPtrTypeIterator.h" + +namespace llvm { + + template + class generic_bridge_gep_type_iterator : public std::iterator { + + typedef std::iterator super; + ItTy OpIt; + PointerIntPair CurTy; + unsigned AddrSpace; + generic_bridge_gep_type_iterator() {} + public: + + static generic_bridge_gep_type_iterator begin(Type *Ty, ItTy It) { + generic_bridge_gep_type_iterator I; + I.CurTy.setPointer(Ty); + I.OpIt = It; + return I; + } + + static generic_bridge_gep_type_iterator begin(Type *Ty, unsigned AddrSpace, + ItTy It) { + generic_bridge_gep_type_iterator I; + I.CurTy.setPointer(Ty); + I.CurTy.setInt(true); + I.AddrSpace = AddrSpace; + I.OpIt = It; + return I; + } + + static generic_bridge_gep_type_iterator end(ItTy It) { + generic_bridge_gep_type_iterator I; + I.OpIt = It; + return I; + } + + bool operator==(const generic_bridge_gep_type_iterator& x) const { + return OpIt == x.OpIt; + } + + bool operator!=(const generic_bridge_gep_type_iterator& x) const { + return !operator==(x); + } + + Type *operator*() const { + if ( CurTy.getInt() ) + return CurTy.getPointer()->getPointerTo(AddrSpace); + return CurTy.getPointer(); + } + + Type *getIndexedType() const { + if ( CurTy.getInt() ) + return CurTy.getPointer(); + CompositeType *CT = cast( CurTy.getPointer() ); + return CT->getTypeAtIndex(getOperand()); + } + + // non-standard operators, these may not need be bridged but seems it's + // predunt to do so... + Type *operator->() const { return operator*(); } + + Value *getOperand() const { return const_cast(&**OpIt); } + + + generic_bridge_gep_type_iterator& operator++() { + if ( CurTy.getInt() ) { + CurTy.setInt(false); + } else if ( CompositeType * CT = dyn_cast(CurTy.getPointer()) ) { + CurTy.setPointer(CT->getTypeAtIndex(getOperand())); + } else { + CurTy.setPointer(nullptr); + } + ++OpIt; + return *this; + } + + + generic_bridge_gep_type_iterator operator++(int) { + generic_bridge_gep_type_iterator tmp = *this; ++*this; return tmp; + } + + }; + + + typedef generic_bridge_gep_type_iterator<> bridge_gep_iterator; + + inline bridge_gep_iterator bridge_gep_begin(const User* GEP) { + auto *GEPOp = cast(GEP); + return bridge_gep_iterator::begin(GEPOp->getSourceElementType(), + cast(GEPOp->getPointerOperandType()->getScalarType())->getAddressSpace(), + GEP->op_begin() + 1); + } + + inline bridge_gep_iterator bridge_gep_end(const User* GEP) { + return bridge_gep_iterator::end(GEP->op_end()); + } + + inline bridge_gep_iterator bridge_gep_begin(const User &GEP) { + auto &GEPOp = cast(GEP); + return bridge_gep_iterator::begin( GEPOp.getSourceElementType(), + cast(GEPOp.getPointerOperandType()->getScalarType())->getAddressSpace(), + GEP.op_begin() + 1); + } + + inline bridge_gep_iterator bridge_gep_end(const User &GEP) { + return bridge_gep_iterator::end(GEP.op_end()); + } + + template + inline generic_bridge_gep_type_iterator bridge_gep_end( Type * /*Op0*/, ArrayRef A ) { + return generic_bridge_gep_type_iterator::end(A.end()); + } + +} + +#endif diff --git a/include/Util/GraphUtil.h b/include/Util/GraphUtil.h index 7d2f11f65..95b8bfb08 100644 --- a/include/Util/GraphUtil.h +++ b/include/Util/GraphUtil.h @@ -33,7 +33,7 @@ #include // for debug #include // for Graphtraits #include -#include // for tool output file +#include // for tool output file #include // for graph write #include // for file open flag @@ -82,7 +82,8 @@ class GraphPrinter { const GraphType >) { ///Define the GTraits and node iterator for printing typedef GraphTraits GTraits; - typedef typename GTraits::NodeType NodeType; + + typedef typename GTraits::NodeRef NodeRef; typedef typename GTraits::nodes_iterator node_iterator; typedef typename GTraits::ChildIteratorType child_iterator; @@ -91,7 +92,7 @@ class GraphPrinter { node_iterator I = GTraits::nodes_begin(GT); node_iterator E = GTraits::nodes_end(GT); for (; I != E; ++I) { - NodeType *Node = *I; + NodeRef *Node = *I; O << "node :" << Node << "'\n"; child_iterator EI = GTraits::child_begin(Node); child_iterator EE = GTraits::child_end(Node); diff --git a/include/Util/PTACallGraph.h b/include/Util/PTACallGraph.h index 460d4f47e..ff9c1d196 100644 --- a/include/Util/PTACallGraph.h +++ b/include/Util/PTACallGraph.h @@ -57,6 +57,8 @@ class PTACallGraphEdge : public GenericCallGraphEdgeTy { enum CEDGEK { CallRetEdge,TDForkEdge,TDJoinEdge,HareParForEdge }; + + private: CallInstSet directCalls; CallInstSet indirectCalls; @@ -216,6 +218,7 @@ class PTACallGraph : public GenericCallGraphTy { destroy(); } + /// Get callees from an indirect callsite //@{ inline CallEdgeMap& getIndCallMap() { @@ -368,8 +371,10 @@ struct GraphTraits > : public GraphTraits struct GraphTraits : public GraphTraits* > { + typedef PTACallGraphNode *NodeRef; }; + } diff --git a/include/Util/SCC.h b/include/Util/SCC.h index 46809b530..5ab062f24 100644 --- a/include/Util/SCC.h +++ b/include/Util/SCC.h @@ -55,7 +55,7 @@ class SCCDetection { private: ///Define the GTraits and node iterator for printing typedef llvm::GraphTraits GTraits; - typedef typename GTraits::NodeType GNODE; + typedef typename GTraits::NodeRef GNODE; typedef typename GTraits::nodes_iterator node_iterator; typedef typename GTraits::ChildIteratorType child_iterator; typedef unsigned NodeID ; @@ -207,11 +207,11 @@ class SCCDetection { return _NodeSCCAuxInfo[n].inSCC(); } - inline GNODE* Node(NodeID id) const { + inline GNODE Node(NodeID id) const { return GTraits::getNode(_graph, id); } - inline NodeID Node_Index(GNODE* node) const { + inline NodeID Node_Index(GNODE node) const { return GTraits::getNodeID(node); } diff --git a/include/WPA/WPAPass.h b/include/WPA/WPAPass.h index ab081f33c..bc0b4da88 100644 --- a/include/WPA/WPAPass.h +++ b/include/WPA/WPAPass.h @@ -39,6 +39,7 @@ #include "MemoryModel/PointerAnalysis.h" #include +#include #include @@ -46,7 +47,9 @@ * Whole program pointer analysis. * This class performs various pointer analysis on the given module. */ -class WPAPass: public llvm::ModulePass, public llvm::AliasAnalysis { +// excised ", public llvm::AliasAnalysis" as that has a very light interface +// and I want to see what breaks. +class WPAPass: public llvm::ModulePass { typedef std::vector PTAVector; public: @@ -59,8 +62,11 @@ class WPAPass: public llvm::ModulePass, public llvm::AliasAnalysis { Precise ///< return alias result by the most precise pta }; - /// Constructor - WPAPass() : llvm::ModulePass(ID), llvm::AliasAnalysis() {} + /// Constructor needs TargetLibraryInfo to be passed to the AliasAnalysis + WPAPass() : llvm::ModulePass(ID) { + + } + /// Destructor ~WPAPass(); @@ -88,7 +94,7 @@ class WPAPass: public llvm::ModulePass, public llvm::AliasAnalysis { virtual bool runOnModule(llvm::Module& module); /// PTA name - virtual inline const char* getPassName() const { + virtual inline llvm::StringRef getPassName() const { return "WPAPass"; } diff --git a/include/WPA/WPASolver.h b/include/WPA/WPASolver.h index db625bb49..0b19c18c6 100644 --- a/include/WPA/WPASolver.h +++ b/include/WPA/WPASolver.h @@ -6,7 +6,7 @@ // Copyright (C) <2013-2016> // This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by +// it under the terms of the GNU Gg12eneral Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. @@ -43,7 +43,7 @@ class WPASolver { public: ///Define the GTraits and node iterator for printing typedef llvm::GraphTraits GTraits; - typedef typename GTraits::NodeType GNODE; + typedef typename GTraits::NodeRef GNODE; typedef typename GTraits::EdgeType GEDGE; typedef typename GTraits::ChildIteratorType child_iterator; @@ -122,8 +122,8 @@ class WPASolver { /// Propagation for the solving, to be implemented in the child class virtual void propagate(GNODE* v) { - child_iterator EI = GTraits::direct_child_begin(v); - child_iterator EE = GTraits::direct_child_end(v); + child_iterator EI = GTraits::direct_child_begin(*v); + child_iterator EE = GTraits::direct_child_end(*v); for (; EI != EE; ++EI) { if (propFromSrcToDst(*(EI.getCurrent()))) pushIntoWorklist(Node_Index(*EI)); @@ -162,7 +162,7 @@ class WPASolver { } /// Get node ID - inline NodeID Node_Index(GNODE* node) { + inline NodeID Node_Index(GNODE node) { return GTraits::getNodeID(node); } diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 70ad9fe5f..fe7891d63 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -51,6 +51,18 @@ set(SOURCES add_llvm_loadable_module(Svf ${SOURCES}) add_llvm_Library(LLVMSvf ${SOURCES}) +if ( CMAKE_SYSTEM_NAME MATCHES "Darwin") + # It seems that the Svf library needs to explictly require the CUDD alloc/init/etc so LLVMCudd + link_directories( ${CMAKE_BINARY_DIR}/lib/Cudd ) + llvm_map_components_to_libnames(llvm_libs bitwriter core ipo irreader instcombine instrumentation target linker analysis scalaropts support ) + target_link_libraries(LLVMSvf ${llvm_libs}) + target_link_libraries(Svf LLVMCudd ${llvm_libs}) +else() + llvm_map_components_to_libnames(llvm_libs bitwriter core ipo irreader instcombine instrumentation target linker analysis scalaropts support ) + target_link_libraries(LLVMSvf ${llvm_libs}) + target_link_libraries(Svf ${llvm_libs}) +endif() + if(DEFINED IN_SOURCE_BUILD) add_dependencies(Svf intrinsics_gen) diff --git a/lib/MemoryModel/LocMemModel.cpp b/lib/MemoryModel/LocMemModel.cpp index 0aaac4a9b..172a83ddb 100644 --- a/lib/MemoryModel/LocMemModel.cpp +++ b/lib/MemoryModel/LocMemModel.cpp @@ -32,6 +32,7 @@ #include "Util/AnalysisUtil.h" #include //for gep iterator +#include "Util/GEPTypeBridgeIterator.h" // include bridge_gep_iterator #include using namespace llvm; @@ -47,20 +48,20 @@ bool LocSymTableInfo::computeGepOffset(const llvm::User *V, LocationSet& ls) { assert(V); int baseIndex = -1; int index = 0; - for (gep_type_iterator gi = gep_type_begin(*V), ge = gep_type_end(*V); + for (bridge_gep_iterator gi = bridge_gep_begin(*V), ge = bridge_gep_end(*V); gi != ge; ++gi, ++index) { if(llvm::isa(gi.getOperand()) == false) baseIndex = index; } index = 0; - for (gep_type_iterator gi = gep_type_begin(*V), ge = gep_type_end(*V); + for (bridge_gep_iterator gi = bridge_gep_begin(*V), ge = bridge_gep_end(*V); gi != ge; ++gi, ++index) { if (index <= baseIndex) { /// variant offset // Handling pointer types - if (const PointerType* pty = dyn_cast(*gi)) { + if (const PointerType* pty = dyn_cast(*gi)) { const Type* et = pty->getElementType(); Size_t sz = getTypeSizeInBytes(et); @@ -73,7 +74,7 @@ bool LocSymTableInfo::computeGepOffset(const llvm::User *V, LocationSet& ls) { ls.addElemNumStridePair(std::make_pair(num, sz)); } // Calculate the size of the array element - else if(const ArrayType* at = dyn_cast(*gi)) { + else if(const ArrayType* at = dyn_cast(*gi)) { const Type* et = at->getElementType(); Size_t sz = getTypeSizeInBytes(et); Size_t num = at->getNumElements(); @@ -106,7 +107,7 @@ bool LocSymTableInfo::computeGepOffset(const llvm::User *V, LocationSet& ls) { ls.offset += idx * sz; } // Handling struct here - else if (const StructType *ST = dyn_cast(*gi)) { + else if (const StructType *ST = dyn_cast(*gi)) { assert(op && "non-const struct index in GEP"); const vector &so = SymbolTableInfo::Symbolnfo()->getStructOffsetVec(ST); if ((unsigned)idx >= so.size()) { diff --git a/lib/MemoryModel/MemModel.cpp b/lib/MemoryModel/MemModel.cpp index b1fcc0f45..b2392ef74 100644 --- a/lib/MemoryModel/MemModel.cpp +++ b/lib/MemoryModel/MemModel.cpp @@ -32,6 +32,7 @@ #include "Util/AnalysisUtil.h" #include "Util/CPPUtil.h" #include "Util/BreakConstantExpr.h" +#include "Util/GEPTypeBridgeIterator.h" // include bridge_gep_iterator #include #include // for output #include // for valueSymbolTable @@ -187,15 +188,14 @@ void SymbolTableInfo::collectSimpleTypeInfo(const llvm::Type* ty) */ bool SymbolTableInfo::computeGepOffset(const llvm::User *V, LocationSet& ls) { assert(V); - for (gep_type_iterator gi = gep_type_begin(*V), ge = gep_type_end(*V); + for (bridge_gep_iterator gi = bridge_gep_begin(*V), ge = bridge_gep_end(*V); gi != ge; ++gi) { // Handling array types, skipe array handling here // We treat whole array as one, then we can distinguish different field of an array of struct // e.g. s[1].f1 is differet from s[0].f2 if(isa(*gi)) - continue; - + continue; //The int-value object of the current index operand // (may not be constant for arrays). @@ -225,8 +225,7 @@ bool SymbolTableInfo::computeGepOffset(const llvm::User *V, LocationSet& ls) { // Handling struct here - - if (const StructType *ST = dyn_cast(*gi)) { + if (const StructType *ST = dyn_cast(*gi) ) { assert(op && "non-const struct index in GEP"); const vector &so = SymbolTableInfo::Symbolnfo()->getStructOffsetVec(ST); if ((unsigned)idx >= so.size()) { diff --git a/lib/Util/AnalysisUtil.cpp b/lib/Util/AnalysisUtil.cpp index 81322ebd0..5535f6a3e 100644 --- a/lib/Util/AnalysisUtil.cpp +++ b/lib/Util/AnalysisUtil.cpp @@ -255,9 +255,16 @@ std::string analysisUtil::getSourceLocOfFunction(const llvm::Function *F) raw_string_ostream rawstr(str); NamedMDNode* CU_Nodes = F->getParent()->getNamedMetadata("llvm.dbg.cu"); if(CU_Nodes) { + /* + * Looks like the DICompileUnt->getSubprogram was moved into Function:: + */ for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { DICompileUnit *CUNode = cast(CU_Nodes->getOperand(i)); - for (DISubprogram *SP : CUNode->getSubprograms()) { + /* + * https://reviews.llvm.org/D18074?id=50385 + * looks like the relevant + */ + if (DISubprogram *SP = F->getSubprogram()) { if (SP->describes(F)) rawstr << "in line: " << SP->getLine() << " file: " << SP->getFilename(); @@ -309,9 +316,13 @@ std::string analysisUtil::getSourceLoc(const Value* val) { if(CU_Nodes) { for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { DICompileUnit *CUNode = cast(CU_Nodes->getOperand(i)); - for (DIGlobalVariable *GV : CUNode->getGlobalVariables()) { - if (gvar == GV->getVariable()) - rawstr << "ln: " << GV->getLine() << " fl: " << GV->getFilename(); + for (DIGlobalVariableExpression *GV : CUNode->getGlobalVariables()) { + DIGlobalVariable * DGV = GV->getVariable(); + + /* + if ( gvar == DGV ) + rawstr << "ln: " << DGV->getLine() << " fl: " << DGV->getFilename(); + */ } } } diff --git a/lib/WPA/FlowSensitive.cpp b/lib/WPA/FlowSensitive.cpp index a85339bf5..71a75f2a3 100644 --- a/lib/WPA/FlowSensitive.cpp +++ b/lib/WPA/FlowSensitive.cpp @@ -126,7 +126,7 @@ NodeStack& FlowSensitive::SCCDetect() void FlowSensitive::processNode(NodeID nodeId) { SVFGNode* node = svfg->getSVFGNode(nodeId); if (processSVFGNode(node)) - propagate(node); + propagate(&node); clearAllDFOutVarFlag(node); } diff --git a/lib/WPA/WPAPass.cpp b/lib/WPA/WPAPass.cpp index 16d0387cf..1d560195b 100644 --- a/lib/WPA/WPAPass.cpp +++ b/lib/WPA/WPAPass.cpp @@ -55,15 +55,15 @@ static cl::bits PASelected(cl::desc("Select pointer anal clEnumValN(PointerAnalysis::AndersenLCD_WPA, "lander", "Lazy cycle detection inclusion-based analysis"), clEnumValN(PointerAnalysis::AndersenWave_WPA, "wander", "Wave propagation inclusion-based analysis"), clEnumValN(PointerAnalysis::AndersenWaveDiff_WPA, "ander", "Diff wave propagation inclusion-based analysis"), - clEnumValN(PointerAnalysis::FSSPARSE_WPA, "fspta", "Sparse flow sensitive pointer analysis"), - clEnumValEnd)); + clEnumValN(PointerAnalysis::FSSPARSE_WPA, "fspta", "Sparse flow sensitive pointer analysis") + )); static cl::bits AliasRule(cl::desc("Select alias check rule"), cl::values( clEnumValN(WPAPass::Conservative, "conservative", "return MayAlias if any pta says alias"), - clEnumValN(WPAPass::Veto, "veto", "return NoAlias if any pta says no alias"), - clEnumValEnd)); + clEnumValN(WPAPass::Veto, "veto", "return NoAlias if any pta says no alias") + )); cl::opt anderSVFG("svfg", cl::init(false), cl::desc("Generate SVFG after Andersen's Analysis")); diff --git a/tools/SABER/saber.cpp b/tools/SABER/saber.cpp index 706b9b8af..a84b3f853 100644 --- a/tools/SABER/saber.cpp +++ b/tools/SABER/saber.cpp @@ -30,6 +30,7 @@ #include "SABER/FileChecker.h" #include "SABER/DoubleFreeChecker.h" +#include // for LLVMGetGlobalContext() #include // for cl #include // for bitcode write #include // pass manager @@ -39,7 +40,8 @@ #include // for pass list #include // for llvm LLVMContext #include // for SMDiagnostic -#include // for createBitcodeWriterPass + +#include // for createBitcodeWriterPass using namespace llvm; @@ -58,15 +60,16 @@ static cl::opt DFREECHECKER("dfree", cl::init(false), int main(int argc, char ** argv) { - sys::PrintStackTraceOnErrorSignal(); + sys::PrintStackTraceOnErrorSignal(argv[0]); llvm::PrettyStackTraceProgram X(argc, argv); - LLVMContext &Context = getGlobalContext(); + LLVMOpaqueContext * WrappedContextRef = LLVMGetGlobalContext(); + LLVMContext &Context = *unwrap(WrappedContextRef); std::string OutputFilename; cl::ParseCommandLineOptions(argc, argv, "Software Bug Check\n"); - sys::PrintStackTraceOnErrorSignal(); + sys::PrintStackTraceOnErrorSignal(argv[0]); PassRegistry &Registry = *PassRegistry::getPassRegistry(); diff --git a/tools/WPA/CMakeLists.txt b/tools/WPA/CMakeLists.txt index a95cff5c8..5c30565fd 100644 --- a/tools/WPA/CMakeLists.txt +++ b/tools/WPA/CMakeLists.txt @@ -3,7 +3,7 @@ if(DEFINED IN_SOURCE_BUILD) set(LLVM_LINK_COMPONENTS BitWriter Core IPO IrReader InstCombine Instrumentation Target Linker Analysis ScalarOpts Support Svf Cudd) add_llvm_tool( wpa wpa.cpp ) else() - llvm_map_components_to_libnames(llvm_libs BitWriter Core IPO IrReader InstCombine Instrumentation Target Linker Analysis ScalarOpts Support ) + llvm_map_components_to_libnames(llvm_libs bitwriter core ipo irreader instcombine instrumentation target linker analysis scalaropts support ) add_executable( wpa wpa.cpp ) target_link_libraries( wpa LLVMSvf LLVMCudd ${llvm_libs} ) diff --git a/tools/WPA/wpa.cpp b/tools/WPA/wpa.cpp index bcbca6b38..a5917889c 100644 --- a/tools/WPA/wpa.cpp +++ b/tools/WPA/wpa.cpp @@ -28,6 +28,7 @@ #include "WPA/WPAPass.h" +#include // for LLVMGetGlobalContext() #include // for cl #include // for sys::fs::F_None #include // for bitcode write @@ -38,7 +39,7 @@ #include // for pass list #include // for llvm LLVMContext #include // for SMDiagnostic -#include // for createBitcodeWriterPass +#include // for createBitcodeWriterPass using namespace llvm; @@ -49,15 +50,16 @@ static cl::opt InputFilename(cl::Positional, int main(int argc, char ** argv) { - sys::PrintStackTraceOnErrorSignal(); + sys::PrintStackTraceOnErrorSignal(argv[0]); llvm::PrettyStackTraceProgram X(argc, argv); - LLVMContext &Context = getGlobalContext(); + LLVMOpaqueContext * WrappedContextRef = LLVMGetGlobalContext(); + LLVMContext &Context = *unwrap(WrappedContextRef); std::string OutputFilename; cl::ParseCommandLineOptions(argc, argv, "Whole Program Points-to Analysis\n"); - sys::PrintStackTraceOnErrorSignal(); + sys::PrintStackTraceOnErrorSignal(argv[0]); PassRegistry &Registry = *PassRegistry::getPassRegistry();