From 8a157bf8f2117371bd9317b3eaf38956afe88781 Mon Sep 17 00:00:00 2001 From: James Molloy Date: Fri, 25 Jul 2014 10:19:47 +0000 Subject: [PATCH] Revert part of r206963 Specifically the part where we removed a warning to be compatible with GCC, which has been widely regarded as a bad idea. I'm not quite happy with how obtuse this warning is, especially in the fairly common case of a 32-bit integer literal, so I've got another patch awaiting review that adds a fixit to reduce confusion. llvm-svn: 213935 --- clang/lib/Basic/Targets.cpp | 27 +++++++++++++++++++++++++++ clang/test/Sema/arm64-inline-asm.c | 2 +- clang/test/Sema/inline-asm-validate.c | 3 +-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index b0ca5a5..e78244d 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -4503,6 +4503,33 @@ public: return false; } + virtual bool validateConstraintModifier(StringRef Constraint, + const char Modifier, + unsigned Size) const { + // Strip off constraint modifiers. + while (Constraint[0] == '=' || Constraint[0] == '+' || Constraint[0] == '&') + Constraint = Constraint.substr(1); + + switch (Constraint[0]) { + default: + return true; + case 'z': + case 'r': { + switch (Modifier) { + case 'x': + case 'w': + // For now assume that the person knows what they're + // doing with the modifier. + return true; + default: + // By default an 'r' constraint will be in the 'x' + // registers. + return Size == 64; + } + } + } + } + virtual const char *getClobbers() const { return ""; } int getEHDataRegisterNumber(unsigned RegNo) const { diff --git a/clang/test/Sema/arm64-inline-asm.c b/clang/test/Sema/arm64-inline-asm.c index 08eb669..2cfbe46 100644 --- a/clang/test/Sema/arm64-inline-asm.c +++ b/clang/test/Sema/arm64-inline-asm.c @@ -1,9 +1,9 @@ // RUN: %clang_cc1 -triple arm64-apple-ios7.1 -fsyntax-only -verify %s -// expected-no-diagnostics 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}} } diff --git a/clang/test/Sema/inline-asm-validate.c b/clang/test/Sema/inline-asm-validate.c index c32dedb..6fa760c 100644 --- a/clang/test/Sema/inline-asm-validate.c +++ b/clang/test/Sema/inline-asm-validate.c @@ -1,9 +1,8 @@ // RUN: %clang_cc1 -triple arm64-apple-macosx10.8.0 -fsyntax-only -verify %s -// expected-no-diagnostics unsigned t, r, *p; int foo (void) { - __asm__ __volatile__( "stxr %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory"); + __asm__ __volatile__( "stxr %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory"); // expected-warning{{value size does not match register size specified by the constraint and modifier}} return 1; } -- 2.7.4