Copying IR during linking causes a type mismatch due to the field being missing in IRMover/Valuemapper. Adds the full range of typed attributes including elementtype attribute in the copy functions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Linker/IRMover.cpp | ||
---|---|---|
652–654 | You can use FirstTypeAttr and LastTypeAttr to generalize this. |
llvm/lib/Linker/IRMover.cpp | ||
---|---|---|
652–654 | 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; |
llvm/lib/Linker/IRMover.cpp | ||
---|---|---|
652–654 | 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. |
llvm/lib/Linker/IRMover.cpp | ||
---|---|---|
652–654 | 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++). |
I don't see any issues locally. Is there something else required to get the automated build passing?
You can use FirstTypeAttr and LastTypeAttr to generalize this.