Good day,
I am trying to run opt optimization passes directly from clang, rather than reducing a file down to llvm IR, and then using opt.
for example rather than use
clang -S -emit-llvm test.c -o test.ll
opt -mem2reg test.ll -o test_m2r.ll
I would like to use just a clang flag. Previous discussions on the issue seem divided on the issue (https://groups.google.com/g/llvm-dev/c/Y1HHgpmBidM) with some suggesting the use of -mllvm - and others stating that there might be no way to this.
I have tried using the -mllvm method as
clang -mllvm -mem2reg test.c -o test
and get the following error
clang (LLVM option parsing): Unknown command line argument '-mem2reg'. Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--mv62'?
Is there any alternative to do this?
Secondly if this is not possible, will it be possible to register a custom opt pass which is always enabled in clang, and can be turned off with a flag.
something like
clang -mllvm -enable-my-pass=<true/false> test.c
I am new to llvm and am unsure if either of the above options is possible. My use case is to run a benchmark with a custom pass. If there is a way to enable the pass as a CFLAG, it reduces the editing done to the makefile to get the benchmark working.