[llvm] [llvm] fix nullptr dereference in BasicBlock::getIrrLoopHeaderWeight (PR #116192)

Alexander Romanov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 00:11:13 PST 2024


arrv-sc wrote:

I think you are right that we should not guarantee that MachineBasicBlock can be constructed for an empty BasicBlock. It indeed has very little sense from compiler infrastructure point of view (will remove the test for it). Thank you. However I think it does make sense to return `std::nullopt` in the case terminator is not found.  It seems legal to me to attempt to get Loop Header Weight of the BasicBlock with no terminators (and the result should be `std::nullopt` because block is indeed incomplete and we can not analyze any loop-related stuff on WIP basic block). In case you are still strongly against handling this case let me know and I'll simply add an assert instead.

https://github.com/llvm/llvm-project/pull/116192


More information about the llvm-commits mailing list