r212954 - CodeGen: Let arrays be inputs to inline asm
David Majnemer
david.majnemer at gmail.com
Mon Jul 14 09:27:53 PDT 2014
Author: majnemer
Date: Mon Jul 14 11:27:53 2014
New Revision: 212954
URL: http://llvm.org/viewvc/llvm-project?rev=212954&view=rev
Log:
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
Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/test/CodeGen/asm.c
cfe/trunk/test/CodeGen/x86-64-inline-asm.c
Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=212954&r1=212953&r2=212954&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Mon Jul 14 11:27:53 2014
@@ -152,6 +152,12 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
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(SourceL
}
}
- 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();
Modified: cfe/trunk/test/CodeGen/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm.c?rev=212954&r1=212953&r2=212954&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/asm.c (original)
+++ cfe/trunk/test/CodeGen/asm.c Mon Jul 14 11:27:53 2014
@@ -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)
+}
Modified: cfe/trunk/test/CodeGen/x86-64-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-64-inline-asm.c?rev=212954&r1=212953&r2=212954&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/x86-64-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/x86-64-inline-asm.c Mon Jul 14 11:27:53 2014
@@ -10,3 +10,8 @@ void f() {
// expected-error at -5 {{scale factor without index register is ignored}}
#endif
}
+
+static unsigned var[1] = {};
+void g(void) { asm volatile("movd %%xmm0, %0"
+ :
+ : "m"(var)); }
More information about the cfe-commits
mailing list