Carlo Kok via llvm-dev
2022-Jan-04 20:05 UTC
[llvm-dev] ASM disappears when NOT optimizing
When compiling: ; ModuleID = 'ExternalCalls-6069268ae2f83f7c993054596767686a' source_filename = "ExternalCalls-6069268ae2f83f7c993054596767686a" target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "aarch64-linux-gnu" define weak void @_start() #1 { BasicBlock107: call void asm "\0D\0A mov x29, #0x0\0D\0A mov x30, #0x0\0D\0A mov x5, x0\0D\0A ldr x1, [sp]\0D\0A add x2, sp, #0x8\0D\0A mov x6, sp\0D\0A adrp x0, __elements_entry_point_helper\0D\0A add x0, x0, :lo12:__elements_entry_point_helper\0D\0A adrp x3, __elements_init\0D\0A add x3, x3, :lo12:__elements_init\0D\0A adrp x4, __elements_fini\0D\0A add x4, x4, :lo12:__elements_fini\0D\0A bl __libc_start_main\0D\0A\0D\0A ", ""() ret void } attributes #1 = { naked uwtable } I get this in -O0 (with LLC) _start: // @_start ret In O1/2/3 I get: _start: // @_start mov x29, #0 mov x30, #0 mov x5, x0 ldr x1, [sp] add x2, sp, #8 mov x6, sp adrp x0, __elements_entry_point_helper add x0, x0, :lo12:__elements_entry_point_helper adrp x3, __elements_init add x3, x3, :lo12:__elements_init adrp x4, __elements_fini add x4, x4, :lo12:__elements_fini bl __libc_start_main ret godbolt repro: https://godbolt.org/z/MoMzE9Kha Can anyone tell me what I'm doing wrong here? -- Carlo Kok
Jacob Lifshay via llvm-dev
2022-Jan-04 20:56 UTC
[llvm-dev] ASM disappears when NOT optimizing
On Tue, Jan 4, 2022, 12:04 Carlo Kok via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > BasicBlock107: > call void asm "\0D\0A mov x29, #0x0\0D\0A >you forgot to add sideeffect to the asm -- because you told it it has no outputs, and doesn't affect anything else (no sideeffect), llvm decided to omit it. Jacob>-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20220104/d478232f/attachment.html>