Conversation
When a parsed module contains branches to control flow structures other than blocks or loops, IRBuilder must create a wrapper block around the control flow structure for those branches to target. When that wrapper block is pushed onto the stack, the current binary position is attached as its end position. But the matching start position was previously still attached to the original control flow structure. The lack of an end position on the original control flow structure could cause an assertion failure later when then debug info was written back out. Fix the bug by moving the start position from the original control flow structure to the wrapper block where the matching end position will be attached. Fixes #8940.
|
Any thoughts about how to test this? |
| // When we wrap an expression then push the wrapper, we would end up with the | ||
| // binary start location attached to the original expression and the end | ||
| // location attached to the wrapper. Move the binary start location to the | ||
| // wrapper to avoid splitting the span information. |
There was a problem hiding this comment.
Hmm, but do we avoid printing this wrapper block both in the text and binary formats? If so then the debug info would not be shown, and it might be better to put it on the original expression instead?
There was a problem hiding this comment.
No, we emit the block in both cases because it has a label. It would be interesting to improve at least the binary parser to elide these blocks as a follow-up.
There was a problem hiding this comment.
Ok, sgtm them, and lgtm % other comments
|
For testing, you can use |
|
Also, can we perhaps document this wrapping process somewhere? That neither AI nor I could figure it out in a reasonable time is unfortunate, as I wrote in the other issue. |
When a parsed module contains branches to control flow structures other than blocks or loops, IRBuilder must create a wrapper block around the control flow structure for those branches to target. When that wrapper block is pushed onto the stack, the current binary position is attached as its end position. But the matching start position was previously still attached to the original control flow structure. The lack of an end position on the original control flow structure could cause an assertion failure later when then debug info was written back out. Fix the bug by moving the start position from the original control flow structure to the wrapper block where the matching end position will be attached.
Fixes #8940.