[all-commits] [llvm/llvm-project] d0e5d6: [CodeGen][CodeLayout] Fix segfault on access to de...
Afanasyev Ivan via All-commits
all-commits at lists.llvm.org
Mon Jun 23 07:04:44 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d0e5d6fd6180b0f294a00cf48996219df97c9e78
https://github.com/llvm/llvm-project/commit/d0e5d6fd6180b0f294a00cf48996219df97c9e78
Author: Afanasyev Ivan <ivafanas at gmail.com>
Date: 2025-06-23 (Mon, 23 Jun 2025)
Changed paths:
M llvm/lib/CodeGen/MachineBlockPlacement.cpp
Log Message:
-----------
[CodeGen][CodeLayout] Fix segfault on access to deleted block in MBP. (#142357)
Problem 1: There is a typo which reassigns `BlockWorkList` to
`EHPadWorkList` on attempt to remove `RemBB` from work lists.
Problem 2: `Chain->UnscheduledPredecessors == 0` is an incorrect way to
check whether `RemBB` is enqueued or not. The root cause is a postponed
deletion of `WorkList` from already scheduled blocks in
`selectBestCandidateBlock`. Bug happens in the following scenario:
* `FunctionChain` is being processed with non-zero
`UnscheduledPredecessors`
* Block `B'` is added to the `BlockWorkList`
* Block `B'` is chosen as the best successor (`selectBestSuccessor`) for
some another block and added into `Chain`
* Block `B'` is removed by tail duplicator.
`RemovalCallback` erroneously won't erase `B'` from `BlockWorkList`,
because `UnscheduledPredecessors` value of `FunctionChain` is not zero
(and it is allowed to be non-zero).
Proposed solution is to always cleanup worklists on block deletion by
tail duplicator.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list