diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h --- a/clang/lib/Basic/Targets/RISCV.h +++ b/clang/lib/Basic/Targets/RISCV.h @@ -82,6 +82,11 @@ const char *getClobbers() const override { return ""; } + StringRef getConstraintRegister(StringRef Constraint, + StringRef Expression) const override { + return Expression; + } + ArrayRef getGCCRegNames() const override; int getEHDataRegisterNumber(unsigned RegNo) const override { diff --git a/clang/test/Sema/inline-asm-validate-riscv.c b/clang/test/Sema/inline-asm-validate-riscv.c --- a/clang/test/Sema/inline-asm-validate-riscv.c +++ b/clang/test/Sema/inline-asm-validate-riscv.c @@ -21,3 +21,11 @@ asm volatile ("" :: "K"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'K'}} asm volatile ("" :: "K"(AboveMax)); // expected-error{{value '32' out of range for constraint 'K'}} } + +void test_clobber_conflict(void) { + register long x10 asm("x10"); + asm volatile("" :: "r"(x10) : "x10"); // expected-error {{conflicts with asm clobber list}} + asm volatile("" :: "r"(x10) : "a0"); // expected-error {{conflicts with asm clobber list}} + asm volatile("" : "=r"(x10) :: "x10"); // expected-error {{conflicts with asm clobber list}} + asm volatile("" : "=r"(x10) :: "a0"); // expected-error {{conflicts with asm clobber list}} +}