Awesome
CFG Flattening LLVM Pass
Control-flow Graph Flattening pass for LLVM 17
Build the pass
$ mkdir build
$ cd build
$ cmake ..
$ make
$ cd ..
Run the pass
# 1 iteration (default)
$ clang -fpass-plugin=`echo build/pass/FlattenCFGPass.*` something.c
# 3 iterations
$ clang -fplugin=`echo build/pass/FlattenCFGPass.*` -fpass-plugin=`echo build/pass/FlattenCFGPass.*` something.c -mllvm -iterations=3
Examples
Original CFG | One iteration | Two iterations |
---|---|---|