Skip to content

[SYCL][NFC] Remove a bunch of unnecessary std::string allocations #3347

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

Merged
merged 1 commit into from
Mar 12, 2021
Merged
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
18 changes: 9 additions & 9 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ enum KernelInvocationKind {
InvokeParallelForWorkGroup
};

const static std::string InitMethodName = "__init";
const static std::string InitESIMDMethodName = "__init_esimd";
const static std::string FinalizeMethodName = "__finalize";
static constexpr llvm::StringLiteral InitMethodName = "__init";
static constexpr llvm::StringLiteral InitESIMDMethodName = "__init_esimd";
static constexpr llvm::StringLiteral FinalizeMethodName = "__finalize";
constexpr unsigned MaxKernelArgsSize = 2048;

namespace {
Expand Down Expand Up @@ -1713,7 +1713,7 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
bool isAccessorType = false) {
const auto *RecordDecl = FieldTy->getAsCXXRecordDecl();
assert(RecordDecl && "The accessor/sampler must be a RecordDecl");
const std::string &MethodName =
llvm::StringLiteral MethodName =
KernelDecl->hasAttr<SYCLSimdAttr>() && isAccessorType
? InitESIMDMethodName
: InitMethodName;
Expand Down Expand Up @@ -1827,9 +1827,9 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
QualType FieldTy) final {
const auto *RecordDecl = FieldTy->getAsCXXRecordDecl();
assert(RecordDecl && "The accessor/sampler must be a RecordDecl");
const std::string MethodName = KernelDecl->hasAttr<SYCLSimdAttr>()
? InitESIMDMethodName
: InitMethodName;
llvm::StringLiteral MethodName = KernelDecl->hasAttr<SYCLSimdAttr>()
? InitESIMDMethodName
: InitMethodName;
CXXMethodDecl *InitMethod = getMethodByName(RecordDecl, MethodName);
assert(InitMethod && "The accessor/sampler must have the __init method");

Expand Down Expand Up @@ -1972,7 +1972,7 @@ class SyclKernelArgsSizeChecker : public SyclKernelFieldHandler {
bool handleSpecialType(QualType FieldTy) {
const CXXRecordDecl *RecordDecl = FieldTy->getAsCXXRecordDecl();
assert(RecordDecl && "The accessor/sampler must be a RecordDecl");
const std::string &MethodName =
llvm::StringLiteral MethodName =
IsSIMD ? InitESIMDMethodName : InitMethodName;
CXXMethodDecl *InitMethod = getMethodByName(RecordDecl, MethodName);
assert(InitMethod && "The accessor/sampler must have the __init method");
Expand Down Expand Up @@ -2386,7 +2386,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
return VD;
}

const std::string &getInitMethodName() const {
const llvm::StringLiteral getInitMethodName() const {
bool IsSIMDKernel = isESIMDKernelType(KernelObj);
return IsSIMDKernel ? InitESIMDMethodName : InitMethodName;
}
Expand Down