This is a fix of D13718. D13718 was committed but then reverted because of the following bug:
https://llvm.org/bugs/show_bug.cgi?id=25299
This patch fixes the issue shown in the bug.
Differential D14308
[SimplifyCFG] Extend SimplifyResume to handle phi of trivial landing pad. • chenli on Nov 3 2015, 3:30 PM. Authored by
Details This is a fix of D13718. D13718 was committed but then reverted because of the following bug: This patch fixes the issue shown in the bug.
Diff Detail Event Timeline
Comment Actions First, fix the issues mentioned by David. Second, the previous patch turned out to have a bug by running some of my own local tests. The patch tried to erase all unreachable landing pad blocks, but this invalidated the iteration of SimplifyCFG pass. if (SimplifyCFG(&*BBIt++, TTI, BonusInstThreshold, AC)) { LocalChange = true; ++NumSimpl; } The next block has been iterated before processing the current block (in this case it is the resume block). If the next block turns out to be an unreachable landing pad block deleted by processing the resume block, the iteration will be broken. Therefore, we can only erase the current block in SimplifyCFG. The updated patch fixes this problem, and modify the test’s block layout to catch this bug if it happens.
Comment Actions All of my comments this time around are minor. I think we can probably get this in after one last round of cleanup. p.s. Sorry for the prolonged period without response.
|
This is at the wrong point. We should be checking that the terminator is a unconditional branch before considering the basic block trivial.