Ditch stack_check instruction

This commit is contained in:
Sergey Pepyakin
2018-05-30 23:31:56 +02:00
committed by Dan Gohman
parent 944251260b
commit e9111d1de2
5 changed files with 0 additions and 70 deletions

View File

@@ -668,27 +668,6 @@ copy_special = Instruction(
ins=(src, dst),
other_side_effects=True)
GV = Operand(
'GV', entities.global_var, doc=r"""
Global variable containing the stack limit.
""")
stack_check = Instruction(
'stack_check', r"""
Check for stack overflow.
Read the stack limit from ``GV`` and compare it to the stack pointer. If
the stack pointer has reached or exceeded the limit, generate a trap with a
``stk_ovf`` code.
The global variable must be accessible and naturally aligned for a
pointer-sized value.
`stack_check` is an alternative way to detect stack overflow, when using
a calling convention that doesn't perform stack probes.
""",
ins=GV, can_trap=True)
delta = Operand('delta', Int)
adjust_sp_down = Instruction(
'adjust_sp_down', r"""

View File

@@ -287,7 +287,6 @@ for ty, minus_zero in [
# Expansions using CPU flags.
expand_flags.custom_legalize(insts.stack_check, 'expand_stack_check')
expand_flags.legalize(
insts.trapnz(x, c),

View File

@@ -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,
);
}