-
Notifications
You must be signed in to change notification settings - Fork 768
[SYCL] Diagnose __float128 type usage in device code, fixes and cleanups #971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f5aaf39
1a174fa
22eb318
ed3e013
9af59b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,10 +359,7 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> { | |
// new operator and any user-defined overloads that | ||
// do not allocate storage are permitted. | ||
if (FunctionDecl *FD = E->getOperatorNew()) { | ||
if (FD->isReplaceableGlobalAllocationFunction()) { | ||
SemaRef.Diag(E->getExprLoc(), diag::err_sycl_restrict) | ||
<< Sema::KernelAllocateStorage; | ||
} else if (FunctionDecl *Def = FD->getDefinition()) { | ||
if (FunctionDecl *Def = FD->getDefinition()) { | ||
if (!Def->hasAttr<SYCLDeviceAttr>()) { | ||
Def->addAttr(SYCLDeviceAttr::CreateImplicit(SemaRef.Context)); | ||
SemaRef.addSyclDeviceDecl(Def); | ||
|
@@ -521,8 +518,7 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> { | |
if (!CheckSYCLType(Field->getType(), Field->getSourceRange(), | ||
Visited)) { | ||
if (SemaRef.getLangOpts().SYCLIsDevice) | ||
SemaRef.SYCLDiagIfDeviceCode(Loc.getBegin(), | ||
diag::note_sycl_used_here); | ||
SemaRef.Diag(Loc.getBegin(), diag::note_sycl_used_here); | ||
return false; | ||
} | ||
} | ||
|
@@ -531,8 +527,7 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> { | |
if (!CheckSYCLType(Field->getType(), Field->getSourceRange(), | ||
Visited)) { | ||
if (SemaRef.getLangOpts().SYCLIsDevice) | ||
SemaRef.SYCLDiagIfDeviceCode(Loc.getBegin(), | ||
diag::note_sycl_used_here); | ||
SemaRef.Diag(Loc.getBegin(), diag::note_sycl_used_here); | ||
return false; | ||
} | ||
} | ||
|
@@ -1390,8 +1385,7 @@ void Sema::MarkDevice(void) { | |
|
||
// Do we know that we will eventually codegen the given function? | ||
static bool isKnownEmitted(Sema &S, FunctionDecl *FD) { | ||
if (!FD) | ||
return true; // Seen in LIT testing | ||
assert(FD && "Given function may not be null."); | ||
|
||
if (FD->hasAttr<SYCLDeviceAttr>() || FD->hasAttr<SYCLKernelAttr>()) | ||
return true; | ||
|
@@ -1407,16 +1401,16 @@ Sema::DeviceDiagBuilder Sema::SYCLDiagIfDeviceCode(SourceLocation Loc, | |
"Should only be called during SYCL compilation"); | ||
FunctionDecl *FD = dyn_cast<FunctionDecl>(getCurLexicalContext()); | ||
DeviceDiagBuilder::Kind DiagKind = [this, FD] { | ||
if (ConstructingOpenCLKernel) | ||
if (ConstructingOpenCLKernel || !FD) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FD can be NULL in the cases where getCurLexicalContext is TU/namespace/record/etc. Don't we want to diagnose always in these cases, since they are likely static initializers? Something like: static auto Global = throw 3; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't want to diagnose things like static initializers always (if they are not completely invalid for both host and device, but this case is diagnosed out of the box, I suppose). In addition, if we will diagnose such cases always, it will prevent from writing regular c++ code for host... I think we want to diagnose case with in-class initializers, and in this case getCurLexicalContext is record, but we also want to diagnose it with deferred diagnostic because diagnostic is only needed if corresponding type is used in device code, but it requires changes in common parts of deferred diagnostics system, I'm looking into it #1032 ... |
||
return DeviceDiagBuilder::K_Nop; | ||
else if (isKnownEmitted(*this, FD)) | ||
if (isKnownEmitted(*this, FD)) | ||
return DeviceDiagBuilder::K_ImmediateWithCallStack; | ||
return DeviceDiagBuilder::K_Deferred; | ||
}(); | ||
return DeviceDiagBuilder(DiagKind, Loc, DiagID, FD, *this); | ||
} | ||
|
||
bool Sema::CheckSYCLCall(SourceLocation Loc, FunctionDecl *Callee) { | ||
void Sema::checkSYCLDeviceFunction(SourceLocation Loc, FunctionDecl *Callee) { | ||
assert(Callee && "Callee may not be null."); | ||
FunctionDecl *Caller = dyn_cast<FunctionDecl>(getCurLexicalContext()); | ||
|
||
|
@@ -1426,7 +1420,6 @@ bool Sema::CheckSYCLCall(SourceLocation Loc, FunctionDecl *Callee) { | |
markKnownEmitted(*this, Caller, Callee, Loc, isKnownEmitted); | ||
else if (Caller) | ||
DeviceCallGraph[Caller].insert({Callee, Loc}); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,12 +259,11 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, | |
// Skip all the checks if we are compiling SYCL device code, but the function | ||
// is not marked to be used on device, this code won't be codegen'ed anyway. | ||
if (getLangOpts().SYCLIsDevice) { | ||
SYCLDiagIfDeviceCode(AsmLoc, diag::err_sycl_restrict) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has anything changed in this file, or is this simply a formatting change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just formatting. |
||
<< KernelUseAssembly; | ||
SYCLDiagIfDeviceCode(AsmLoc, diag::err_sycl_restrict) << KernelUseAssembly; | ||
return new (Context) | ||
GCCAsmStmt(Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, | ||
NumInputs, Names, Constraints, Exprs.data(), AsmString, | ||
NumClobbers, Clobbers, NumLabels, RParenLoc); | ||
GCCAsmStmt(Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, | ||
Names, Constraints, Exprs.data(), AsmString, NumClobbers, | ||
Clobbers, NumLabels, RParenLoc); | ||
} | ||
|
||
FunctionDecl *FD = dyn_cast<FunctionDecl>(getCurLexicalContext()); | ||
|
Uh oh!
There was an error while loading. Please reload this page.