From: Eric Christopher Date: Fri, 6 Feb 2015 18:44:18 +0000 (+0000) Subject: Inline asm IR input register constraints don't have early clobber X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=987bc043c7325fda4d426b55205939a0389add58;p=clang Inline asm IR input register constraints don't have early clobber modifiers on them. If we have a matching output constraint with an early clobber make sure we don't propagate that to the input constraint. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228422 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 8e1c7f2d19..d921c0d9b9 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -1957,10 +1957,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { InputConstraint = SimplifyConstraint(InputConstraint.c_str(), getTarget(), &OutputConstraintInfos); - InputConstraint = - AddVariableConstraints(InputConstraint, - *InputExpr->IgnoreParenNoopCasts(getContext()), - getTarget(), CGM, S, Info.earlyClobber()); + InputConstraint = AddVariableConstraints( + InputConstraint, *InputExpr->IgnoreParenNoopCasts(getContext()), + getTarget(), CGM, S, false /* No EarlyClobber */); llvm::Value *Arg = EmitAsmInput(Info, InputExpr, Constraints); diff --git a/test/CodeGen/inline-asm-matching-constraint.c b/test/CodeGen/inline-asm-matching-constraint.c new file mode 100644 index 0000000000..7d073b17b7 --- /dev/null +++ b/test/CodeGen/inline-asm-matching-constraint.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -triple powerpc64le-linux-gnu | FileCheck %s +// Sadly since this requires a register constraint to trigger we have to set +// a target here. +void a(void) { + register unsigned long __sc_0 __asm__("r0"); + __asm__ __volatile__("mfcr %0" : "=&r"(__sc_0) : "0"(__sc_0)); +} + +// Check that we can generate code for this correctly. The matching input +// constraint should not have an early clobber on it. +// CHECK: call i64 asm sideeffect "mfcr $0", "=&{r0},{r0}"(i64 %0)