921
});
922
} else if (defaultBlock.instructions.length === 1) {
923
const instr = defaultBlock.instructions[0]!;
924
- let place: Place = instr.lvalue!;
924
+ let place: Place = instr.lvalue;
925
let value: ReactiveValue = instr.value;
926
- if (instr.value.kind === "StoreLocal") {
927
- place = instr.value.lvalue.place;
926
+ if (
927
+ /*
928
+ * Value blocks generally end in a StoreLocal to assign the value of the
929
+ * expression for this branch. These StoreLocal instructions can be pruned,
930
+ * since we represent the value blocks as a compund value in ReactiveFunction
931
+ * (no phis). However, it's also possible to have a value block that ends in
932
+ * an AssignmentExpression, which we need to keep. So we only prune
933
+ * StoreLocal for temporaries — any named/promoted values must be used
934
+ * elsewhere and aren't safe to prune.
935
+ */
936
+ value.kind === "StoreLocal" &&
937
+ value.lvalue.place.identifier.name === null
938
+ ) {
939
+ place = value.lvalue.place;
940
value = {
941
kind: "LoadLocal",
930
- place: instr.value.value,
931
- loc: instr.value.value.loc,
942
+ place: value.value,
943
+ loc: value.value.loc,
944
};
945
}
946
return {
951
};
952
} else {
953
const instr = defaultBlock.instructions.at(-1)!;
942
- let place: Place = instr.lvalue!;
954
+ let place: Place = instr.lvalue;
955
let value: ReactiveValue = instr.value;
944
- if (instr.value.kind === "StoreLocal") {
945
- place = instr.value.lvalue.place;
956
+ if (
957
+ /*
958
+ * Value blocks generally end in a StoreLocal to assign the value of the
959
+ * expression for this branch. These StoreLocal instructions can be pruned,
960
+ * since we represent the value blocks as a compund value in ReactiveFunction
961
+ * (no phis). However, it's also possible to have a value block that ends in
962
+ * an AssignmentExpression, which we need to keep. So we only prune
963
+ * StoreLocal for temporaries — any named/promoted values must be used
964
+ * elsewhere and aren't safe to prune.
965
+ */
966
+ value.kind === "StoreLocal" &&
967
+ value.lvalue.place.identifier.name === null
968
+ ) {
969
+ place = value.lvalue.place;
970
value = {
971
kind: "LoadLocal",
948
- place: instr.value.value,
949
- loc: instr.value.value.loc,
972
+ place: value.value,
973
+ loc: value.value.loc,
974
};
975
}
976
const sequence: ReactiveSequenceValue = {