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

LLVM 4 Merge #23

Merged
merged 26 commits into from
May 7, 2017
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
54415ad
Starting to move this into 4.0; likely with some errors, but it looks…
jcarlson23 Mar 28, 2017
73f69af
A few compilation fixes, the dataflow looks reasonable while the anal…
jcarlson23 Mar 28, 2017
ea5c7d4
I think I almost have the specializations right for the PTACallgraph
jcarlson23 Apr 3, 2017
9abbd56
Ok, fixed the PTACallGraph graph trait issue - at least for compilation
jcarlson23 Apr 3, 2017
fdab9cd
Fixed the SVFG Noderef issue, but looks like I need to clear the X** …
jcarlson23 Apr 4, 2017
ef3bb89
Had to clean up where I was, should be moving forward again, needs cl…
jcarlson23 Apr 4, 2017
b62082f
Have an iterator conflict but if I can get past that looks like I'm m…
jcarlson23 Apr 4, 2017
cab36c2
Fixed that iterator mismatch by changing the GNODE type in WPASolver.h
jcarlson23 Apr 5, 2017
af491dc
Fixed const char to StringRef in the getPassName() of BreakConstantExpr
jcarlson23 Apr 5, 2017
5fbd66b
A number of small fixes, mostly replacing const char* with llvm::Stri…
jcarlson23 Apr 5, 2017
de31c27
Couple trivial fixes, more StringRef and a ref to pointer
jcarlson23 Apr 6, 2017
7b7e39d
Starting to compile actual products but linkage errors likely indicat…
jcarlson23 Apr 6, 2017
837d2d2
1% more to go...
jcarlson23 Apr 13, 2017
099e767
Ok, down to one little header issue and then write it up and pass it …
Apr 15, 2017
e5c9dd3
Fixed that header issue, looks like the next few are pretty simple
Apr 17, 2017
37111d4
Fixed the wpa and saber tools - just needed a few args changed and us…
jcarlson23 Apr 17, 2017
29ae917
Ready to issue a PR, one issue for others to decide I think but the r…
jcarlson23 Apr 18, 2017
fdc9e2c
first offline attempt at fixing the cmake list
jcarlson23 Apr 30, 2017
ef62cdc
Adding in Will's fix, I want to test this out a bit
jcarlson23 May 4, 2017
e857e0f
Merged in the Bridged GEP iterator; time to fire up a VM and test the…
jcarlson23 May 5, 2017
66f62ab
ierge branch 'master' into llvm-4
jcarlson23 May 5, 2017
517d3d3
removing a file and verifying compilation after the merge
jcarlson23 May 5, 2017
6cd7aef
Updating LocMemModel.cpp per Yulei's comments
jcarlson23 May 7, 2017
acca31f
Missed one getIndexedType in LocMemModel for updated PR
jcarlson23 May 7, 2017
31cffc2
quick typo fix, verified compilation, no testing beyond trivial, upda…
jcarlson23 May 7, 2017
9ef3981
Couple quick changes from getIndexedType() back to *gi using the brid…
jcarlson23 May 7, 2017
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Release/
Debug/
build/
build*
html/
Release+Asserts/
Debug+Asserts/
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include)


add_subdirectory(lib)
add_subdirectory(tools)

1 change: 1 addition & 0 deletions include/MSSA/SVFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ struct GraphTraits<Inverse<SVFGNode *> > : public GraphTraits<Inverse<GenericNod
};

template<> struct GraphTraits<SVFG*> : public GraphTraits<GenericGraph<SVFGNode,SVFGEdge>* > {
typedef SVFGNode *NodeRef;
};
}

Expand Down
2 changes: 1 addition & 1 deletion include/MSSA/SVFGBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MemSSADF : public llvm::DominanceFrontier {

bool runOnDT(llvm::DominatorTree& dt) {
releaseMemory();
getBase().analyze(dt);
analyze(dt);
return false;
}
};
Expand Down
1 change: 1 addition & 0 deletions include/MemoryModel/CHA.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ struct GraphTraits<Inverse<CHNode*> > : public GraphTraits<Inverse<GenericNode<C
};

template<> struct GraphTraits<CHGraph*> : public GraphTraits<GenericGraph<CHNode,CHEdge>* > {
typedef CHNode *NodeRef;
};

}
Expand Down
1 change: 1 addition & 0 deletions include/MemoryModel/ConsG.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ struct GraphTraits<Inverse<ConstraintNode *> > : public GraphTraits<Inverse<Gene
};

template<> struct GraphTraits<ConstraintGraph*> : public GraphTraits<GenericGraph<ConstraintNode,ConstraintEdge>* > {
typedef ConstraintNode *NodeRef;
};

}
Expand Down
1 change: 1 addition & 0 deletions include/MemoryModel/PAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ template<> struct GraphTraits<Inverse<PAGNode *> > : public GraphTraits<Inverse<
};

