forked from OSchip/llvm-project
If an input constraint refers to an output constraint, it should have the same constraint info as the output constraint. Fixes PR3417
llvm-svn: 63127
This commit is contained in:
parent
7415caa3d4
commit
570c357ded
|
@ -201,6 +201,7 @@ public:
|
|||
bool validateInputConstraint(const char *Name,
|
||||
const std::string *OutputNamesBegin,
|
||||
const std::string *OutputNamesEnd,
|
||||
ConstraintInfo* OutputConstraints,
|
||||
ConstraintInfo &info) const;
|
||||
bool resolveSymbolicName(const char *&Name,
|
||||
const std::string *OutputNamesBegin,
|
||||
|
|
|
@ -222,6 +222,7 @@ bool TargetInfo::resolveSymbolicName(const char *&Name,
|
|||
bool TargetInfo::validateInputConstraint(const char *Name,
|
||||
const std::string *OutputNamesBegin,
|
||||
const std::string *OutputNamesEnd,
|
||||
ConstraintInfo* OutputConstraints,
|
||||
ConstraintInfo &info) const {
|
||||
info = CI_None;
|
||||
|
||||
|
@ -236,6 +237,10 @@ bool TargetInfo::validateInputConstraint(const char *Name,
|
|||
// Check if matching constraint is out of bounds.
|
||||
if (i >= NumOutputs)
|
||||
return false;
|
||||
|
||||
// The constraint should have the same info as the respective
|
||||
// output constraint.
|
||||
info = (ConstraintInfo)(info|OutputConstraints[i]);
|
||||
} else if (!validateAsmConstraint(*Name, info)) {
|
||||
// FIXME: This error return is in place temporarily so we can
|
||||
// add more constraints as we hit it. Eventually, an unknown
|
||||
|
|
|
@ -933,6 +933,8 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
|
|||
std::vector<llvm::Value*> InOutArgs;
|
||||
std::vector<const llvm::Type*> InOutArgTypes;
|
||||
|
||||
llvm::SmallVector<TargetInfo::ConstraintInfo, 4> OutputConstraintInfos;
|
||||
|
||||
for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {
|
||||
std::string OutputConstraint(S.getOutputConstraint(i)->getStrData(),
|
||||
S.getOutputConstraint(i)->getByteLength());
|
||||
|
@ -942,6 +944,8 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
|
|||
Info);
|
||||
assert(result && "Failed to parse output constraint"); result=result;
|
||||
|
||||
OutputConstraintInfos.push_back(Info);
|
||||
|
||||
// Simplify the output constraint.
|
||||
OutputConstraint = SimplifyConstraint(OutputConstraint.c_str() + 1, Target);
|
||||
|
||||
|
@ -993,6 +997,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
|
|||
bool result = Target.validateInputConstraint(InputConstraint.c_str(),
|
||||
S.begin_output_names(),
|
||||
S.end_output_names(),
|
||||
&OutputConstraintInfos[0],
|
||||
Info); result=result;
|
||||
assert(result && "Failed to parse input constraint");
|
||||
|
||||
|
|
|
@ -849,6 +849,8 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
|
|||
StringLiteral *AsmString = cast<StringLiteral>((Expr *)asmString.get());
|
||||
StringLiteral **Clobbers = reinterpret_cast<StringLiteral**>(clobbers.get());
|
||||
|
||||
llvm::SmallVector<TargetInfo::ConstraintInfo, 4> OutputConstraintInfos;
|
||||
|
||||
// The parser verifies that there is a string literal here.
|
||||
if (AsmString->isWide())
|
||||
return StmtError(Diag(AsmString->getLocStart(),diag::err_asm_wide_character)
|
||||
|
@ -877,6 +879,8 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
|
|||
diag::err_asm_invalid_lvalue_in_output)
|
||||
<< OutputExpr->getSubExpr()->getSourceRange());
|
||||
}
|
||||
|
||||
OutputConstraintInfos.push_back(info);
|
||||
}
|
||||
|
||||
for (unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; i++) {
|
||||
|
@ -891,7 +895,9 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
|
|||
TargetInfo::ConstraintInfo info;
|
||||
if (!Context.Target.validateInputConstraint(InputConstraint.c_str(),
|
||||
&Names[0],
|
||||
&Names[0] + NumOutputs, info)) {
|
||||
&Names[0] + NumOutputs,
|
||||
&OutputConstraintInfos[0],
|
||||
info)) {
|
||||
return StmtError(Diag(Literal->getLocStart(),
|
||||
diag::err_asm_invalid_input_constraint) << InputConstraint);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ void t4()
|
|||
__asm__ volatile ("":: "m"(a), "m"(b));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// PR3417
|
||||
void t5(int i)
|
||||
{
|
||||
asm("nop" : "=r"(i) : "0"(t5));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue