[PATCH] D95329: [llvm-link] Fix crash when materializing appending global

Sergey Dmitriev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 25 10:17:46 PST 2021


sdmitriev added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/ValueMapper.cpp:822-824
+      // 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.
----------------
tra wrote:
> Does the crash happen because `mapAppendingVariable` attempts to iterate over an array that may change by the loop?
> If that's the case, the fix (making a temp copy with relevant items) should probably be done there.
> 
For the IR from test `mapAppendingVariable` call causes a new item to be added to the `AppendingInits` vector, but this item gets incorrectly cleaned up from it by the `resize` call which follows `mapAppendingVariable`. As a result we are getting `PrefixSize` == -1 while processing the second appending global which leads to a crash.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95329/new/

https://reviews.llvm.org/D95329



More information about the llvm-commits mailing list