Skip to content

Commit b970ff1

Browse files
tekknolagik0kubun
authored andcommitted
Default instruction output type to Any
If we're adding a bunch of instructions in the middle of an optimization pass, we don't want to use their (currently uninitialized) types because they start as Empty, and Empty is a subtype of everything. This breaks some optimizations. This Any will get refined the next time we call infer_types.
1 parent 608fe6e commit b970ff1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

zjit/src/hir.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,12 @@ impl Function {
666666
// Add an instruction to the function without adding it to any block
667667
fn new_insn(&mut self, insn: Insn) -> InsnId {
668668
let id = InsnId(self.insns.len());
669+
if insn.has_output() {
670+
self.insn_types.push(types::Any);
671+
} else {
672+
self.insn_types.push(types::Empty);
673+
}
669674
self.insns.push(insn);
670-
self.insn_types.push(types::Empty);
671675
id
672676
}
673677

@@ -2854,8 +2858,8 @@ mod opt_tests {
28542858
bb0():
28552859
PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_PLUS)
28562860
PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_PLUS)
2857-
v14:Fixnum[6] = Const Value(6)
2858-
Return v14
2861+
v15:Fixnum[6] = Const Value(6)
2862+
Return v15
28592863
"#]]);
28602864
}
28612865

0 commit comments

Comments
 (0)