diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -1398,6 +1398,11 @@ // A basic block can only return if it terminates with a ReturnInst and does not // contain calls to noreturn functions. +// If we could assume that something like SimplifyCFG would always run before +// FunctionAttrs and replace code after instructions that don't return with +// unreachable, we would only need to look at the terminator. However, that's +// not always true; for example the new PM's CGSCC pipeline first runs +// FunctionAttrs, then function simplification passes. static bool basicBlockCanReturn(BasicBlock &BB) { if (!isa(BB.getTerminator())) return false;