This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug inline-asm/84861] -flto with asm() optimizes too much
- From: "marxin at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 14 Mar 2018 11:34:57 +0000
- Subject: [Bug inline-asm/84861] -flto with asm() optimizes too much
- Auto-submitted: auto-generated
- References: <bug-84861-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84861
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |marxin at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
> The only difference is "-flto".
Having a top-level assembly requires to disable LTO for the compilation unit
(-fno-lto). Otherwise
as Andrew mentioned it can screw up LTO partitioning.
>
> It this a problem of LTO, or is the assembler supposed to be tweaked (how?)
> so that the symbols get exported?
>
> Having a file containing
> asm ("");
> does compile, but a file containing only:
> asm volatile ("");
> fails with "error: expected ‘(’ before ‘volatile’".
asm volatile can be used just within in a function body.
The best approach you can do is to define a normal function
and use asm to implement what you have written in assembly:
...
" movq %rax, 0(%rdi)" "\n"
" movq %rbx, 8(%rdi)" "\n"
" movq %rcx, 16(%rdi)" "\n"
...
Then LTO will work because the assembly will be encapsulated in a function.
>
> Happens with gcc 8.0.1 20180306 (experimental).