Giter VIP home page Giter VIP logo

llvm-dsa's Introduction

llvm-dsa

DSA fork for SeaHorn. Based on the DSA for in SMACK. Originally from PoolAlloc. LLVM version is 5.0

llvm-dsa's People

Contributors

agurfinkel avatar caballa avatar ianamason avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

llvm-dsa's Issues

Compile fail

This is when compiling from modular_inc branch of seahorn, on ubuntu 14.04, Clang 3.6.1, boost 1.60.0.

dejan@pup:~/workspace/seahorn/build$ cmake --build .
Scanning dependencies of target DSA
[  1%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/AddressTakenAnalysis.cpp.o
[  1%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/CallTargets.cpp.o
[  1%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/DSTest.cpp.o
[  3%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/EquivClassGraphs.cpp.o
[  3%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/StdLibPass.cpp.o
[  4%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/AllocatorIdentification.cpp.o
[  4%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/CompleteBottomUp.cpp.o
[  6%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/DataStructure.cpp.o
/homes/dejan/workspace/seahorn/dsa-seahorn/lib/DSA/DataStructure.cpp:1184:7: warning: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false [-Wtautological-undefined-compare]
  if (this == 0) return;
      ^~~~    ~
1 warning generated.
[  6%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/GraphChecker.cpp.o
[  7%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/Printer.cpp.o
[  7%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/TopDownClosure.cpp.o
[  9%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/Basic.cpp.o
[  9%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/DSCallGraph.cpp.o
[ 10%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/DataStructureStats.cpp.o
[ 10%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/TypeSafety.cpp.o
[ 10%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/BottomUpClosure.cpp.o
[ 12%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/DSGraph.cpp.o
[ 12%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/EntryPointAnalysis.cpp.o
[ 13%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/Local.cpp.o
/homes/dejan/workspace/seahorn/dsa-seahorn/lib/DSA/Local.cpp:1453:48: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
      if (!(I->hasSection() && I->getSection() == "llvm.metadata")) {
                                               ^  ~~~~~~~~~~~~~~~
1 warning generated.
[ 13%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/SanityCheck.cpp.o
[ 15%] Building CXX object dsa-seahorn/lib/DSA/CMakeFiles/DSA.dir/Steensgaard.cpp.o
Linking CXX static library libDSA.a
[ 15%] Built target DSA
Scanning dependencies of target AssistDS
[ 15%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/ArgCast.cpp.o
[ 15%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/Devirt.cpp.o
[ 16%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/GEPExprArgs.cpp.o
[ 16%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/LoadArgs.cpp.o
[ 18%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/SimplifyExtractValue.cpp.o
[ 18%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/StructReturnToPointer.cpp.o
[ 20%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/ArgSimplify.cpp.o
[ 20%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/DynCount.cpp.o
[ 21%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/IndCloner.cpp.o
[ 21%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/SimplifyGEP.cpp.o
[ 23%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/TypeChecks.cpp.o
[ 23%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/DSNodeEquivs.cpp.o
[ 24%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/FuncSimplify.cpp.o
[ 24%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/Int2PtrCmp.cpp.o
[ 24%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/MergeGEP.cpp.o
[ 26%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/SimplifyInsertValue.cpp.o
[ 26%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/TypeChecksOpt.cpp.o
[ 27%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/DataStructureCallGraph.cpp.o
[ 27%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/FuncSpec.cpp.o
[ 29%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/SVADevirt.cpp.o
[ 29%] Building CXX object dsa-seahorn/lib/AssistDS/CMakeFiles/AssistDS.dir/SimplifyLoad.cpp.o
Linking CXX static library libAssistDS.a
[ 29%] Built target AssistDS
Scanning dependencies of target SeaLlvmIpo
[ 30%] Building CXX object llvm-seahorn/lib/Transforms/IPO/CMakeFiles/SeaLlvmIpo.dir/PassManagerBuilder.cpp.o
Linking CXX static library ../../../../lib/libSeaLlvmIpo.a
[ 30%] Built target SeaLlvmIpo
Scanning dependencies of target SeaInstCombine
[ 32%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstructionCombining.cpp.o
[ 32%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineAddSub.cpp.o
[ 33%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineAndOrXor.cpp.o
[ 33%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineCalls.cpp.o
[ 33%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineCasts.cpp.o
[ 35%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineCompares.cpp.o
[ 35%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineLoadStoreAlloca.cpp.o
[ 36%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineMulDivRem.cpp.o
[ 36%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombinePHI.cpp.o
[ 38%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineSelect.cpp.o
[ 38%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineShifts.cpp.o
[ 40%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineSimplifyDemanded.cpp.o
[ 40%] Building CXX object llvm-seahorn/lib/Transforms/InstCombine/CMakeFiles/SeaInstCombine.dir/InstCombineVectorOps.cpp.o
Linking CXX static library ../../../../lib/libSeaInstCombine.a
[ 40%] Built target SeaInstCombine
Scanning dependencies of target SeaInstNondet
[ 41%] Building CXX object llvm-seahorn/lib/Transforms/InstNondet/CMakeFiles/SeaInstNondet.dir/NondetInit.cc.o
Linking CXX static library ../../../../lib/libSeaInstNondet.a
[ 41%] Built target SeaInstNondet
Scanning dependencies of target seaopt
[ 41%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/AnalysisWrappers.cpp.o
[ 43%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/BreakpointPrinter.cpp.o
[ 43%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/GraphPrinters.cpp.o
[ 44%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/NewPMDriver.cpp.o
[ 44%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/Passes.cpp.o
[ 46%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/PassPrinters.cpp.o
[ 46%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/PrintSCC.cpp.o
[ 47%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/opt.cpp.o
Linking CXX executable ../../../bin/seaopt
[ 47%] Built target seaopt
Scanning dependencies of target CrabLlvmAnalysis
[ 49%] Building CXX object crab-llvm/lib/CrabLlvm/CMakeFiles/CrabLlvmAnalysis.dir/CfgBuilder.cc.o
In file included from /homes/dejan/workspace/seahorn/crab-llvm/lib/CrabLlvm/CfgBuilder.cc:19:
In file included from /homes/dejan/workspace/seahorn/crab-llvm/include/crab_llvm/CfgBuilder.hh:32:
/homes/dejan/workspace/seahorn/crab-llvm/include/crab_llvm/MemAnalysis.hh:162:45: error: use of undeclared identifier 'REG'
    MemAnalysis ():  m_dsa (0), m_tracklev (REG) { }
                                            ^
/homes/dejan/workspace/seahorn/crab-llvm/lib/CrabLlvm/CfgBuilder.cc:654:38: error: use of undeclared identifier 'MEM'
      if (m_mem->getTrackLevel () >= MEM) {
                                     ^
/homes/dejan/workspace/seahorn/crab-llvm/lib/CrabLlvm/CfgBuilder.cc:678:38: error: use of undeclared identifier 'MEM'
      if (m_mem->getTrackLevel () >= MEM) {        
                                     ^
/homes/dejan/workspace/seahorn/crab-llvm/lib/CrabLlvm/CfgBuilder.cc:813:40: error: use of undeclared identifier 'MEM'
        if (m_mem->getTrackLevel () >= MEM) {
                                       ^
/homes/dejan/workspace/seahorn/crab-llvm/lib/CrabLlvm/CfgBuilder.cc:828:40: error: use of undeclared identifier 'MEM'
        if (m_mem->getTrackLevel () >= MEM) {
                                       ^
/homes/dejan/workspace/seahorn/crab-llvm/lib/CrabLlvm/CfgBuilder.cc:846:40: error: use of undeclared identifier 'MEM'
        if (m_mem->getTrackLevel () >= MEM) {
                                       ^
/homes/dejan/workspace/seahorn/crab-llvm/lib/CrabLlvm/CfgBuilder.cc:1093:36: error: use of undeclared identifier 'MEM'
    if (m_mem->getTrackLevel () >= MEM)
                                   ^
/homes/dejan/workspace/seahorn/crab-llvm/lib/CrabLlvm/CfgBuilder.cc:1144:40: error: use of undeclared identifier 'MEM'
        if (m_mem->getTrackLevel () >= MEM && 
                                       ^
8 errors generated.
make[2]: *** [crab-llvm/lib/CrabLlvm/CMakeFiles/CrabLlvmAnalysis.dir/CfgBuilder.cc.o] Error 1
make[1]: *** [crab-llvm/lib/CrabLlvm/CMakeFiles/CrabLlvmAnalysis.dir/all] Error 2
make: *** [all] Error 2

Exceptions with libDSA

I am trying to use llvm-dsa to generate call graphs but libDSA always causes exceptions.

Here is how I compiled the llvm and lllvm-dsa:
OS: ubuntu server 16.04.3/gcc 5.4
I built llvm using cmake and enabled the LLVM RTTI. No other options are enabled.
I then changed the CMakeLists.txt files in llvm-dsa to build it as a shared library. I can load libDSA.so and print the help message. When I use the following command to test DSA with a simple C file:
opt -load ../build/lib/DSA/libDSA.so -dsa-td test.bc -stats -o test.ll
I had the following exception:

opt: /home/zhi/llvm/lib/IR/Instructions.cpp:349: bool llvm::CallInst::paramHasAttr(unsigned int, llvm::Attribute::AttrKind) const: Assertion `i < (getNumArgOperands() + 1) && "Param index out of bounds!"' failed.
#0 0x00000000027c2479 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/zhi/local/bin/opt+0x27c2479)
#1 0x00000000027c27d1 PrintStackTraceSignalHandler(void*) (/home/zhi/local/bin/opt+0x27c27d1)
#2 0x00000000027c0c17 llvm::sys::RunSignalHandlers() (/home/zhi/local/bin/opt+0x27c0c17)
#3 0x00000000027c1dc0 SignalHandler(int) (/home/zhi/local/bin/opt+0x27c1dc0)
#4 0x00007f245b1c6390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#5 0x00007f245a57f428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428)
#6 0x00007f245a58102a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a)
#7 0x00007f245a577bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7)
#8 0x00007f245a577c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#9 0x00000000022278a0 llvm::CallInst::paramHasAttr(unsigned int, llvm::Attribute::AttrKind) const (/home/zhi/local/bin/opt+0x22278a0)
#10 0x00007f245a297445 llvm::CallSiteBase<llvm::Function const, llvm::BasicBlock const, llvm::Value const, llvm::User const, llvm::Use const, llvm::Instruction const, llvm::CallInst const, llvm::InvokeInst const, llvm::Use const*>::paramHasAttr(unsigned int, llvm::Attribute::AttrKind) const (../build/lib/DSA/libDSA.so+0x208445)
#11 0x00007f245a294a1c llvm::CallSiteBase<llvm::Function const, llvm::BasicBlock const, llvm::Value const, llvm::User const, llvm::Use const, llvm::Instruction const, llvm::CallInst const, llvm::InvokeInst const, llvm::Use const*>::isByValArgument(unsigned int) const (../build/lib/DSA/libDSA.so+0x205a1c)
#12 0x00007f245a2901b1 llvm::functionIsCallable(llvm::ImmutableCallSite, llvm::Function const*) (../build/lib/DSA/libDSA.so+0x2011b1)
#13 0x00007f245a2905be llvm::DSGraph::buildCallGraph(DSCallGraph&, std::vector<llvm::Function const*, std::allocator<llvm::Function const*> >&, bool) const (../build/lib/DSA/libDSA.so+0x2015be)
#14 0x00007f245a2a4d8a llvm::LocalDataStructures::runOnModule(llvm::Module&) (../build/lib/DSA/libDSA.so+0x215d8a)
#15 0x000000000225c6c8 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) (/home/zhi/local/bin/opt+0x225c6c8)
#16 0x000000000225cdf9 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/zhi/local/bin/opt+0x225cdf9)
#17 0x000000000225d005 llvm::legacy::PassManager::run(llvm::Module&) (/home/zhi/local/bin/opt+0x225d005)
#18 0x0000000000f9a453 main (/home/zhi/local/bin/opt+0xf9a453)
#19 0x00007f245a56a830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830)
#20 0x0000000000f752a9 _start (/home/zhi/local/bin/opt+0xf752a9)
Stack dump:
0.	Program arguments: opt -load ../build/lib/DSA/libDSA.so -dsa-td test.bc -stats -o test.ll 
1.	Running pass 'Local Data Structure Analysis' on module 'test.bc'.
Aborted (core dumped)

Any help is appreciated. Thank you!

Issues in 4.0 port via the ilist iterators

Hello, I'm trying to port this to 4.0 (as part of a Crab port) and I'm having issues in that the 4.0 GraphTraits requires NodeRef to be a pointer, and so I get typedef DSNode* NodeRef. For example in dsa-seahorn/include/dsa/GraphTraits.h I changed NodeType referring to a DSNode instead to point to a DSNode:

template <> struct GraphTraits<DSGraph*> {
typedef DSNode* NodeRef;
typedef DSNode::iterator ChildIteratorType;

This seems to fix a number of issues for the node itself but when I go into DSGraph then I need iterators that can be dereferenced as NodeRef's...

I reached out to the mailing list and got the following:

I'm not sure what DSGraph::iterator returns on dereference; but ultimately you want both ChildIteratorType and nodes_iterator to dereference to a NodeRef, as documented. You may find llvm::pointer_iterator or llvm::pointee_iterator helpful.

So I'm trying to reimplement using the following type of fix (in DSGraph.h):

public:
  // Public data-type declarations...
  typedef DSScalarMap ScalarMapTy;
  typedef std::map<const Function*, DSNodeHandle> ReturnNodesTy;
  typedef std::map<const Function*, DSNodeHandle> VANodesTy;
  typedef DSNode* NodeReference;
  typedef ilist<NodeReference> NodeListTy;
...
  NodeListTy Nodes;

This is failing mostly in the instantiation of the ilist and I have to confess that I don't quite understand the ilist_sentinel_traits<DSNode> that was there (this was deprecated now so I changed that to simple_ilist<DSNode>, then simple_ilist<DSNode*> as I've understand the code a bit better and GraphTraits...

So, am I correct that given NodeRef being required to be a pointer the ilist_traits need to be implemented? Was that list_sentinel_traits<DSNode> giving you the quick sentinel and head creation needed for iteration? I've got a fork you can look at directly if you'd like but, it just feels like a lot of behind the scenes code gets pulled in and while I'm relatively confident that the NodeRef issues are moving along that's bumping into other problems.... Any help would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.