[llvm-bugs] [Bug 50318] New: Inline asm clobber list reserved register warning should point to the clobber list itself

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 12 07:54:39 PDT 2021


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

            Bug ID: 50318
           Summary: Inline asm clobber list reserved register warning
                    should point to the clobber list itself
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david.spickett at linaro.org
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

(writing this prior to https://reviews.llvm.org/D102244 landing, so the exact
output may have changed by now)

This applies to all architectures, here's an Arm example.

Test file:
void bar(void)
{
    __asm__ __volatile__ ( "nop" : 
                                 : : "sp");
}

Compile with:
./bin/clang --target=arm-arm-none-eabi -march=armv7-m -c bar.c -o bar.o

You get:
bar.c:3:28: warning: inline asm clobber list contains reserved registers: SP
[-Winline-asm]
    __asm__ __volatile__ ( "nop" :
                           ^
<inline asm>:1:1: note: instantiated into assembly here
        nop
^
bar.c:3:28: note: Reserved registers on the clobber list may not be preserved
across the asm statement, and clobbering them may lead to undefined behaviour.
    __asm__ __volatile__ ( "nop" : : : "sp");
                           ^
<inline asm>:1:1: note: instantiated into assembly here
        nop
^
1 warning generated.

Ideally the warning would point to the clobber list itself. This can be useful
if you use an alias for the reserved register.

E.g. "r13" instead of "sp" on arm. If the user goes to search their file for
"sp" they won't find it, but pointing to the clobber list gives a stronger
hint.

Currently, I think there is only one source location node for the whole inline
asm block and this is why we always mark the start of the block. The clobber
list is its own operand but I don't see a way to get a specific source location
for it.

-- 
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/20210512/24ef1bd7/attachment.html>


More information about the llvm-bugs mailing list