Skip to content
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

Fix ignored -fsycl-unnamed-lambda (#145) #146

Merged
merged 1 commit into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions clang/lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ static llvm::Optional<unsigned> SYCLMangleCallback(ASTContext &Ctx,
return llvm::None;
}

std::string computeUniqueSYCLVXXName(StringRef Demangle);

std::string SYCLUniqueStableNameExpr::ComputeName(ASTContext &Context,
QualType Ty) {
std::unique_ptr<MangleContext> Ctx{ItaniumMangleContext::create(
Expand All @@ -569,7 +571,7 @@ std::string SYCLUniqueStableNameExpr::ComputeName(ASTContext &Context,
llvm::raw_string_ostream Out(Buffer);
Ctx->mangleTypeName(Ty, Out);

return Out.str();
return computeUniqueSYCLVXXName(Out.str());
}

SYCLUniqueStableIdExpr::SYCLUniqueStableIdExpr(EmptyShell Empty,
Expand Down Expand Up @@ -684,7 +686,7 @@ StringRef PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
}

/// Compute a unique name that is consumable by sycl_vxx
std::string computeUniqueSYCLVXXName(StringRef Name, StringRef Demangle) {
std::string computeUniqueSYCLVXXName(StringRef Demangle) {
/// VXX has a maximum of 64 character for the name of the kernel function
/// plus the name of one parameter.
/// Those characters need to be used wisely to prevent name collisions.
Expand Down Expand Up @@ -747,8 +749,8 @@ std::string computeUniqueSYCLVXXName(StringRef Name, StringRef Demangle) {
/// repeated. This doesn't hurt entropy too much because it is just 2 out
/// of 64.
Result += llvm::SHA1::hashToString(
llvm::ArrayRef<uint8_t>{reinterpret_cast<const uint8_t *>(Name.data()),
Name.size()},
llvm::ArrayRef<uint8_t>{reinterpret_cast<const uint8_t *>(Demangle.data()),
Demangle.size()},
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789AB");
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3976,7 +3976,6 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
options::OPT_fno_sycl_allow_variadic_func)
: Args.hasFlag(options::OPT_fsycl_allow_variadic_func,
options::OPT_fno_sycl_allow_variadic_func, false);
Opts.SYCLUnnamedLambda = Args.hasArg(options::OPT_fsycl_unnamed_lambda);

// Get OpenMP host file path if any and report if a non existent file is
// found
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,6 @@ static QualType calculateKernelNameType(ASTContext &Ctx,
return TAL->get(0).getAsType().getCanonicalType();
}

std::string computeUniqueSYCLVXXName(StringRef Name, StringRef Demangle);

// Gets a name for the OpenCL kernel function, calculated from the first
// template argument of the kernel caller function.
static std::pair<std::string, std::string>
Expand All @@ -1092,7 +1090,6 @@ constructKernelName(Sema &S, const FunctionDecl *KernelCallerFunc,
std::string Res = std::string(Out.str());
std::string Str =
SYCLUniqueStableNameExpr::ComputeName(S.getASTContext(), KernelNameType);
Res = computeUniqueSYCLVXXName(Res, KernelNameType.getAsString());
return {Res, Str};
}

Expand Down