|
@@ -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());
|