[PATCH] D24020: [LTO] Added flag to generate assembly file with after LTO passes

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 11:47:11 PDT 2016

mehdi_amini added a comment.

In https://reviews.llvm.org/D24020#531164, @bunty2020 wrote:

> I have modified save temps to generate assembly file too. But, I had to clone the module for assembly generation. I would like to know if there is a work around to generate assembly without cloning module.

I already mentioned it in my previous comments: the codegen is modifying the IR. So running it two times on the same module is likely to give different results (Depending on your use-case, it may or may not matter to you, but it can be surprising).

Comment at: include/llvm/LTO/Config.h:150
@@ -145,1 +149,3 @@
+  /// This module hook is called before code generation. It generates
+  /// assembly file by running all the codegen passes on module
Comment says "before", name is "after".

Also you shouldn't describe what a hook is actually doing, this is up to the client.

Comment at: lib/LTO/LTOBackend.cpp:123
@@ -79,1 +122,3 @@
+  };
   setHook("0.preopt", PreOptModuleHook);
This will be "costly", we don't want this by default with "addSaveTemps".
And since it hasn't been needed till now, it is likely a "rare" need. Most of the time (i.e. always till now), using `clang -O2 -disable-llvm-optzns  output.lto.bc -S` is enough to reproduce the codegen and produce an assembly file out of the save-temps bitcode if needed.


More information about the llvm-commits mailing list