2012-08-17 07:50:41 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple armv7-apple-darwin -verify -fsyntax-only
|
|
|
|
|
|
|
|
void f (void) {
|
|
|
|
int Val;
|
|
|
|
asm volatile ("lw (r1), %0[val]": "=&b"(Val)); // expected-error {{invalid output constraint '=&b' in asm}}
|
|
|
|
return;
|
|
|
|
}
|
2013-12-08 23:24:55 +08:00
|
|
|
|
|
|
|
void test_64bit_r(void) {
|
|
|
|
long long foo = 0, bar = 0;
|
|
|
|
asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar));
|
|
|
|
}
|
[Targets] Implement getConstraintRegister for ARM and AArch64
Summary:
The getConstraintRegister method is used by semantic checking of
inline assembly statements in order to diagnose conflicts between
clobber list and input/output lists. Currently ARM and AArch64 don't
override getConstraintRegister, so conflicts between registers
assigned to variables in asm labels and clobber lists are not
diagnosed. Such conflicts can cause assertion failures in the back end
and even miscompilations.
This patch implements getConstraintRegister for ARM and AArch64
targets. Since these targets don't have single-register constraints,
the implementation is trivial and just returns the register specified
in an asm label (if any).
Reviewers: eli.friedman, javed.absar, thopre
Reviewed By: thopre
Subscribers: rengolin, eraman, rogfer01, myatsina, kristof.beyls, cfe-commits, chrib
Differential Revision: https://reviews.llvm.org/D45965
llvm-svn: 331164
2018-04-30 17:11:08 +08:00
|
|
|
|
|
|
|
void test_clobber_conflict(void) {
|
|
|
|
register int x asm("r1");
|
|
|
|
asm volatile("nop" :: "r"(x) : "%r1"); // expected-error {{conflicts with asm clobber list}}
|
|
|
|
asm volatile("nop" :: "l"(x) : "%r1"); // expected-error {{conflicts with asm clobber list}}
|
|
|
|
asm volatile("nop" : "=r"(x) :: "%r1"); // expected-error {{conflicts with asm clobber list}}
|
|
|
|
}
|