Skip to content

Commit b4a791f

Browse files
committed
Canonicalize register names properly.
Fixes rdar://9425559 llvm-svn: 133486
1 parent cdd3635 commit b4a791f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,8 @@ AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr,
12861286
CGM.ErrorUnsupported(&Stmt, "__asm__");
12871287
return Constraint;
12881288
}
1289+
// Canonicalize the register here before returning it.
1290+
Register = Target.getNormalizedGCCRegisterName(Register);
12891291
return "{" + Register.str() + "}";
12901292
}
12911293

clang/test/CodeGen/arm-asm-variable.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ int64_t foo(int64_t v, volatile int64_t *p)
2020

2121
return r;
2222
}
23+
24+
// Make sure we translate register names properly.
25+
void bar (void) {
26+
register unsigned int rn asm("r14");
27+
register unsigned int d asm("r2");
28+
29+
// CHECK: call i32 asm sideeffect "sub $1, $1, #32", "={r2},{lr}"
30+
asm volatile ("sub %1, %1, #32" : "=r"(d) : "r"(rn));
31+
}

0 commit comments

Comments
 (0)