]> granicus.if.org Git - clang/commitdiff
Canonicalize register names properly.
authorEric Christopher <echristo@apple.com>
Tue, 21 Jun 2011 00:07:10 +0000 (00:07 +0000)
committerEric Christopher <echristo@apple.com>
Tue, 21 Jun 2011 00:07:10 +0000 (00:07 +0000)
Fixes rdar://9425559

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133486 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmt.cpp
test/CodeGen/arm-asm-variable.c

index 86b9e2b997ad2d2120f9277b7f2b9cbba650d4e8..e0541911587b787f55b22b0b50200d39bd04f889 100644 (file)
@@ -1286,6 +1286,8 @@ AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr,
     CGM.ErrorUnsupported(&Stmt, "__asm__");
     return Constraint;
   }
+  // Canonicalize the register here before returning it.
+  Register = Target.getNormalizedGCCRegisterName(Register);
   return "{" + Register.str() + "}";
 }
 
index 20648e4cc37560317d3f6861c0d85fb6af9bfc6a..8088051e241f866207d4944adaaae21d25f3d49a 100644 (file)
@@ -20,3 +20,12 @@ int64_t foo(int64_t v, volatile int64_t *p)
 
   return r;
 }
+
+// Make sure we translate register names properly.
+void bar (void) {
+  register unsigned int rn asm("r14");
+  register unsigned int d asm("r2");
+
+  // CHECK: call i32 asm sideeffect "sub $1, $1, #32", "={r2},{lr}"
+  asm volatile ("sub %1, %1, #32" : "=r"(d) : "r"(rn));
+}