From: David Majnemer Date: Mon, 14 Jul 2014 16:27:53 +0000 (+0000) Subject: CodeGen: Let arrays be inputs to inline asm X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f685eac9e678f29e3d905c740a61aa1e84e2af04;p=clang CodeGen: Let arrays be inputs to inline asm An array showing up in an inline assembly input is accepted in ICC and GCC 4.8 This fixes PR20201. Differential Revision: http://reviews.llvm.org/D4382 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212954 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index fdab947a47..5d076cac94 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -152,6 +152,12 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, diag::err_asm_invalid_lvalue_in_input) << Info.getConstraintStr() << InputExpr->getSourceRange()); + } else { + ExprResult Result = DefaultFunctionArrayLvalueConversion(Exprs[i]); + if (Result.isInvalid()) + return StmtError(); + + Exprs[i] = Result.get(); } if (Info.allowsRegister()) { @@ -163,11 +169,6 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, } } - ExprResult Result = DefaultFunctionArrayLvalueConversion(Exprs[i]); - if (Result.isInvalid()) - return StmtError(); - - Exprs[i] = Result.get(); InputConstraintInfos.push_back(Info); const Type *Ty = Exprs[i]->getType().getTypePtr(); diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c index 670c24405d..5dbc01b121 100644 --- a/test/CodeGen/asm.c +++ b/test/CodeGen/asm.c @@ -239,3 +239,12 @@ void t28(void) // CHECK: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1) } +static unsigned t29_var[1]; + +void t29(void) { + asm volatile("movl %%eax, %0" + : + : "m"(t29_var)); + // CHECK: @t29 + // CHECK: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"([1 x i32]* @t29_var) +} diff --git a/test/CodeGen/x86-64-inline-asm.c b/test/CodeGen/x86-64-inline-asm.c index fefbf76dd9..bb46eda633 100644 --- a/test/CodeGen/x86-64-inline-asm.c +++ b/test/CodeGen/x86-64-inline-asm.c @@ -10,3 +10,8 @@ void f() { // expected-error@-5 {{scale factor without index register is ignored}} #endif } + +static unsigned var[1] = {}; +void g(void) { asm volatile("movd %%xmm0, %0" + : + : "m"(var)); }