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

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 30 09:10:21 PDT 2016


mehdi_amini added inline comments.

================
Comment at: lib/LTO/LTOBackend.cpp:49
@@ -37,1 +48,3 @@
+
+
 Error Config::addSaveTemps(std::string OutputFileName,
----------------
I rather not have any cl::opt controlling the behavior of the API.

================
Comment at: lib/LTO/LTOBackend.cpp:178
@@ +177,3 @@
+
+  if(FLTOAsmFilename == ""){
+    EC = sys::fs::createTemporaryFile("llvm-flto", "s", FD, OutputFile);
----------------
tejohnson wrote:
> Better to set this up in addSaveTemps (but keep optional) and use the same file naming used there (and remove the FLTOAsmFilename option). You could then do it via a new variant of setHook (e.g. setAsmHook) and create a new config hook like PrintAsmHook.
> 
> E.g. something like
> 
> auto setAsmHook = [&](ModuleHookFn &Hook) {
>     // Keep track of the hook created earlier, which also needs to run.
>     ModuleHookFn ExistingHook = Hook;
>     Hook = [=](unsigned Task, const Module &M, const TargetMachine *TM) {
>    ... create the filename as in setHook but with .s extension and invoke addPassesToEmitFile...
> }
> ...
> setAsmHook(PrintAsmHook);
> 
> Then you would replace where you are calling genAssemblyFile with an invocation of that new hook.
> 
I agree that this would be better, however usual hooks don't have access to the targetMachine, and more important, the CodeGen actually modifies the Module, which forces it to be cloned entirely before dumping the ASM.


https://reviews.llvm.org/D24020





More information about the llvm-commits mailing list