[llvm-bugs] [Bug 51634] New: Issue with passing expression to inline assembly in Linux kernel

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 26 11:52:51 PDT 2021


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

            Bug ID: 51634
           Summary: Issue with passing expression to inline assembly in
                    Linux kernel
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: natechancellor at gmail.com
                CC: llvm-bugs at lists.llvm.org, nemanja.i.ibm at gmail.com

Created attachment 25195
  --> https://bugs.llvm.org/attachment.cgi?id=25195&action=edit
Reduced program

Initial explanation of the issue by Michael Ellerman:
https://lore.kernel.org/r/87h7fcc2m4.fsf@mpe.ellerman.id.au/

clang does not emit a clrlwi instruction for the attached program, resulting in
incorrect behavior at runtime, as noted in the above post.

$ clang -O2 --target=powerpc64-linux-gnu -c -o warn_on.o warn_on.c

$ llvm-objdump -dr warn_on.o

warn_on.o:      file format elf64-powerpc

Disassembly of section .text:

0000000000000000 <.text>:
       0: f8 83 00 00   std 4, 0(3)
       4: 0b 04 00 00   tdnei   4, 0
       8: 4e 80 00 20   blr
       c: 4e 80 00 20   blr
                ...

Compared to GCC 11.2.0:

$ powerpc64-linux-gcc -O2 -c -o warn_on.o warn_on.c

$ llvm-objdump -dr warn_on.o

warn_on.o:      file format elf64-powerpc

Disassembly of section .text:

0000000000000000 <.text>:
       0: 54 89 07 fe   clrlwi  9, 4, 31
       4: f8 83 00 00   std 4, 0(3)
       8: 0b 09 00 00   tdnei   9, 0
       c: 4e 80 00 20   blr
                ...

Changing

"r"(knode_dead(knode))

to

"r"(!!knode_dead(knode)

does make clang emit the clrlwi instruction:

$ clang -O2 --target=powerpc64-linux-gnu -c -o warn_on.o warn_on.c

$ llvm-objdump -dr warn_on.o

warn_on.o:      file format elf64-powerpc

Disassembly of section .text:

0000000000000000 <.text>:
       0: 54 85 07 fe   clrlwi  5, 4, 31
       4: f8 83 00 00   std 4, 0(3)
       8: 0b 05 00 00   tdnei   5, 0
       c: 4e 80 00 20   blr
      10: 4e 80 00 20   blr
                ...

but that seems to be more of a workaround than addressing the root cause?

-- 
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/20210826/09bbfd4c/attachment.html>


More information about the llvm-bugs mailing list