[PATCH] D108796: Copy Elementtype Attribute to IR at Link step

Chenyang Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 27 13:12:02 PDT 2021


chenyang.liu 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:
> 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.


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