This is an archive of the discontinued LLVM Phabricator instance.

[gold] emit assembly listing from gold plugin on LTO stage
ClosedPublic

Authored by dendibakh on Dec 27 2018, 3:00 PM.

Details

Summary

Sometimes it's useful to emit assembly after LTO stage to modify it manually. Emitting precodegen bitcode file (via save-temps plugin option) and then feeding it to llc doesn't always give the same binary as original.
This patch is simpler alternative to https://reviews.llvm.org/D24020.

Diff Detail

Repository
rL LLVM

Event Timeline

dendibakh created this revision.Dec 27 2018, 3:00 PM

Nit on patch description: use [gold] not [LTO] since this is about the gold plugin specifically, and not a change to the LTO API. Also, please add a gold test.

tools/gold/gold-plugin.cpp
1078

Rather than doing this copying, I think you could modify the invocation of getOutputFileName so that it sets Filename to output_name (or maybe output_name + ".s"?) in this case. I.e. see what it does when the output type is OT_SAVE_TEMPS. Then it should emit the assemble to the desired file directly.

dendibakh updated this revision to Diff 179934.Jan 2 2019, 1:55 PM
dendibakh retitled this revision from [LTO] emit assembly listing from LTO stage to [gold] emit assembly listing from gold plugin on LTO stage.

Updated title, added test and removed copying files.
I decided not to add '.s' to the filename, because then user can also name it as "out.s" and it will be "out.s.s" which seems unnatural.

dendibakh marked an inline comment as done.Jan 2 2019, 1:57 PM
tejohnson accepted this revision.Jan 2 2019, 2:04 PM

LGTM, with a change to the gold invocations to make the test more portable.

test/tools/gold/X86/emit-asm.ll
3 ↗(On Diff #179934)

Please add "-m elf_x86_64" to the gold invocations.

This revision is now accepted and ready to land.Jan 2 2019, 2:04 PM
dendibakh updated this revision to Diff 179942.Jan 2 2019, 2:16 PM

Added "-m elf_x86_64" to the gold invocation.

@tejohnson, can you please commit this patch on my behalf?

dendibakh marked an inline comment as done.Jan 2 2019, 2:17 PM

Added "-m elf_x86_64" to the gold invocation.

@tejohnson, can you please commit this patch on my behalf?

Sure, will do so shortly.

This revision was automatically updated to reflect the committed changes.