Skip to content

Commit

Permalink
Merge pull request #959 from ltratt/move_last_block_removal
Browse files Browse the repository at this point in the history
Move "ignore the very last block" into the hwt mapper.
  • Loading branch information
ptersilie authored Feb 7, 2024
2 parents f3d7537 + e067f27 commit 35539d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 10 additions & 0 deletions ykrt/src/trace/hwt/mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ impl HWTMapper {
}
}
}

// The last block contains pointless unmappable code (the stop tracing call).
match ret.pop() {
Some(x) => {
// This is a rough proxy for "check that we removed only the thing we want to
// remove".
assert!(matches!(x, TracedAOTBlock::Unmappable));
}
_ => unreachable!(),
}
Ok(ret)
}
}
5 changes: 2 additions & 3 deletions yktracec/src/jitmodbuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ class JITModBuilder {
continue;
}

if (Idx > 0 && Idx < InpTrace.Length() - 1) {
if (Idx < InpTrace.Length()) {
// Stores into YkCtrlPointVars only need to be copied if they appear
// at the beginning or end of the trace. Any YkCtrlPointVars stores
// inbetween come from tracing over the control point and aren't
Expand All @@ -1314,8 +1314,7 @@ class JITModBuilder {
I++;
CurInstrIdx++;
}
assert(InpTrace.Length() > 2);
if (Idx == InpTrace.Length() - 2) {
if (Idx == InpTrace.Length() - 1) {
// Once we reached the YkCtrlPointVars stores at the end of the
// trace, we're done. We don't need to copy those instructions
// over, since all YkCtrlPointVars are stored on the shadow
Expand Down

0 comments on commit 35539d3

Please sign in to comment.