When setting a tied check if it's already tied. If it's tied to another constraint it's invalid. Fixes PR3905.
llvm-svn: 118146
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 947cbfc..1437a4b 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -354,6 +354,11 @@
if (OutputConstraints[i].isReadWrite())
return false;
+ // If the constraint is already tied, it must be tied to the
+ // same operand referenced to by the number.
+ if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
+ return false;
+
// The constraint should have the same info as the respective
// output constraint.
Info.setTiedOperand(i, OutputConstraints[i]);
@@ -369,6 +374,11 @@
if (!resolveSymbolicName(Name, OutputConstraints, NumOutputs, Index))
return false;
+ // If the constraint is already tied, it must be tied to the
+ // same operand referenced to by the number.
+ if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
+ return false;
+
Info.setTiedOperand(Index, OutputConstraints[Index]);
break;
}