Ditch stack_check instruction
This commit is contained in:
committed by
Dan Gohman
parent
944251260b
commit
e9111d1de2
@@ -269,35 +269,3 @@ fn expand_fconst(
|
||||
};
|
||||
pos.func.dfg.replace(inst).bitcast(ty, ival);
|
||||
}
|
||||
|
||||
/// Expand the stack check instruction.
|
||||
pub fn expand_stack_check(
|
||||
inst: ir::Inst,
|
||||
func: &mut ir::Function,
|
||||
_cfg: &mut ControlFlowGraph,
|
||||
isa: &TargetIsa,
|
||||
) {
|
||||
use ir::condcodes::IntCC;
|
||||
|
||||
let gv = match func.dfg[inst] {
|
||||
ir::InstructionData::UnaryGlobalVar { global_var, .. } => global_var,
|
||||
_ => panic!("Want stack_check: {}", func.dfg.display_inst(inst, isa)),
|
||||
};
|
||||
let ptr_ty = isa.pointer_type();
|
||||
|
||||
let mut pos = FuncCursor::new(func).at_inst(inst);
|
||||
pos.use_srcloc(inst);
|
||||
|
||||
let limit_addr = pos.ins().global_addr(ptr_ty, gv);
|
||||
|
||||
let mut mflags = ir::MemFlags::new();
|
||||
mflags.set_aligned();
|
||||
mflags.set_notrap();
|
||||
let limit = pos.ins().load(ptr_ty, mflags, limit_addr, 0);
|
||||
let cflags = pos.ins().ifcmp_sp(limit);
|
||||
pos.func.dfg.replace(inst).trapif(
|
||||
IntCC::UnsignedGreaterThanOrEqual,
|
||||
cflags,
|
||||
ir::TrapCode::StackOverflow,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user