Another solution is to not have kids, interestingly enough.
At my funeral, since I will be dead, the only ones who will (presumably) be suffering at that point will be the mourners, so arguably, the less people at one’s funeral, the less overall suffering there is.
In terms of the lens of the Regret Minimization Framework (for me) I would regret not having the family I'm leaving my legacy to at my funeral.