Extend cold-blocks test to test debuginfo as well.
This commit is contained in:
@@ -184,12 +184,13 @@ fn isa_constructor(
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::cursor::{Cursor, FuncCursor};
|
||||
use crate::ir::types::*;
|
||||
use crate::ir::{types::*, SourceLoc, ValueLabel, ValueLabelStart};
|
||||
use crate::ir::{AbiParam, ExternalName, Function, InstBuilder, Signature};
|
||||
use crate::isa::CallConv;
|
||||
use crate::settings;
|
||||
use crate::settings::Configurable;
|
||||
use core::str::FromStr;
|
||||
use cranelift_entity::EntityRef;
|
||||
use target_lexicon::Triple;
|
||||
|
||||
/// We have to test cold blocks by observing final machine code,
|
||||
@@ -204,6 +205,9 @@ mod test {
|
||||
sig.params.push(AbiParam::new(I32));
|
||||
sig.returns.push(AbiParam::new(I32));
|
||||
let mut func = Function::with_name_signature(name, sig);
|
||||
// Add debug info: this tests the debug machinery wrt cold
|
||||
// blocks as well.
|
||||
func.dfg.collect_debug_info();
|
||||
|
||||
let bb0 = func.dfg.make_block();
|
||||
let arg0 = func.dfg.append_block_param(bb0, I32);
|
||||
@@ -216,26 +220,73 @@ mod test {
|
||||
let mut pos = FuncCursor::new(&mut func);
|
||||
|
||||
pos.insert_block(bb0);
|
||||
pos.set_srcloc(SourceLoc::new(1));
|
||||
let v0 = pos.ins().iconst(I32, 0x1234);
|
||||
pos.set_srcloc(SourceLoc::new(2));
|
||||
let v1 = pos.ins().iadd(arg0, v0);
|
||||
pos.ins().brnz(v1, bb1, &[v1]);
|
||||
pos.ins().jump(bb2, &[]);
|
||||
|
||||
pos.insert_block(bb1);
|
||||
pos.set_srcloc(SourceLoc::new(3));
|
||||
let v2 = pos.ins().isub(v1, v0);
|
||||
pos.set_srcloc(SourceLoc::new(4));
|
||||
let v3 = pos.ins().iadd(v2, bb1_param);
|
||||
pos.ins().brnz(v1, bb2, &[]);
|
||||
pos.ins().jump(bb3, &[v3]);
|
||||
|
||||
pos.func.layout.set_cold(bb2);
|
||||
pos.insert_block(bb2);
|
||||
pos.set_srcloc(SourceLoc::new(5));
|
||||
let v4 = pos.ins().iadd(v1, v0);
|
||||
pos.ins().brnz(v4, bb2, &[]);
|
||||
pos.ins().jump(bb1, &[v4]);
|
||||
|
||||
pos.insert_block(bb3);
|
||||
pos.set_srcloc(SourceLoc::new(6));
|
||||
pos.ins().return_(&[bb3_param]);
|
||||
|
||||
// Create some debug info. Make one label that follows all the
|
||||
// values around. Note that this is usually done via an API on
|
||||
// the FunctionBuilder, but that's in cranelift_frontend
|
||||
// (i.e., a higher level of the crate DAG) so we have to build
|
||||
// it manually here.
|
||||
pos.func.dfg.values_labels.as_mut().unwrap().insert(
|
||||
v0,
|
||||
crate::ir::ValueLabelAssignments::Starts(vec![ValueLabelStart {
|
||||
from: SourceLoc::new(1),
|
||||
label: ValueLabel::new(1),
|
||||
}]),
|
||||
);
|
||||
pos.func.dfg.values_labels.as_mut().unwrap().insert(
|
||||
v1,
|
||||
crate::ir::ValueLabelAssignments::Starts(vec![ValueLabelStart {
|
||||
from: SourceLoc::new(2),
|
||||
label: ValueLabel::new(1),
|
||||
}]),
|
||||
);
|
||||
pos.func.dfg.values_labels.as_mut().unwrap().insert(
|
||||
v2,
|
||||
crate::ir::ValueLabelAssignments::Starts(vec![ValueLabelStart {
|
||||
from: SourceLoc::new(3),
|
||||
label: ValueLabel::new(1),
|
||||
}]),
|
||||
);
|
||||
pos.func.dfg.values_labels.as_mut().unwrap().insert(
|
||||
v3,
|
||||
crate::ir::ValueLabelAssignments::Starts(vec![ValueLabelStart {
|
||||
from: SourceLoc::new(4),
|
||||
label: ValueLabel::new(1),
|
||||
}]),
|
||||
);
|
||||
pos.func.dfg.values_labels.as_mut().unwrap().insert(
|
||||
v4,
|
||||
crate::ir::ValueLabelAssignments::Starts(vec![ValueLabelStart {
|
||||
from: SourceLoc::new(5),
|
||||
label: ValueLabel::new(1),
|
||||
}]),
|
||||
);
|
||||
|
||||
let mut shared_flags_builder = settings::builder();
|
||||
shared_flags_builder.set("opt_level", "none").unwrap();
|
||||
shared_flags_builder.set("enable_verifier", "true").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user