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

            Bug ID: 42762
           Summary: unexpected codegen for inline asm
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedb...@nondot.org
          Reporter: ndesaulni...@google.com
                CC: hfin...@anl.gov, kit.bar...@gmail.com,
                    llvm-bugs@lists.llvm.org, nemanja.i....@gmail.com
            Blocks: 4068

The powerpc (32b) Linux kernel started panicing at runtime recently when built
with LLVM due to a change in the kernel sources.  We narrowed it down to
commit, and a single call site of a static inline function containing extended
inline assembly with constraints.

I think this concise test case distills this issue:
https://godbolt.org/z/E4f1Us

Basically, we had:

// from arch/powerpc/include/asm/cache.h
// pre-commit 6c5875843b87 ("powerpc: slightly improve cache helpers")
void dcbz_old(void* addr)
{
    asm volatile ("dcbz 0, %0" : : "r"(addr) : "memory");
}

then moved to:

// from arch/powerpc/include/asm/cache.h
// post-commit 6c5875843b87 ("powerpc: slightly improve cache helpers")
void dcbz_current(void* addr)
{
    asm volatile ("dcbz %y0" :: "Z"(*(unsigned char*)addr) : "memory");
}

It seems that GCC generates the same code for both cases, and LLVM matches GCC
for the first case.  In the second case, the codegen is wildly different, which
seems like what's leading to our panic at runtime.

I'm not super familiar with the "Z" constraint and "%y" output format, but they
might be related?


Referenced Bugs:

https://bugs.llvm.org/show_bug.cgi?id=4068
[Bug 4068] [Meta] Compiling the Linux kernel with clang
-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to