[cfe-commits] r152873 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp test/CodeGen/asm-variable.c

Eli Friedman eli.friedman at gmail.com
Thu Mar 15 16:12:52 PDT 2012


Author: efriedma
Date: Thu Mar 15 18:12:51 2012
New Revision: 152873

URL: http://llvm.org/viewvc/llvm-project?rev=152873&view=rev
Log:
When a variable has a specified asm name, but isn't using the register storage class, the asm name doesn't specify a register. PR12244.


Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/test/CodeGen/asm-variable.c

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=152873&r1=152872&r2=152873&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Mar 15 18:12:51 2012
@@ -1295,6 +1295,8 @@
   const VarDecl *Variable = dyn_cast<VarDecl>(&Value);
   if (!Variable)
     return Constraint;
+  if (Variable->getStorageClass() != SC_Register)
+    return Constraint;
   AsmLabelAttr *Attr = Variable->getAttr<AsmLabelAttr>();
   if (!Attr)
     return Constraint;

Modified: cfe/trunk/test/CodeGen/asm-variable.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm-variable.c?rev=152873&r1=152872&r2=152873&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/asm-variable.c (original)
+++ cfe/trunk/test/CodeGen/asm-variable.c Thu Mar 15 18:12:51 2012
@@ -57,3 +57,9 @@
 }
 
 // CHECK: call i64 asm "call *$1", "={rax},r,{xmm0},{xmm1},{xmm2},{xmm3},{xmm4},{xmm5},{xmm6},{xmm7},~{dirflag},~{fpsr},~{flags}
+
+int randomvar asm("randomvar");
+void foo3() {
+  asm("vartest %0" : : "r"(randomvar));
+}
+// CHECK: call void asm sideeffect "vartest $0", "r,~{dirflag},~{fpsr},~{flags}"





More information about the cfe-commits mailing list