This is an archive of the discontinued LLVM Phabricator instance.

Avoid useless AttrBuilder conversion
AbandonedPublic

Authored by serge-sans-paille on Dec 20 2021, 5:26 AM.

Details

Reviewers
nikic
Summary

AttrBuilder has two constructors that allow for costly implict conversion, when ad-hoc method could do the job more efficiently.
Make these constructors explicit, and provide the ad-hoc specialized method.

Diff Detail

Event Timeline

serge-sans-paille requested review of this revision.Dec 20 2021, 5:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 20 2021, 5:26 AM

(rebased on main branch)

nikic added inline comments.Dec 20 2021, 5:52 AM
llvm/include/llvm/IR/Attributes.h
455

Duplicate declaration with a few lines below, due to a similar change I landed earlier today (https://github.com/llvm/llvm-project/commit/6e30cb7673df293fd294acef7eadca8050b5a71e).

490

I'm not sure I understand the benefit of this method, and similar ones below. In the end, won't we still convert this AttributeSet into an AttrBuilder for merging?

I think the only case where this could make a difference is if the Index is currently unused, in which case the original attribute set can be directly used. Is this the case being optimized?

llvm/lib/IR/Attributes.cpp
1286

@nikic As can be seen here, we're not converting AS to an AttrBuilder, directly calling the merge from an AttributeSet

1793

This merge doesn't require a temporary AttrBuilder

llvm/include/llvm/IR/Attributes.h
455

gotcha

serge-sans-paille abandoned this revision.Feb 24 2022, 7:06 AM