[llvm-bugs] [Bug 28641] New: Emit a warning if inline assembly with a clobber list is used inside a naked function.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 21 04:18:47 PDT 2016


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

            Bug ID: 28641
           Summary: Emit a warning if inline assembly with a clobber list
                    is used inside a naked function.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pierregousseau14 at gmail.com
                CC: llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com
    Classification: Unclassified

Having inline assembly with a clobber list in a function marked naked seems
dangerous as this will alter the stack but only at -O0 in the case below,
higher optimisations level are fine.

eg:
$ clang --version
clang version 3.9.0 @r276109
Target: x86_64-unknown-linux-gnu

  #include <stdlib.h>

  __attribute__((__naked__, __noinline__)) int foo(size_t) 
  {
    __asm__ __volatile__ (
      "ret" : : : "rdi"
    );
  }

$ clang -O0 -S test.cpp

# BB#0:                                 # %entry
        movq    %rdi, -16(%rbp)         # 8-byte Spill <- Stack altered
        #APP
        retq
        #NO_APP

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160721/9f82c8fc/attachment.html>


More information about the llvm-bugs mailing list