https://bugs.llvm.org/show_bug.cgi?id=36078

            Bug ID: 36078
           Summary: __attribute__((naked)) function loses parameter
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: momchil.veli...@arm.com
                CC: llvm-bugs@lists.llvm.org

Created attachment 19740
  --> https://bugs.llvm.org/attachment.cgi?id=19740&action=edit
minimal testcase

LLVM discards a parameter of a function, declared with the "naked" attribute.

Compiling the attached test program for Arm with `clang -target arm-eabi -O3 -S
naked.c` output the following assembly for `bar`:

    bar:
            .fnstart
            b       foo

i.e. the parameter to `foo` is not passed at all.

This change occurs during "Deduce function attributes", which marks the
parameter with "readnone" and subsequently it's removed by "Promote 'by
reference' arguments to scalars" pass.

    *** IR Dump After Function Integration/Inlining ***
    ; Function Attrs: naked noinline nounwind
    define internal fastcc i32 @foo(i32*) unnamed_addr #1 {
    entry:
      call void asm sideeffect "ldr r0, [r0] \0Abx lr        \0A", ""() #2,
!srcloc !3
      unreachable
    }
    *** IR Dump After Deduce function attributes ***
    ; Function Attrs: naked noinline nounwind
    define internal fastcc i32 @foo(i32* nocapture readnone) unnamed_addr #1 {
    entry:
      call void asm sideeffect "ldr r0, [r0] \0Abx lr        \0A", ""() #2,
!srcloc !3
      unreachable
    }
    *** IR Dump After Promote 'by reference' arguments to scalars ***
    ; Function Attrs: naked noinline nounwind
    define internal fastcc i32 @foo() unnamed_addr #1 {
    entry:
      call void asm sideeffect "ldr r0, [r0] \0Abx lr        \0A", ""() #2,
!srcloc !3
      unreachable
    }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to