I have been using LLVM/Clang and its Intermediate Representation(IR) for a while now. I have recently started working with GCC. I want to dump IR bitcode to a file, similar to (-flto -save-temps flag) in LLVM.
I can get gimple IR using '-fdump-tree-cfg-raw' flag while building, but with multiple input files, this generates an a '.gimple' file for each source.
To get the view of the entire program, in LLVM, I used '-flto -Wl,-plugin-opt=save-temps' in LDFLAGS. What is the correct way of getting the same behavior in GCC.
I tried using 'gcc -fdump-tree-cfg-raw -flto -save-temps src1.c main.c', but I do not get the combined IR file. The outputs include .o,.s,.i files for each source and .cfg file for each.
You don't see the merged file because this pass was not executed by lto. All the passes executed by cc1 are not necessarily executed by lto. A solution could be to use
fdump-tree-all option
you will get all the gimple files for the entire program. For each pass executed you will get
exec.ltrans.xxxt.pass_name
. Otherwise, if you don't want to use fdump-tree-all you must be sure that the pass you want to dump will be executed by the lto.