Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv: error: expected '(' or optional integer offset after LLVM commit f281543a48905e58359c6b0f1b9c3b42bd67e315 #1928

Closed
samitolvanen opened this issue Aug 31, 2023 · 4 comments
Labels
[ARCH] risc-v This bug impacts ARCH=riscv [BUG] llvm (main) A bug in an unreleased version of LLVM (this label is appropriate for regressions) [FIXED][LLVM] main This bug was only present and fixed in an unreleased version of LLVM [Regression] llvm This was previously working, but the toolchain has regressed. Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.

Comments

@samitolvanen
Copy link
Member

ToT Clang fails to build RISC-V defconfig after commit f281543a48905e58359c6b0f1b9c3b42bd67e315 ("[RISCV] Teach RISCVMergeBaseOffset to handle inline asm") with plenty of these errors:

In file included from ../ipc/namespace.c:7:
In file included from ../include/linux/ipc.h:5:
In file included from ../include/linux/spinlock.h:63:
In file included from ../include/linux/lockdep.h:14:
In file included from ../include/linux/smp.h:15:
In file included from ../include/linux/smp_types.h:5:
../include/linux/llist.h:239:9: error: expected '(' or optional integer offset
  239 |         return xchg(&head->first, NULL);
      |                ^
../include/linux/atomic/atomic-instrumented.h:4716:2: note: expanded from macro 'xchg'
 4716 |         raw_xchg(__ai_ptr, __VA_ARGS__); \
      |         ^
../include/linux/atomic/atomic-arch-fallback.h:12:18: note: expanded from macro 'raw_xchg'
   12 | #define raw_xchg arch_xchg
      |                  ^
../arch/riscv/include/asm/cmpxchg.h:146:23: note: expanded from macro 'arch_xchg'
  146 |         (__typeof__(*(ptr))) __arch_xchg((ptr), _x_, sizeof(*(ptr)));   \
      |                              ^
../arch/riscv/include/asm/cmpxchg.h:132:4: note: expanded from macro '__arch_xchg'
  132 |                         "       amoswap.d.aqrl %0, %2, %1\n"            \
      |                         ^
<inline asm>:1:26: note: instantiated into assembly here
    1 |                 amoswap.d.aqrl a0, a0, %pcrel_lo(.Lpcrel_hi18)(a1)
      |                                        ^
@samitolvanen samitolvanen added [ARCH] risc-v This bug impacts ARCH=riscv [BUG] llvm (main) A bug in an unreleased version of LLVM (this label is appropriate for regressions) labels Aug 31, 2023
@nickdesaulniers nickdesaulniers added the Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list. label Aug 31, 2023
@nickdesaulniers
Copy link
Member

Thanks for the report, reported upstream.

@nickdesaulniers
Copy link
Member

I think this is the preprocessed output from the case above.

static inline __attribute__((__gnu_inline__)) __attribute__((__unused__))
__attribute__((__no_instrument_function__))
__attribute__((__always_inline__)) int
raw_atomic_xchg(atomic_t *v, int new) {

  return ({
    __typeof__(*(&v->counter)) _x_ = (new);
    (__typeof__(*(&v->counter)))({
      __typeof__((&v->counter)) __ptr = ((&v->counter));
      __typeof__(_x_) __new = (_x_);
      __typeof__(*((&v->counter))) __ret;
      switch (sizeof(*(&v->counter))) {
      case 4:
        __asm__ __volatile__("	amoswap.w.aqrl %0, %2, %1\n"
                             : "=r"(__ret), "+A"(*__ptr)
                             : "r"(__new)
                             : "memory");
        break;
      case 8:
        __asm__ __volatile__("	amoswap.d.aqrl %0, %2, %1\n"
                             : "=r"(__ret), "+A"(*__ptr)
                             : "r"(__new)
                             : "memory");
        break;
      default:
        do {
          __attribute__((__noreturn__)) extern void __compiletime_assert_35(
              void) __attribute__((__error__("BUILD_BUG failed")));
          if (!(!(1)))
            __compiletime_assert_35();
        } while (0);
      }
      __ret;
    });
  });
}

running cvise now. @topperc gave the green light to revert. I'll do that now.

@nickdesaulniers nickdesaulniers added the [Regression] llvm This was previously working, but the toolchain has regressed. label Aug 31, 2023
@nickdesaulniers
Copy link
Member

cvise reported:

typedef struct {
  int counter
} atomic_t;
int arch_atomic_fetch_sub_i, atomic_dec_return_ret;
void genl_sk_destructing_cnt() {
  atomic_t *__trans_tmp_8 = genl_sk_destructing_cnt;
  __asm__("	amo"
          "add"
          "."
          "w"
          ".aqrl  %1, %2, %0"
          : "+A"(__trans_tmp_8->counter), "=r"(atomic_dec_return_ret)
          : "r"(arch_atomic_fetch_sub_i));
}

nickdesaulniers added a commit to llvm/llvm-project that referenced this issue Aug 31, 2023
This reverts commit f281543.

Sami Tolvanen reports that this breaks the Linux kernel's arch=RISCV
defconfig.

Link: ClangBuiltLinux/linux#1928
@nickdesaulniers
Copy link
Member

reverted: llvm/llvm-project@fc5306d

@nickdesaulniers nickdesaulniers added the [FIXED][LLVM] main This bug was only present and fixed in an unreleased version of LLVM label Aug 31, 2023
smeenai pushed a commit to smeenai/llvm-project that referenced this issue Sep 1, 2023
This reverts commit f281543.

Sami Tolvanen reports that this breaks the Linux kernel's arch=RISCV
defconfig.

Link: ClangBuiltLinux/linux#1928

commit-id:96287f6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] risc-v This bug impacts ARCH=riscv [BUG] llvm (main) A bug in an unreleased version of LLVM (this label is appropriate for regressions) [FIXED][LLVM] main This bug was only present and fixed in an unreleased version of LLVM [Regression] llvm This was previously working, but the toolchain has regressed. Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.
Projects
None yet
Development

No branches or pull requests

2 participants