This is an archive of the discontinued LLVM Phabricator instance.

Auto Causes copy problems
ClosedPublic

Authored by XinWang10 on Jan 4 2023, 2:24 AM.

Details

Summary

Use variable without & cause the copy of an object

Diff Detail

Event Timeline

XinWang10 created this revision.Jan 4 2023, 2:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 4 2023, 2:24 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
XinWang10 requested review of this revision.Jan 4 2023, 2:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 4 2023, 2:24 AM
This revision is now accepted and ready to land.Jan 5 2023, 1:18 AM
pengfei added inline comments.Jan 5 2023, 1:38 AM
llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
100

StringRef is a small class. It's common to use copy in LLVM code. I guess it may be better to use copy than reference in small size sturctures.

XinWang10 retitled this revision from [Coverity] Auto Causes copy to Auto Causes copy problems.Jan 5 2023, 1:43 AM
XinWang10 added inline comments.Jan 5 2023, 2:43 AM
llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
100

I tried to make an assemble file, seems it is better to use copy here, little struct can be transfered by regs.

XinWang10 closed this revision.Jan 5 2023, 2:47 AM
XinWang10 added inline comments.Jan 5 2023, 3:28 AM
llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
100

sorry, by stack not regs.