aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/ValueMapper.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2020-09-29 09:33:55 -0400
committerMatt Arsenault <Matthew.Arsenault@amd.com>2020-10-16 11:05:02 -0400
commit0a7cd99a702595ccf73c957be0127af9f25fb9a2 (patch)
tree01837b082bd0229afc320b4371fe3558b1a9758f /llvm/lib/Transforms/Utils/ValueMapper.cpp
parent97533b10b27db058cc77c81a4f964b66392871c6 (diff)
downloadllvm-0a7cd99a702595ccf73c957be0127af9f25fb9a2.zip
llvm-0a7cd99a702595ccf73c957be0127af9f25fb9a2.tar.gz
llvm-0a7cd99a702595ccf73c957be0127af9f25fb9a2.tar.bz2
Reapply "OpaquePtr: Add type to sret attribute"
This reverts commit eb9f7c28e5fe6d75fed3587023e17f2997c8024b. Previously this was incorrectly handling linking of the contained type, so this merges the fixes from D88973.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index f1b3fe8e..b2cb8cb 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -900,14 +900,13 @@ void Mapper::remapInstruction(Instruction *I) {
LLVMContext &C = CB->getContext();
AttributeList Attrs = CB->getAttributes();
for (unsigned i = 0; i < Attrs.getNumAttrSets(); ++i) {
- if (Attrs.hasAttribute(i, Attribute::ByVal)) {
- Type *Ty = Attrs.getAttribute(i, Attribute::ByVal).getValueAsType();
- if (!Ty)
- continue;
-
- Attrs = Attrs.removeAttribute(C, i, Attribute::ByVal);
- Attrs = Attrs.addAttribute(
- C, i, Attribute::getWithByValType(C, TypeMapper->remapType(Ty)));
+ for (Attribute::AttrKind TypedAttr :
+ {Attribute::ByVal, Attribute::StructRet}) {
+ if (Type *Ty = Attrs.getAttribute(i, TypedAttr).getValueAsType()) {
+ Attrs = Attrs.replaceAttributeType(C, i, TypedAttr,
+ TypeMapper->remapType(Ty));
+ break;
+ }
}
}
CB->setAttributes(Attrs);