]> granicus.if.org Git - clang/commitdiff
Ensure that set constrained asm operands are not affected by truncation.
authorJoerg Sonnenberger <joerg@bec.de>
Thu, 28 Feb 2019 00:55:09 +0000 (00:55 +0000)
committerJoerg Sonnenberger <joerg@bec.de>
Thu, 28 Feb 2019 00:55:09 +0000 (00:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355058 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/TargetInfo.h
test/Sema/inline-asm-validate-x86.c

index d41f4c6462cfe54c7a439b46ce9cf7229466bb5c..7b9f9d9565d06629b0a683c84522045c428ad14a 100644 (file)
@@ -857,8 +857,10 @@ public:
     }
     bool isValidAsmImmediate(const llvm::APInt &Value) const {
       if (!ImmSet.empty())
-        return ImmSet.count(Value.getZExtValue()) != 0;
-      return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
+        return Value.isSignedIntN(32) &&
+               ImmSet.count(Value.getZExtValue()) != 0;
+      return !ImmRange.isConstrained ||
+             (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
     }
 
     void setIsReadWrite() { Flags |= CI_ReadWrite; }
index b238ab8a5038fff3cefc692beecaf948c4ebb1a7..026216c92a455294a1fd52d7661461128fdb0f10 100644 (file)
@@ -56,6 +56,7 @@ void L(int i, int j) {
   static const int Invalid1 = 1;
   static const int Invalid2 = 42;
   static const int Invalid3 = 0;
+  static const long long Invalid4 = 0x1000000ff;
   static const int Valid1 = 0xff;
   static const int Valid2 = 0xffff;
   static const int Valid3 = 0xffffffff;
@@ -71,6 +72,9 @@ void L(int i, int j) {
   __asm__("xorl %0,%2"
           : "=r"(i)
           : "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range for constraint 'L'}}
+  __asm__("xorl %0,%2"
+          : "=r"(i)
+          : "0"(i), "L"(Invalid4)); // expected-error{{value '4294967551' out of range for constraint 'L'}}
   __asm__("xorl %0,%2"
           : "=r"(i)
           : "0"(i), "L"(Valid1)); // expected-no-error