This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Simplify some conversions from ArrayRef to SmallVector by using to_vector and to_vector_of utilities
Changes PlannedPublic

Authored by yurai007 on Jul 29 2022, 7:32 AM.

Details

Diff Detail

Event Timeline

yurai007 created this revision.Jul 29 2022, 7:32 AM
yurai007 requested review of this revision.Jul 29 2022, 7:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 7:32 AM
dblaikie added inline comments.Jul 29 2022, 10:20 AM
llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
814

I'm not sure changes like this add value - if we end up with a ctor that can take MD->operands() as a single argument. Is that possible already/will it be possible with some of the patches you're working on?

llvm/unittests/Analysis/VectorUtilsTest.cpp
510

if there is/we end up with a ctor that takes a range, maybe there should also be an assign function that does the same, that would be used here? Shape.Parameters.assign(Parameters)

yurai007 added inline comments.Aug 4 2022, 7:40 AM
llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
814

Taking into account parallel change which adds SmallVector(ArrayRef<U>) the answer is yes - NextNodes (SmallVector) can be created directly from MD->operands(). So yeah we can skip using to_vector_of here.

yurai007 added inline comments.Aug 4 2022, 8:17 AM
llvm/unittests/Analysis/VectorUtilsTest.cpp
510

I can think of extending SmallVector with range version of assign, but haven't checked yet how much value it would add excluding this particular usage. If you don't mind I would like to postpone it until rest of SmallVector related patches are submitted.

dblaikie added inline comments.Aug 4 2022, 11:40 AM
llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
814

Could you remove this/changes like this from the patch then, or do you plan to wait on changes for this patch until the ArrayRef ctor is added? (you can flag this review as "changes planned" or something)

llvm/unittests/Analysis/VectorUtilsTest.cpp
510

Fair enough - it is a bit unfortunate that this still causes copies & has to re-encode the small size (8 in this instance) but yeah, this is still simpler/tidier than the previous code.

yurai007 marked an inline comment as done and an inline comment as not done.Aug 4 2022, 11:58 AM
yurai007 added inline comments.
llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
814

do you plan to wait on changes for this patch until the ArrayRef ctor is added? (you can flag this review as "changes planned" or something)

Yes, that's my plan, I'm gonna submit https://reviews.llvm.org/D130268 first, and then rebase this change. So flagging this one as "changes planned" sounds good.

yurai007 planned changes to this revision.Aug 4 2022, 12:00 PM
yurai007 marked an inline comment as done.