Move out logic for inserting a goto.

Allows it to be used more widely; part of the inline logic wants it.