This patch fixes llvm-link crash when materializing global variable
with appending linkage and initializer that depends on another
global with appending linkage.
Details
Diff Detail
Unit Tests
Event Timeline
llvm/lib/Transforms/Utils/ValueMapper.cpp | ||
---|---|---|
822–824 | Does the crash happen because mapAppendingVariable attempts to iterate over an array that may change by the loop? |
llvm/lib/Transforms/Utils/ValueMapper.cpp | ||
---|---|---|
822–824 | 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. |
llvm/lib/Transforms/Utils/ValueMapper.cpp | ||
---|---|---|
822–824 | I see. I'd rename Inits -> NewInits or UnmappedInits to make it more clear that we only want to process new entries. | |
825 | What's the typical number of inits do you expect to see in practice? |
llvm/lib/Transforms/Utils/ValueMapper.cpp | ||
---|---|---|
825 | I have renamed Inits to NewInits in the updated patch and reduced its size to 8. |
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.