From: Eric Christopher Date: Tue, 21 Jun 2011 00:07:10 +0000 (+0000) Subject: Canonicalize register names properly. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=43fec879a527c74ff01d8aa2bf94a12432249fc7;p=clang Canonicalize register names properly. Fixes rdar://9425559 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133486 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 86b9e2b997..e054191158 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -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() + "}"; } diff --git a/test/CodeGen/arm-asm-variable.c b/test/CodeGen/arm-asm-variable.c index 20648e4cc3..8088051e24 100644 --- a/test/CodeGen/arm-asm-variable.c +++ b/test/CodeGen/arm-asm-variable.c @@ -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)); +}