]> granicus.if.org Git - llvm/commit
[TableGen] Fix bug in TableGen CodeGenPatterns when adding variants of the patterns.
authorAyman Musa <ayman.musa@intel.com>
Tue, 27 Jun 2017 07:10:20 +0000 (07:10 +0000)
committerAyman Musa <ayman.musa@intel.com>
Tue, 27 Jun 2017 07:10:20 +0000 (07:10 +0000)
commit1921b1c5edce46992c8b095479e96ac46290ae6e
tree853b8c62b031bc4d4a68527a9d6baaed867efe79
parent5d353d4750143a13e53abf721d521684ba6a5165
[TableGen] Fix bug in TableGen CodeGenPatterns when adding variants of the patterns.

All patterns reside in a std::vector container, where new variants are added to it using the standard library's emplace_back function.
When calling this with a new element while there is no enough allocated space, a bigger space is allocated and all the old info in the small vector is copied to the newly allocated vector, then the old vector is freed.
The problem is that before doing this "copying", we take a reference of one of the elements in the old vector, and after the "copying" we add it to the new vector.
As the old vector is freed after the copying, the reference now does not point to a valid element.

Added new function to the API of CodeGenDAGPatterns class to return the same information as a copy in order to avoid this issue.

This was revealed in rL305465 that added many patterns and forced the reallocation of the vector which caused crashes in windows bots.

Differential Revision: https://reviews.llvm.org/D34341

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306371 91177308-0d34-0410-b5e6-96231b3b80d8
utils/TableGen/CodeGenDAGPatterns.cpp