Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why optimizations passes doesn't work without mem2reg?

Why i have to do this mem2reg pass in bytecode optimization for obtaining another optimization pass result's? What's the use of mem2reg?

opt -dce myfile.bc

in this case i haven't changes in the output code

opt -mem2reg -dce myfile.bc

in this second case i have changes in the output code

edit: LLVR IR is still into SSa form, isn't it? using mem2reg i should have a "pruned" SSA form, is right?

like image 753
Nicola Avatar asked Jan 27 '26 18:01

Nicola


1 Answers

mem2reg pass converts non-SSA form of LLVM IR into SSA form, raising loads and stores to stack-allocated values to "registers" (SSA values). Many of LLVM optimization passes operate on the code in SSA form and thus most probably will be no-op seeing IR in non-SSA form.

A bit more information is here: http://llvm.org/docs/Passes.html#mem2reg-promote-memory-to-register

like image 94
Anton Korobeynikov Avatar answered Jan 30 '26 16:01

Anton Korobeynikov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!