diff options
author | Sergey Dmitriev <serguei.n.dmitriev@intel.com> | 2021-01-25 18:07:23 -0800 |
---|---|---|
committer | Sergey Dmitriev <serguei.n.dmitriev@intel.com> | 2021-01-25 18:08:07 -0800 |
commit | 13cedcaf4538dbe1e5c643ba1c5ee0eafa6cb795 (patch) | |
tree | 0f7326e480908228f778fe06699a1c3966ae0445 /llvm/lib/Transforms/Utils/ValueMapper.cpp | |
parent | 8b1171488575bd0b5ccb23bc1a3d22e2aaccb244 (diff) | |
download | llvm-13cedcaf4538dbe1e5c643ba1c5ee0eafa6cb795.zip llvm-13cedcaf4538dbe1e5c643ba1c5ee0eafa6cb795.tar.gz llvm-13cedcaf4538dbe1e5c643ba1c5ee0eafa6cb795.tar.bz2 |
[llvm-link] Fix crash when materializing appending global
This patch fixes llvm-link crash when materializing global variable
with appending linkage and initializer that depends on another
global with appending linkage.
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D95329
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ValueMapper.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 8ab272e..930e0b7 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -819,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: |