[cfe-commits] r63127 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/CodeGen/CGStmt.cpp lib/Sema/SemaStmt.cpp test/CodeGen/asm.c test/Sema/asm.c
Anders Carlsson
andersca at mac.com
Tue Jan 27 12:38:24 PST 2009
Author: andersca
Date: Tue Jan 27 14:38:24 2009
New Revision: 63127
URL: http://llvm.org/viewvc/llvm-project?rev=63127&view=rev
Log:
If an input constraint refers to an output constraint, it should have the same constraint info as the output constraint. Fixes PR3417
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/CodeGen/asm.c
cfe/trunk/test/Sema/asm.c
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=63127&r1=63126&r2=63127&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Jan 27 14:38:24 2009
@@ -201,6 +201,7 @@
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,
Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=63127&r1=63126&r2=63127&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Tue Jan 27 14:38:24 2009
@@ -222,6 +222,7 @@
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 @@
// 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
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=63127&r1=63126&r2=63127&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Jan 27 14:38:24 2009
@@ -932,7 +932,9 @@
std::string InOutConstraints;
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 @@
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 @@
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");
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=63127&r1=63126&r2=63127&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Jan 27 14:38:24 2009
@@ -849,6 +849,8 @@
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 @@
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 @@
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);
}
Modified: cfe/trunk/test/CodeGen/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm.c?rev=63127&r1=63126&r2=63127&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/asm.c (original)
+++ cfe/trunk/test/CodeGen/asm.c Tue Jan 27 14:38:24 2009
@@ -22,7 +22,8 @@
__asm__ volatile ("":: "m"(a), "m"(b));
}
-
-
-
-
+// PR3417
+void t5(int i)
+{
+ asm("nop" : "=r"(i) : "0"(t5));
+}
Modified: cfe/trunk/test/Sema/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm.c?rev=63127&r1=63126&r2=63127&view=diff
==============================================================================
--- cfe/trunk/test/Sema/asm.c (original)
+++ cfe/trunk/test/Sema/asm.c Tue Jan 27 14:38:24 2009
@@ -59,4 +59,4 @@
void test6(long i)
{
asm("nop" : : "er"(i));
-}
\ No newline at end of file
+}
More information about the cfe-commits
mailing list