mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 19:45:40 -04:00

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
16 lines
651 B
C
16 lines
651 B
C
// RUN: %clang_cc1 -triple arm64-apple-ios7.1 -fsyntax-only -verify %s
|
|
|
|
void foo() {
|
|
asm volatile("USE(%0)" :: "z"(0LL));
|
|
asm volatile("USE(%x0)" :: "z"(0LL));
|
|
asm volatile("USE(%w0)" :: "z"(0));
|
|
|
|
asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}}
|
|
}
|
|
|
|
void test_clobber_conflict(void) {
|
|
register long x asm("x1");
|
|
asm volatile("nop" :: "r"(x) : "%x1"); // expected-error {{conflicts with asm clobber list}}
|
|
asm volatile("nop" : "=r"(x) :: "%x1"); // expected-error {{conflicts with asm clobber list}}
|
|
}
|