google / souper

A superoptimizer for LLVM IR
Apache License 2.0
2.17k stars 170 forks source link

Rgiht way to use souper #872

Closed ChijinZ closed 1 year ago

ChijinZ commented 1 year ago

Hi, I'm new to souper and currently investigating it. I tried to use it to compile sqlite (https://www.sqlite.org/download.html) with command line path/to/sclang shell.c sqlite3.c -lpthread -ldl -lm -o sqlite_sclang. It can successfully and quickly compile sqlite, but nothing happens. I expect that it should take a long time to analyze the code, optimize the code, and output some useful optimization hints. Does I use souper correctly?

I enable the SOUPER_DEBUG flag and the compilation flags seems ok. Output message:

# command line
env SOUPER_DEBUG=1 time /path/to/souper/build/sclang shell.c sqlite3.c -lpthread -ldl -lm -o sqlite_sclang

# output
/path/to/souper/third_party/llvm-Release-install/bin/clang shell.c sqlite3.c -lpthread -ldl -lm -o sqlite_sclang -Xclang -load -Xclang /path/to/souper/build/libsouperPass.so -fpass-plugin=/path/to/souper/build/libsouperPass.so -fplugin-arg-souper-solver-timeout=15 -mllvm -souper-double-check -mllvm -souper-debug-level=1 -mllvm -souper-external-cache
1.22user 0.08system 0:01.30elapsed 99%CPU (0avgtext+0avgdata 198748maxresident)k
0inputs+6728outputs (0major+46400minor)pagefaults 0swaps
regehr commented 1 year ago

hello, you will need to pass an optimization flag such as -O3 to sclang, otherwise LLVM will not run any optimization passes, including souper

ChijinZ commented 1 year ago

Oh, that's a silly mistake, sorry for that.