This is an archive of the discontinued LLVM Phabricator instance.

[NFC][Clang][Driver][AMDGPU] Avoid temporary copies of std::string by using Twine and StringRef
ClosedPublic

Authored by jmmartinez on Nov 30 2022, 9:17 AM.

Diff Detail

Event Timeline

jmmartinez created this revision.Nov 30 2022, 9:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 30 2022, 9:17 AM
jmmartinez requested review of this revision.Nov 30 2022, 9:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 30 2022, 9:17 AM
tra accepted this revision.Dec 1 2022, 10:32 AM

LGTM in principle.

That said, I don't think StringRef buys us anything here as none of this code is in the hot path. It also comes with the downside that now one has to worry about lifetimes of the strings we refer to. Things do look OK in this case, but it would be good if it could be confirmed with sanitizer.
In code that's not performance critical I personally prefer passing std::string by value and let compiler optimize them away.

This revision is now accepted and ready to land.Dec 1 2022, 10:32 AM

@tra Thanks for the review! I double checked with ASAN and there were no issues.