[cfe-dev] [llvm-dev] An error of asm goto occured while compiling Linux kernel 5.3

Tim Northover via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 26 13:01:55 PDT 2019


Hi Will,

I'm adding cfe-dev since this potentially covers both areas.

On Thu, 26 Sep 2019 at 15:45, Will Lester via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I encountered an error while compiling Linux kernel 5.3 to IR.
> My LLVM version is 9.0.0 release.

The error message you quote can only be emitted after LLVM has started
turning IR into machine code. What's the actual Clang command that
produces this error?

> This error said "invalid operand for inline asm constraint 'i'" in
> arch/x86/include/asm/jump_table.h.

This is a pretty fragile use of that constraint, since it's declaring
that something must be a constant when that can only happen via
optimizations. I'm not convinced that's what's going on here though.
Kernels aren't usually compiled at -O0 and I think I trust the Linux
developers to make sure users are passing an obvious constant.

> The source code is
> static __always_inline bool arch_static_branch(struct static_key *key,
> bool branch)
> {
> asm_volatile_goto("1:"
> ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
> ".pushsection __jump_table,  \"aw\" \n\t"
> _ASM_ALIGN "\n\t"
> ".long 1b - ., %l[l_yes] - . \n\t"
> _ASM_PTR "%c0 + %c1 - .\n\t"
> ".popsection \n\t"
> : :  "i" (key), "i" (branch) : : l_yes);
>
> return false;
> l_yes:
> return true;
> }
>
> The error pointed to asm_volatile_goto("1:"
> I'm not sure whether this error is related to asm goto support.



More information about the cfe-dev mailing list