SVF
SVF copied to clipboard
How do you analyze the entire project on top of wllvm
Hello author, may I ask how SVF can produce the call graph of the whole project (including.h file and.c file)? I have seen what you said about using wllvm before, what does this mean? Will svf run directly on wllvm? What am I supposed to do? Is there documentation?
I'm not the author but I hope my answer could help..
SVF takes LLVM bitcode (*.bc) / text IR file (*.ll) as input, so if you want to analyze an entire project / program, you should (1) try to produce a whole-program LLVM IR, and (2) use SVF to do the analysis you want (e.g., wpa -ander -dump-icfg all.bc
).
To produce the whole-program LLVM bitcode, you can use WLLVM, which is designed for this. You can also use clang + llvm-link (e.g., clang -O2 -c -emit-llvm -o source1.bc source1.c
and llvm-link source1.bc source2.bc ... -o all.bc
) if you like.
Thank you for your answer, you are a great developer
发自我的企业微信
----------Reply to Message---------- On Wed, Mar 15, 2023 22:44 PM Shengjie @.***> wrote:
I'm not the author but I hope my answer could help..
SVF takes LLVM bitcode (.bc) / text IR file (.ll) as input, so if you want to analyze an entire project / program, you should (1) try to produce a whole-program LLVM IR, and (2) use SVF to do the analysis you want (e.g., wpa -ander -dump-icfg all.bc).
To produce the whole-program LLVM bitcode, you can use WLLVM, which is designed for this. You can also use clang + llvm-link (e.g., clang -O2 -c -emit-llvm -o source1.bc source1.c and llvm-link source1.bc source2.bc ... -o all.bc) if you like.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
@yuleisui Could SVF analyze multiple bitcodes at the same time? I tried this example by
../svf-latest/Debug-build/bin/wpa -ander a.bc main.bc
but SVF aborted at:
../svf-latest/svf-llvm/include/SVF-LLVM/LLVMModule.h:198: SVF::SVFFunction* SVF::LLVMModuleSet::getSVFFunction(const Function*) const: Assertion `it!=LLVMFunc2SVFFunc.end() && "SVF Function not found!"' failed.
Would you upload those bcs? It should be able to analyse multiple files, but we haven’t tested for a while, it might be some marginal issues and can be fixed quickly. @xudon9 could you have a look at this issue in LLVMModule/SVFModule?
thank you for your answer, I appreciate it. I use wllvm to build the whole project .bc file s to solve the question, and I succeeded. 😂
发自我的企业微信
----------Reply to Message---------- On Wed, Mar 15, 2023 22:44 PM Shengjie @.***> wrote:
I'm not the author but I hope my answer could help..
SVF takes LLVM bitcode (.bc) / text IR file (.ll) as input, so if you want to analyze an entire project / program, you should (1) try to produce a whole-program LLVM IR, and (2) use SVF to do the analysis you want (e.g., wpa -ander -dump-icfg all.bc).
To produce the whole-program LLVM bitcode, you can use WLLVM, which is designed for this. You can also use clang + llvm-link (e.g., clang -O2 -c -emit-llvm -o source1.bc source1.c and llvm-link source1.bc source2.bc ... -o all.bc) if you like.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
@yuleisui Could SVF analyze multiple bitcodes at the same time? I tried this example by
../svf-latest/Debug-build/bin/wpa -ander a.bc main.bc
but SVF aborted at:
../svf-latest/svf-llvm/include/SVF-LLVM/LLVMModule.h:198: SVF::SVFFunction* SVF::LLVMModuleSet::getSVFFunction(const Function*) const: Assertion `it!=LLVMFunc2SVFFunc.end() && "SVF Function not found!"' failed.
Hi, I reviewed the code that collects all llvm::Function
s to SVFModule. In theory, it should be able to handle multiple *.bc
files. If possible, you can share the bitcode files you're using so we can reproduce the error.
SVF1028.zip @yuleisui @xudon9 Thanks a lot, the source code and bitcodes are attached. The compile command is
clang -emit-llvm -O0 -g -c a.c -o a.bc
Thanks @timmyyuan for bringing this to our attention.
Long story short, when creating SVFFunction
s, there is a reference to another SVFFunction
that has not been created yet. This was not an issue in the past when we used LLVM data structures directly. To address this, it looks like we will need to do some refactoring. I'll take a closer look and see what we can do to resolve the issue.
For now one workaround might be what @BookerShi has suggested -- to combine all bitcode files with wllvm
.