diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:31:46 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:37:19 +0000 | 
| commit | e8d8bef961a50d4dc22501cde4fb9fb0be1b2532 (patch) | |
| tree | 94f04805f47bb7c59ae29690d8952b6074fff602 /contrib/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp | |
| parent | bb130ff39747b94592cb26d71b7cb097b9a4ea6b (diff) | |
| parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp | 28 | 
1 files changed, 14 insertions, 14 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp b/contrib/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp index f1b3fe8e2fa9..930e0b7ee01a 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -167,12 +167,9 @@ public:    void flush();  private: -  void mapGlobalInitializer(GlobalVariable &GV, Constant &Init);    void mapAppendingVariable(GlobalVariable &GV, Constant *InitPrefix,                              bool IsOldCtorDtor,                              ArrayRef<Constant *> NewMembers); -  void mapGlobalIndirectSymbol(GlobalIndirectSymbol &GIS, Constant &Target); -  void remapFunction(Function &F, ValueToValueMapTy &VM);    ValueToValueMapTy &getVM() { return *MCs[CurrentMCID].VM; }    ValueMaterializer *getMaterializer() { return MCs[CurrentMCID].Materializer; } @@ -822,11 +819,15 @@ void Mapper::flush() {        break;      case WorklistEntry::MapAppendingVar: {        unsigned PrefixSize = AppendingInits.size() - E.AppendingGVNumNewMembers; +      // mapAppendingVariable call can change AppendingInits if initalizer for +      // the variable depends on another appending global, because of that inits +      // need to be extracted and updated before the call. +      SmallVector<Constant *, 8> NewInits( +          drop_begin(AppendingInits, PrefixSize)); +      AppendingInits.resize(PrefixSize);        mapAppendingVariable(*E.Data.AppendingGV.GV,                             E.Data.AppendingGV.InitPrefix, -                           E.AppendingGVIsOldCtorDtor, -                           makeArrayRef(AppendingInits).slice(PrefixSize)); -      AppendingInits.resize(PrefixSize); +                           E.AppendingGVIsOldCtorDtor, makeArrayRef(NewInits));        break;      }      case WorklistEntry::MapGlobalIndirectSymbol: @@ -900,14 +901,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, Attribute::ByRef}) { +        if (Type *Ty = Attrs.getAttribute(i, TypedAttr).getValueAsType()) { +          Attrs = Attrs.replaceAttributeType(C, i, TypedAttr, +                                             TypeMapper->remapType(Ty)); +          break; +        }        }      }      CB->setAttributes(Attrs);  | 
