]> granicus.if.org Git - clang/commitdiff
Inline asm IR input register constraints don't have early clobber
authorEric Christopher <echristo@gmail.com>
Fri, 6 Feb 2015 18:44:18 +0000 (18:44 +0000)
committerEric Christopher <echristo@gmail.com>
Fri, 6 Feb 2015 18:44:18 +0000 (18:44 +0000)
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

lib/CodeGen/CGStmt.cpp
test/CodeGen/inline-asm-matching-constraint.c [new file with mode: 0644]

index 8e1c7f2d1971813919d12f7f286bcc8999c5edc6..d921c0d9b973e8433d6352ec3cad40017bd2fa69 100644 (file)
@@ -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 (file)
index 0000000..7d073b1
--- /dev/null
@@ -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)