Retain original structure of labeled blocks

Handles some edge-cases where we previously flattened away some of the structure 
of a labeled block, instead ensuring that we retain the original shape. See the 
output. 

## Test Plan 

Tested on the internal app we're focused on (w useMemo inlining enabled), it 
works fine.
This commit is contained in:
Joe Savona committed 2023-05-17 15:55:54 -07:00
1 parent 7831ac2189
commit 3603ee00a6
5 files changed
+27 -15

No files matched your search

@@ -573,15 +573,18 @@ class Driver {
case "optional":
case "ternary":
case "logical": {
const fallthroughId = terminal.fallthrough;
invariant(
!this.cx.isScheduled(fallthroughId),
"Logical terminal fallthrough cannot have been scheduled"
);
const scheduleId = this.cx.schedule(fallthroughId, "if");
scheduleIds.push(scheduleId);
const fallthroughId =
terminal.fallthrough !== null &&
!this.cx.isScheduled(terminal.fallthrough)
? terminal.fallthrough
: null;
if (fallthroughId !== null) {
const scheduleId = this.cx.schedule(fallthroughId, "if");
scheduleIds.push(scheduleId);
}
const { place, value } = this.visitValueBlockTerminal(terminal);
this.cx.unscheduleAll(scheduleIds);
blockValue.push({
kind: "instruction",
instruction: {
@@ -592,8 +595,9 @@ class Driver {
},
});
this.cx.unschedule(scheduleId);
this.visitBlock(this.cx.ir.blocks.get(fallthroughId)!, blockValue);
if (fallthroughId !== null) {
this.visitBlock(this.cx.ir.blocks.get(fallthroughId)!, blockValue);
}
break;
}
case "goto": {