About using mem2reg pass only for SSA form

Hello,

I am using mem2reg to provide SSA form. However, I found that it also do some optimization work, e.g., remove some unnecessary code. May I ask is it possible to use mem2reg only to generate SSA form without any other changes to the code? Because the originial code is important to me.

I have integrated a PromotePass pass to clang backend when generating IR, and need this to achieve the above goal, but I am not sure whether it is feasible to modify the source code of PromoteMemoryToRegister.cpp or Mem2Reg.cpp in llvm/Transforms/Utils directory.

Thanks!
Padefic