From: Chad Rosier Date: Tue, 23 Oct 2012 17:44:40 +0000 (+0000) Subject: [ms-inline asm] Update for r166433. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d5dd7c954842bc5043e45734af17db197654ca0;p=clang [ms-inline asm] Update for r166433. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166489 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index f33b87cebc..3a5f40c74f 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -513,7 +513,7 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, unsigned NumOutputs; unsigned NumInputs; std::string AsmStringIR; - SmallVector OpDecls; + SmallVector, 4> OpDecls; SmallVector Constraints; SmallVector Clobbers; if (Parser->ParseMSInlineAsm(AsmLoc.getPtrEncoding(), AsmStringIR, @@ -533,7 +533,7 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ConstraintRefs.resize(NumExprs); Exprs.resize(NumExprs); for (unsigned i = 0, e = NumExprs; i != e; ++i) { - NamedDecl *OpDecl = static_cast(OpDecls[i]); + NamedDecl *OpDecl = static_cast(OpDecls[i].first); if (!OpDecl) return StmtError(); @@ -542,7 +542,12 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, OpDecl); if (OpExpr.isInvalid()) return StmtError(); - + + // Need offset of variable. + if (OpDecls[i].second) + OpExpr = BuildUnaryOp(getCurScope(), AsmLoc, clang::UO_AddrOf, + OpExpr.take()); + Names[i] = OpDecl->getIdentifier(); ConstraintRefs[i] = StringRef(Constraints[i]); Exprs[i] = OpExpr.take(); diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c index 90d05a4e70..83cabcc6f4 100644 --- a/test/CodeGen/ms-inline-asm.c +++ b/test/CodeGen/ms-inline-asm.c @@ -144,4 +144,5 @@ void t15() { __asm mov eax, offset var ; eax = address of myvar // CHECK: t15 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) nounwind +// CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) nounwind }