template<> struct GraphTraits<PAG*> : public GraphTraits<GenericGraph<PAGNode,PAGEdge>* > {
typedef PAGNode *NodeRef;
};
}
#endif /* PAG_H_ */
4 changes: 2 additions & 2 deletions include/MemoryModel/PAGNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion include/SABER/DoubleFreeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
2 changes: 1 addition & 1 deletion include/SABER/FileChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
2 changes: 1 addition & 1 deletion include/SABER/LeakChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
4 changes: 2 additions & 2 deletions include/Util/BreakConstantExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
9 changes: 5 additions & 4 deletions include/Util/DataFlowUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ class PTACFInfoBuilder {
llvm::Function* fun = const_cast<llvm::Function*>(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;
Expand Down Expand Up @@ -225,7 +226,7 @@ class IteratedDominanceFrontier: public llvm::DominanceFrontierBase<llvm::BasicB

virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<llvm::DominanceFrontier>();
// AU.addRequired<llvm::DominanceFrontier>();
}

// virtual bool runOnFunction(llvm::Function &m) {
Expand Down
127 changes: 127 additions & 0 deletions include/Util/GEPTypeBridgeIterator.h
Original file line number Diff line number Diff line change
@@ -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<typename ItTy = User::const_op_iterator>
class generic_bridge_gep_type_iterator : public std::iterator<std::forward_iterator_tag, Type *, ptrdiff_t> {

typedef std::iterator<std::forward_iterator_tag,Type *, ptrdiff_t> super;
ItTy OpIt;
PointerIntPair<Type *,1> 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<CompositeType>( 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<Value*>(&**OpIt); }


generic_bridge_gep_type_iterator& operator++() {
if ( CurTy.getInt() ) {
CurTy.setInt(false);
} else if ( CompositeType * CT = dyn_cast<CompositeType>(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<GEPOperator>(GEP);
return bridge_gep_iterator::begin(GEPOp->getSourceElementType(),
cast<PointerType>(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<GEPOperator>(GEP);
return bridge_gep_iterator::begin( GEPOp.getSourceElementType(),
cast<PointerType>(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<typename T>
inline generic_bridge_gep_type_iterator<const T*> bridge_gep_end( Type * /*Op0*/, ArrayRef<T> A ) {
return generic_bridge_gep_type_iterator<const T*>::end(A.end());
}

}

#endif
7 changes: 4 additions & 3 deletions include/Util/GraphUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <llvm/Support/Debug.h> // for debug
#include <llvm/ADT/GraphTraits.h> // for Graphtraits
#include <llvm/Support/ToolOutputFile.h>
#include <llvm/Support/CommandLine.h> // for tool output file
#include <llvm/Support/CommandLine.h> // for tool output file
#include <llvm/Support/GraphWriter.h> // for graph write
#include <llvm/Support/FileSystem.h> // for file open flag

Expand Down Expand Up @@ -82,7 +82,8 @@ class GraphPrinter {
const GraphType &GT) {
///Define the GTraits and node iterator for printing
typedef GraphTraits<GraphType> GTraits;
typedef typename GTraits::NodeType NodeType;

typedef typename GTraits::NodeRef NodeRef;
typedef typename GTraits::nodes_iterator node_iterator;
typedef typename GTraits::ChildIteratorType child_iterator;

Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions include/Util/PTACallGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class PTACallGraphEdge : public GenericCallGraphEdgeTy {
enum CEDGEK {
CallRetEdge,TDForkEdge,TDJoinEdge,HareParForEdge
};


private:
CallInstSet directCalls;
CallInstSet indirectCalls;
Expand Down Expand Up @@ -216,6 +218,7 @@ class PTACallGraph : public GenericCallGraphTy {
destroy();
}


/// Get callees from an indirect callsite
//@{
inline CallEdgeMap& getIndCallMap() {
Expand Down Expand Up @@ -368,8 +371,10 @@ struct GraphTraits<Inverse<PTACallGraphNode *> > : public GraphTraits<Inverse<Ge
};

template<> struct GraphTraits<PTACallGraph*> : public GraphTraits<GenericGraph<PTACallGraphNode,PTACallGraphEdge>* > {
typedef PTACallGraphNode *NodeRef;
};


}


Expand Down
6 changes: 3 additions & 3 deletions include/Util/SCC.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SCCDetection {
private:
///Define the GTraits and node iterator for printing
typedef llvm::GraphTraits<GraphType> 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 ;
Expand Down Expand Up @@ -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);
}

Expand Down
14 changes: 10 additions & 4 deletions include/WPA/WPAPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@

#include "MemoryModel/PointerAnalysis.h"
#include <llvm/Analysis/AliasAnalysis.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/Pass.h>


/*!
* 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<PointerAnalysis*> PTAVector;

public:
Expand All @@ -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();

Expand Down Expand Up @@ -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";
}

Expand Down
Loading