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.

llvm-svn: 152873
This commit is contained in:
Eli Friedman 2012-03-15 23:12:51 +00:00
parent dbe27e70a5
commit 6f87b44fe3
2 changed files with 8 additions and 0 deletions

View File

@ -1295,6 +1295,8 @@ AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr,
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;

View File

@ -57,3 +57,9 @@ unsigned long long foo2(unsigned long long addr, double a0,
}
// 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}"