[PATCH] D108796: Copy Elementtype Attribute to IR at Link step
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 27 13:31:34 PDT 2021
nikic added inline comments.
================
Comment at: llvm/lib/Linker/IRMover.cpp:653
{Attribute::ByVal, Attribute::StructRet, Attribute::ByRef,
- Attribute::InAlloca}) {
+ Attribute::InAlloca, Attribute::ElementType}) {
if (Attrs.hasAttribute(i, TypedAttr)) {
----------------
chenyang.liu wrote:
> chenyang.liu wrote:
> > nikic wrote:
> > > You can use FirstTypeAttr and LastTypeAttr to generalize this.
> > I can do it like this if you think it's ok:
> >
> > for (unsigned i = 0; i < Attrs.getNumAttrSets(); ++i) {
> > auto Attr = Attrs.getAttribute(i);
> > if (Attr.isTypeAttribute()) {
> > auto TypedAttr = Attr.getKindAsEnum();
> > if (Type *Ty = Attrs.getAttribute(i, TypedAttr).getValueAsType()) {
> > Attrs = Attrs.replaceAttributeType(C, i, TypedAttr, TypeMap.get(Ty));
> > break;
> Nvm, the existing Attributes API doesn't allow get/set without specifying the specific attribute itself. I wouldn't be able to generalize the attributes with only the firsttype/lasttype as there isn't a way to get the set of attributes of specific type. It's also out of the scope of this change that I want to make.
To be clear, what I'm suggesting is that you replace the hardcoded list of type attributes with something like `for (Attribute::AttrKind TypedAttr = Attribute::FirstTypeAttr; TypedAttr <= Attribute::LastTypeAttr; TypedAttr++)`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108796/new/
https://reviews.llvm.org/D108796
More information about the llvm-commits
mailing list