[lld] [lld][COFF][LTO] Implement /lldemit:asm option (PR #67079)

Matheus Izvekov via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 03:35:58 PDT 2023


================
@@ -235,20 +245,21 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
     if (bitcodeFilePath == "ld-temp.o") {
       ltoObjName =
           saver().save(Twine(ctx.config.outputFile) + ".lto" +
-                       (i == 0 ? Twine("") : Twine('.') + Twine(i)) + ".obj");
+                       (i == 0 ? Twine("") : Twine('.') + Twine(i)) + Ext);
     } else {
       StringRef directory = sys::path::parent_path(bitcodeFilePath);
-      StringRef baseName = sys::path::filename(bitcodeFilePath);
+      StringRef baseName = sys::path::stem(bitcodeFilePath);
       StringRef outputFileBaseName = sys::path::filename(ctx.config.outputFile);
       SmallString<64> path;
       sys::path::append(path, directory,
-                        outputFileBaseName + ".lto." + baseName);
+                        outputFileBaseName + ".lto." + baseName + Ext);
       sys::path::remove_dots(path, true);
       ltoObjName = saver().save(path.str());
     }
-    if (ctx.config.saveTemps)
+    if (ctx.config.saveTemps || emitASM)
----------------
mizvekov wrote:

No, for the emit-asm case we still stop short of linking the final executable.
The ELF linker works the same way here.

For the LTO case, there is a phase before linking where we generate obj files from the input bitcode.

We just hook up our new flag to change the output type of that phase to assembly, and resuse the same code saveTemps uses to save the intermediate object files, but now instead they are assembly files.

https://github.com/llvm/llvm-project/pull/67079


More information about the llvm-commits mailing list