how to check whether from basicblock A we can go to basicblock B within the same function?

Yes, that would be better.