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

Conversation

erichkeane
Copy link
Contributor

Apparently we have some static globals of type std::string to represent
a string-literal. The result is that we get some std::string
constructors (and thus allocations!) for no reason. These are only ever
used as StringRef.

This patch replaces those with constexpr llvm::StringLiteral types,
which is a constexpr-constructed StringRef. These don't require
allocations like std::string, so the initialization becomes a no-op.

Additionally, these were being copied at least 1x later on, so the
switch there likely saves runtime allocations as well.

Apparently we have some static globals of type std::string to represent
a string-literal.  The result is that we get some std::string
constructors (and thus allocations!) for no reason.  These are only ever
used as StringRef.

This patch replaces those with constexpr llvm::StringLiteral types,
which is a constexpr-constructed StringRef. These don't require
allocations like std::string, so the initialization becomes a no-op.

Additionally, these were being copied at least 1x later on, so the
switch there likely saves runtime allocations as well.
Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me, thanks!

@bader bader merged commit 8b38a14 into intel:sycl Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants