Skip to content

Commit

Permalink
Merge pull request #1397 from vext01/phi-type
Browse files Browse the repository at this point in the history
Fix stack overflow when asking for an AOT operand's type.
  • Loading branch information
ltratt authored Sep 13, 2024
2 parents 432faf1 + 37bdeb3 commit 7baa208
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ykllvm
6 changes: 4 additions & 2 deletions ykrt/src/compile/jitc_yk/aot_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ pub(crate) enum Inst {
},
#[deku(id = "14")]
Phi {
tyidx: TyIdx,
#[deku(temp)]
num_incoming: usize,
#[deku(count = "num_incoming")]
Expand Down Expand Up @@ -1014,9 +1015,9 @@ impl Inst {
Self::Store { .. } => None,
Self::Cast { dest_tyidx, .. } => Some(m.type_(*dest_tyidx)),
Self::Switch { .. } => None,
Self::Phi { incoming_vals, .. } => {
Self::Phi { tyidx, .. } => {
// Indexing cannot crash: correct PHI nodes have at least one incoming value.
Some(incoming_vals[0].type_(m))
Some(m.type_(*tyidx))
}
Self::IndirectCall { ftyidx, .. } => {
// The type of the newly-defined local is the return type of the callee.
Expand Down Expand Up @@ -1276,6 +1277,7 @@ impl fmt::Display for DisplayableInst<'_> {
Inst::Phi {
incoming_vals,
incoming_bbs,
..
} => {
let args = incoming_bbs
.iter()
Expand Down
1 change: 1 addition & 0 deletions ykrt/src/compile/jitc_yk/trace_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ impl TraceBuilder {
aot_ir::Inst::Phi {
incoming_bbs,
incoming_vals,
..
} => {
debug_assert_eq!(prevbb.as_ref().unwrap().funcidx(), bid.funcidx());
self.handle_phi(
Expand Down

0 comments on commit 7baa208

Please sign in to comment.