Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Module::tracekind() to examine the kind of trace we have. #1525

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions ykrt/src/compile/jitc_yk/opt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,26 @@ impl Opt {

fn opt(mut self) -> Result<Module, CompilationError> {
let base = self.m.insts_len();
let peel = match self.m.inst(self.m.last_inst_idx()) {
// If this is a sidetrace, we perform optimisations up to, but including, loop peeling.
Inst::SidetraceEnd => false,
Inst::TraceHeaderEnd => true,
#[cfg(test)]
// Not all tests create "fully valid" traces, in the sense that -- to keep things
// simple -- they don't end with `TraceHeaderEnd`. We don't want to peel such traces,
// but nor, in testing mode, do we consider them ill-formed.
_ => false,
#[cfg(not(test))]
_ => panic!(),
let peel = match self.m.tracekind() {
TraceKind::HeaderOnly => {
#[cfg(not(test))]
{
true
}

#[cfg(test)]
{
// Not all tests create "fully valid" traces, in the sense that -- to keep
// things simple -- they don't end with `TraceHeaderEnd`. We don't want to peel
// such traces, but nor, in testing mode, do we consider them ill-formed.
matches!(self.m.inst(self.m.last_inst_idx()), Inst::TraceHeaderEnd)
}
}
// If we hit this case, someone's tried to run the optimiser twice.
TraceKind::HeaderAndBody => unreachable!(),
// If this is a sidetrace, we perform optimisations up to, but not including, loop
// peeling.
TraceKind::Sidetrace => false,
};

// Note that since we will apply loop peeling here, the list of instructions grows as this
Expand Down
Loading