3 ms·
It's not difficult to implement goto as such, it's just a JMP instruction, but (I'm not a compiler developer, but I can imagine) implementing goto without intro
by rob74 2y ago
It's not difficult to implement goto as such, it's just a JMP instruction, but (I'm not a compiler developer, but I can imagine) implementing goto without introducing strange bugs or crashes is a bit more difficult.
- JonChesterfield 2y agoCompilers really like canonical forms. There's a good chance that if, for, while, goto, break and so forth all turn into an edge between basic blocks (anything that doesn't have a branch or branch target in it). In a rather literal sense it's usually all sugar over goto, unless you're doing something niche like carefully preserving structure because your target language doesn't have branches. So seeing someone say that their compiler struggles to represent goto throws some doubt on how the thing is implemented. Goto should generally be the easiest possible control flow to translate into your IR.