[llvm-bugs] [Bug 45826] New: using arm thumb register r7 in inline asm with -pg

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 7 05:13:51 PDT 2020


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

            Bug ID: 45826
           Summary: using arm thumb register r7 in inline asm with -pg
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arnd at linaro.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

With clang-8 or higher, I get errors about using the frame pointer register
(r7) when building the Linux kernel in thumb mode with "ftrace" enabled, which
passes '-pg', e.g.:

    arch/arm/probes/kprobes/actions-thumb.c:449:3: error: inline asm clobber
list contains reserved registers: R7 [-Werror,-Winline-asm]
                    "msr    cpsr_fs, %[oldcpsr]     \n\t"
    arch/arm/probes/kprobes/actions-thumb.c:449:3: note: Reserved registers on
the clobber list may not be preserved across the asm statement, and clobbering
them may lead to undefined behaviour.

See https://godbolt.org/z/6aVF_5 for a minmal example, also
$ echo 'void f(void) { asm("mov r7, #0" ::: "r7"); }' | clang-10
--target=arm-linux-gnueabi -O2 -funwind-tables -mthumb -pg -S -xc -
<stdin>:1:20: warning: inline asm clobber list contains reserved registers: R7
[-Winline-asm]

gcc produces the same error when I pass "-fno-omit-frame-pointer" or "-O0".

Both clang and gcc produce an error when combining "-pg" with
"-fomit-frame-pointer".

However, gcc can compile the example and the kernel source files with "-mthumb
-O2 -pg" as long as neither "-fomit-frame-pointer" nor
"-fno-omit-frame-pointer" is used.

I don't actually know which behavior is correct here, but I assume that either
clang or gcc does something wrong here. Opening the bug against clang for now
as it caused the symptom of the broken kernel configuration.

-- 
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/20200507/64199460/attachment.html>


More information about the llvm-bugs mailing list