summaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2023-10-17 23:04:35 -0700
committerGitHub <noreply@github.com>2023-10-17 23:04:35 -0700
commit33430205510f4ac82f91728e6289b0412576209c (patch)
tree21b9b0e66e4a4d2e862ce0d900b74ff1f823b819 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent279c155fb224f5078e1fc8cc7ad9616442573d4a (diff)
[ModuleInliner] Fix the heap maintenance (#69251)
With expensive checks enabled but without this patch, std::pop_heap triggers an assertion failure. This is because: updateAndCheckDecreased(Heap.front()) updates the priority associated with Heap.front(), so Heap may no longer be a valid heap. The libstdc++ version of std::pop_heap requires that the entire range be a valid heap even though the core task of std::pop_heap is just to swap the Heap.front() and Heap.back(). This patch fixes the problem by: - calling std::pop_heap to swap Heap.front() and Heap.back(), - updating the priority of Heap.back(), and - inserting Heap.back() back into the heap. We could reduce the number of calls to updateAndCheckDecreased or the number of elements being moved, but I think it's important to fix the crash first. Credit to Ivan Kosarev for identifying the problem and Liqiang Tao for the analysis and initial version of the patch.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions