r225605 - Basic: [asmSymbolicName] follows the same rule as numbers in asm inputs

David Majnemer david.majnemer at gmail.com
Sun Jan 11 01:57:19 PST 2015


Author: majnemer
Date: Sun Jan 11 03:57:13 2015
New Revision: 225605

URL: http://llvm.org/viewvc/llvm-project?rev=225605&view=rev
Log:
Basic: [asmSymbolicName] follows the same rule as numbers in asm inputs

Input constraints like "0" and "[foo]" should be treated the same when
it comes to their corresponding output constraint.

This fixes PR21850.

Modified:
    cfe/trunk/lib/Basic/TargetInfo.cpp
    cfe/trunk/test/Sema/asm.c

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=225605&r1=225604&r2=225605&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Sun Jan 11 03:57:13 2015
@@ -583,6 +583,10 @@ bool TargetInfo::validateInputConstraint
       if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
         return false;
 
+      // A number must refer to an output only operand.
+      if (OutputConstraints[Index].isReadWrite())
+        return false;
+
       Info.setTiedOperand(Index, OutputConstraints[Index]);
       break;
     }

Modified: cfe/trunk/test/Sema/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm.c?rev=225605&r1=225604&r2=225605&view=diff
==============================================================================
--- cfe/trunk/test/Sema/asm.c (original)
+++ cfe/trunk/test/Sema/asm.c Sun Jan 11 03:57:13 2015
@@ -190,3 +190,10 @@ void fn4() {
           : "=r"(l)
           : "#m"(l)); // expected-error {{invalid input constraint '#m' in asm}}
 }
+
+void fn5() {
+  int l;
+    __asm__(""
+          : [g] "+r"(l)
+          : "[g]"(l)); // expected-error {{invalid input constraint '[g]' in asm}}
+}





More information about the cfe-commits mailing list