[AIEX] Fix empty unreachable blocks surviving to assembly.#940
Draft
SagarMaheshwari99 wants to merge 1 commit intoaie-publicfrom
Draft
[AIEX] Fix empty unreachable blocks surviving to assembly.#940SagarMaheshwari99 wants to merge 1 commit intoaie-publicfrom
SagarMaheshwari99 wants to merge 1 commit intoaie-publicfrom
Conversation
BranchFolding failed to eliminate empty MBBs from unreachable IR blocks because: (1) it ran before DeadMachineInstructionElim stripped the dead instructions that made the block empty, and (2) even when it did encounter such blocks, it skipped them—empty blocks with no successors didn't match the `isSuccessor(FallThrough)` check, and the `FallThrough == MF.end()` case was an unimplemented TODO. Fix BranchFolding to handle both cases, and add a BranchFolding run after DCE in the AIE2 pipeline so it can clean up blocks that only become empty after dead code elimination.
Collaborator
martien-de-jong
left a comment
There was a problem hiding this comment.
I guess it will allow linking, but I think the code will still be broken. The 'unreachable' that starts this chain of events is early in llvm code, after it has inferred that calling a function would definitely cause undefined behaviour. That unreachable leaks out through inlining.
Since the branch was definitely emitted, the block definitely existed entering the MCLayer. I would rather emit that empty unreachable block rather than remove the branch to it.
Collaborator
|
We fixed the root case of the problem here: #941. Should we close this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BranchFolding failed to eliminate empty MBBs from unreachable IR blocks because: (1) it ran before DeadMachineInstructionElim stripped the dead instructions that made the block empty, and (2) even when it did encounter such blocks, it skipped them—empty blocks with no successors didn't match the
isSuccessor(FallThrough)check, and theFallThrough == MF.end()case was an unimplemented TODO.Fix BranchFolding to handle both cases, and add a BranchFolding run after DCE in the AIE2 pipeline so it can clean up blocks that only become empty after dead code elimination.