[llvm-dev] Dumping compiled module as LLVM IR bitcode after certain optimization passes

Mehdi Amini via llvm-dev llvm-dev at lists.llvm.org
Sat Dec 31 13:40:10 PST 2016


Also, if I have a small test-case, using `clang -mllvm -print-after-all` is convenient to get the IR at any point.
Adding "-filter-print-funcs” can help reducing the amount in the output to a single function (or a list of functions), for example:
`clang  -mllvm -filter-print-funcs=_Z3foov -mllvm -print-after-all`.

(There is a print-after option but it does not work in clang).

— 
Mehdi




> On Dec 31, 2016, at 12:09 PM, Mehdi Amini via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi,
> 
> Usually we disable the llvm optimizations (clang -mllvm disable-llvm-optzns ) and then use opt to run the passes till the point of interest. I don’t know of a shortcut in clang (the new PassManager will make it possible to pass an arbitrary pipeline with a string, but not there yet).
> 
>> Mehdi
> 
>> On Dec 31, 2016, at 11:43 AM, Alex Susu via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> 
>> Hello.
>>   Is there a possibility to instruct at command line the clang or the opt tools to emit LLVM bitcode file after a certain optimization pass such as LoopVectorize (or all optimization passes)? (This question was asked also at http://stackoverflow.com/questions/17904440/dump-ir-after-each-llvm-optimization-each-pass-both-llvm-ir-passes-and-backen .)
>>   As far as I can see giving:
>>     clang -save-temps ...
>>   generates a .bc file for the compiled module just before passing the module to the optimization passes (opt).
>> 
>>   An alternative I have is to programmatically generate the corresponding bitcode file at the right time after finishing the pass in discussion - see, for example, http://stackoverflow.com/questions/13903686/writing-module-to-bc-bitcode-file, methods WriteBitcodeToFile() or WriteModule() .
>> 
>> Thank you,
>>   Alex
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list