Unreachable blocks may not be in the dominator tree, so don't crash on them.
Thanks! I completely missed this case :(
There are InfluenceBB and InfluenceNode below, so we'd better be explicit.
This seems unnecessary. ThisBB is guaranteed reachable according to the check you added above. InfluenceBB is guaranteed to dominate ThisBB, so it must be reachable too.
If you agree, maybe change this if to an assert.
Looking at your code more, the first check PDT.getNode doesn't really guard against unreachable basic blocks. You may want to use DT.getNode() or DT.isReachableFromEntry (I prefer the latter because it's more explicit) there. Then, I believe the second check here is unnecessary.