Hi All,
When -flto is combined with -S on the clang command line, the output .s file contains IR content instead of target assembly language.
Is this expected/correct behavior? I was anticipating that the output .s file would contain target assembly code.
~ Todd Snider
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
David,
Thanks for the reply. That makes sense.
A couple of further thoughts … In the LTO implementation that I am working on, when -flto is specified to the compiler, the compiler embeds the IR in the compiler generated object file. The linker can then read the IR out of the incoming object file if LTO is enabled at link time or just ignore the IR if LTO is disabled at link time.
I would agree that having -S write out the IR content for -flto provides a good way to see what is being fed into the LTO link in a human readable form.
For our LTO implementation, the linker can be told to keep the IR that it extracts from the incoming object files. You can then run llvm-dis over the extracted IR to see the .ll version.
~ Todd
David,
Thanks for the reply. That makes sense.
A couple of further thoughts … In the LTO implementation that I am working on, when -flto is specified to the compiler, the compiler embeds the IR in the compiler generated object file. The linker can then read the IR out of the incoming object file if LTO is enabled at link time or just ignore the IR if LTO is disabled at link time.
On Mon, Oct 18, 2021 at 3:55 PM Snider, Todd <t-sn...@ti.com> wrote:
David,
Thanks for the reply. That makes sense.
A couple of further thoughts … In the LTO implementation that I am working on, when -flto is specified to the compiler, the compiler embeds the IR in the compiler generated object file. The linker can then read the IR out of the incoming object file if LTO is enabled at link time or just ignore the IR if LTO is disabled at link time.
Fair enough - in that case, I guess you might want your compiler to generate both? It could generate x.ll for the LLVM IR and x.s for the machine assembly.
David,
Thanks for the reply. That makes sense.
A couple of further thoughts … In the LTO implementation that I am working on, when -flto is specified to the compiler, the compiler embeds the IR in the compiler generated object file. The linker can then read the IR out of the incoming object file if LTO is enabled at link time or just ignore the IR if LTO is disabled at link time.
I would agree that having -S write out the IR content for -flto provides a good way to see what is being fed into the LTO link in a human readable form.
For our LTO implementation, the linker can be told to keep the IR that it extracts from the incoming object files. You can then run llvm-dis over the extracted IR to see the .ll version.
_______________________________________________
~ Todd
From: David Blaikie <dbla...@gmail.com>
Sent: Monday, October 18, 2021 4:21 PM
To: Snider, Todd <t-sn...@ti.com>
Cc: llvm...@lists.llvm.org
Subject: [EXTERNAL] Re: [llvm-dev] Question about -flto behavior
Yeah, sounds expected to me - flto produces object files that aren't really object files - instead they're LLVM IR (bitcode) that the linker identifies, then calls back into LLVM to link the IR, optimize on that IR, then produce object code/assembly/whatever).
So the "assembly" form of an "object" (really LLVM bitcode) file is LLVM textual IR.
On Mon, Oct 18, 2021 at 1:56 PM Snider, Todd via llvm-dev <llvm...@lists.llvm.org> wrote:
Hi All,
When -flto is combined with -S on the clang command line, the output .s file contains IR content instead of target assembly language.
Is this expected/correct behavior? I was anticipating that the output .s file would contain target assembly code.
~ Todd Snider
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Yes, if the end user application is building with LTO, then we are going through code generation unnecessarily during -flto compiles.
However, one of the motivations for embedding the IR in object code is so that the libc and other runtime libraries can be pre-built and shipped with embedded bitcode IR. The runtime libraries can then be linked in whether the end user application chooses to built with LTO or not.
I’m speculating that this tradeoff becomes less cost effective as the user application gets very big, but it is probably a reasonable tradeoff for embedded applications.
~ Todd
It would be entirely possible to deliver library binaries that are IR-only. In that case, if the application build doesn’t use LTO, the linker will apply LTO only to the library, and then the link will proceed normally. Or, if the application does use LTO, the LTO process will incorporate the library code as well. You can mix-and-match objects and IR in a link.
--paulr