Commit cb45b8ed authored by Administrator's avatar Administrator
Browse files

added a few more helpers

parent c883ba2d
......@@ -353,6 +353,8 @@ foreach(src ${CPPSAMPLES})
OUTPUT ${CMAKE_SOURCE_DIR}/output/${src}.ll
COMMAND ${PATH_TO_LLVM}/bin/clang++ -O0 -emit-llvm ${CMAKE_SOURCE_DIR}/samples/${src}.cpp -Xclang -disable-O0-optnone -c -o ${CMAKE_SOURCE_DIR}/output/${src}.bc
COMMAND ${PATH_TO_LLVM}/bin/opt -S -mem2reg ${CMAKE_SOURCE_DIR}/output/${src}.bc -o ${CMAKE_SOURCE_DIR}/output/${src}.ll
COMMAND optdir=${PATH_TO_LLVM}/bin ${CMAKE_SOURCE_DIR}/helpers/flowgraph.sh ${CMAKE_SOURCE_DIR}/output/${src}.ll main
COMMAND optdir=${PATH_TO_LLVM}/bin ${CMAKE_SOURCE_DIR}/helpers/callgraph.sh ${CMAKE_SOURCE_DIR}/output/${src}.ll
DEPENDS clang opt ${CMAKE_SOURCE_DIR}/samples/${src}.cpp
COMMENT "Generating LLVM IR for example ${src}.cpp"
)
......
#!/bin/bash
if [[ -z $optdir ]]
then
echo setting opt to default
optdir=$(dirname $(which opt))
fi
$optdir/opt -enable-new-pm=0 -dot-callgraph -S "$1" -disable-output
cat "$1".callgraph.dot | c++filt | sed 's,>,\\>,g; s,-\\>,->,g; s,<,\\<,g' | dot -Tsvg > "$1.staticcallgraph.svg"
#dot -Tsvg output/classes.ll.callgraph.dot > classes.svg
\ No newline at end of file
#!/bin/bash
if [[ -z $optdir ]]
then
echo setting opt to default
optdir=$(dirname $(which opt))
fi
$optdir/opt --dot-cfg -cfg-func-name="$2" "$1" -disable-output
cat ".$2".dot | c++filt | dot -Tsvg > "$1.$2.svg"
rm ".$2".dot
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment