Analyze data dependence of call expression.
This project is supposed to analyze data dependence of call expression, e.g., input, flow, anti and output dependence. Existing date-dependence analysis pass in LLVM is hard to analyze the dependence between call expression (e.g., foo(a)) and variables (e.g., b) . To help this situation, CallDependence converts the dependence between call and variables to dependence between arguments (of the call, e.g., a) and variable, and then infers the call dependence.
- Change directory to LLVM lib transform directory.
cd path/to/llvm-source-tree/lib/Transforms
- Download source code.
git clone https://github.com/ZhouyangJia/CallDependence.git
- Add add_subdirectory(CallDependence) to CMakeList.txt.
echo "add_subdirectory(CallDependence)" >> CMakeLists.txt
- Recompile LLVM and try following command to test.
ls path/to/llvm-build/Release/lib/*CallDependence*
- Generate compile_commands.json. More information about compile_commands.json.
cd test/
tar zxvf bftpd-3.2.tar
cd bftpd/
./configure
bear make
- Generate build_ir.sh, This file is used to build LLVM IR for each file.
../../script/extract_command.pl compile_commands.json
- Build LLVM IR.
./build_ir.sh
- Get analysis result.
../../script/all_call_dependence.sh
The result is written in call_dependence.cvs, and represented as a 7-tuples:
< file_name, caller_name, callee_name, call_line, inst_line, arg_id, dep_type >, where:
file_name is the file where the dep. locates.
caller_name and callee_name are the names of caller and callee function, repectively.
call_line and inst_line are the line numbers of call and inst, respectively.
arg_id means the index of argument which makes the dependence happens. 0 means return value, whereas 1,2,... indicate arguments.
dep_type has 4 types: flow, anti, output, input.