summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmtAsm.cpp
diff options
context:
space:
mode:
authorArtem Belevich <tra@google.com>2015-03-19 18:40:25 +0000
committerArtem Belevich <tra@google.com>2015-03-19 18:40:25 +0000
commit5196fe7c197a56548a4df99287e08ad3903927ff (patch)
tree1e2ef740141e1da69213477514d71f8e70cb0e34 /clang/lib/Sema/SemaStmtAsm.cpp
parent152b936683ff65874e9716df0851bce233fa20bd (diff)
downloadbcm5719-llvm-5196fe7c197a56548a4df99287e08ad3903927ff.tar.gz
bcm5719-llvm-5196fe7c197a56548a4df99287e08ad3903927ff.zip
Ignore device-side asm constraint errors while compiling CUDA code for host and vice versa.
Differential Revision: http://reviews.llvm.org/D8392 llvm-svn: 232747
Diffstat (limited to 'clang/lib/Sema/SemaStmtAsm.cpp')
-rw-r--r--clang/lib/Sema/SemaStmtAsm.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index c091cf88a92..179e207e76a 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -124,6 +124,17 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
// The parser verifies that there is a string literal here.
assert(AsmString->isAscii());
+ bool ValidateConstraints = true;
+ if (getLangOpts().CUDA) {
+ // In CUDA mode don't verify asm constraints in device functions during host
+ // compilation and vice versa.
+ bool InDeviceMode = getLangOpts().CUDAIsDevice;
+ FunctionDecl *FD = getCurFunctionDecl();
+ bool IsDeviceFunction =
+ FD && (FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>());
+ ValidateConstraints = IsDeviceFunction == InDeviceMode;
+ }
+
for (unsigned i = 0; i != NumOutputs; i++) {
StringLiteral *Literal = Constraints[i];
assert(Literal->isAscii());
@@ -133,7 +144,8 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
OutputName = Names[i]->getName();
TargetInfo::ConstraintInfo Info(Literal->getString(), OutputName);
- if (!Context.getTargetInfo().validateOutputConstraint(Info))
+ if (ValidateConstraints &&
+ !Context.getTargetInfo().validateOutputConstraint(Info))
return StmtError(Diag(Literal->getLocStart(),
diag::err_asm_invalid_output_constraint)
<< Info.getConstraintStr());
@@ -207,8 +219,9 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
InputName = Names[i]->getName();
TargetInfo::ConstraintInfo Info(Literal->getString(), InputName);
- if (!Context.getTargetInfo().validateInputConstraint(OutputConstraintInfos.data(),
- NumOutputs, Info)) {
+ if (ValidateConstraints &&
+ !Context.getTargetInfo().validateInputConstraint(
+ OutputConstraintInfos.data(), NumOutputs, Info)) {
return StmtError(Diag(Literal->getLocStart(),
diag::err_asm_invalid_input_constraint)
<< Info.getConstraintStr());
OpenPOWER on IntegriCloud