diff --git a/lib/codegen/meta-python/cdsl/instructions.py b/lib/codegen/meta-python/cdsl/instructions.py index 30bdc306e6..5b2a04d7be 100644 --- a/lib/codegen/meta-python/cdsl/instructions.py +++ b/lib/codegen/meta-python/cdsl/instructions.py @@ -92,7 +92,8 @@ class Instruction(object): :param is_indirect_branch: This is an indirect branch instruction. :param is_call: This is a call instruction. :param is_return: This is a return instruction. - :param is_ghost: This is a ghost instruction. + :param is_ghost: This is a ghost instruction, which has no encoding and no + other register allocation constraints. :param can_trap: This instruction can trap. :param can_load: This instruction can load from memory. :param can_store: This instruction can store to memory. diff --git a/lib/codegen/src/regalloc/coloring.rs b/lib/codegen/src/regalloc/coloring.rs index f0b96e79c9..5e77a42f94 100644 --- a/lib/codegen/src/regalloc/coloring.rs +++ b/lib/codegen/src/regalloc/coloring.rs @@ -166,6 +166,8 @@ impl<'a> Context<'a> { while let Some(inst) = self.cur.next_inst() { self.cur.use_srcloc(inst); if !self.cur.func.dfg[inst].opcode().is_ghost() { + // This is an instruction which either has an encoding or carries ABI-related + // register allocation constraints. let enc = self.cur.func.encodings[inst]; let constraints = self.encinfo.operand_constraints(enc); if self.visit_inst(inst, constraints, tracker, &mut regs) { @@ -175,7 +177,7 @@ impl<'a> Context<'a> { self.cur.goto_inst(inst); } } else { - // This is a ghost instruction with no encoding. + // This is a ghost instruction with no encoding and no extra constraints. let (_throughs, kills) = tracker.process_ghost(inst); self.process_ghost_kills(kills, &mut regs); } diff --git a/lib/codegen/src/regalloc/reload.rs b/lib/codegen/src/regalloc/reload.rs index c767993578..e22fefc0fc 100644 --- a/lib/codegen/src/regalloc/reload.rs +++ b/lib/codegen/src/regalloc/reload.rs @@ -126,10 +126,14 @@ impl<'a> Context<'a> { // visit_ebb_header() places us at the first interesting instruction in the EBB. while let Some(inst) = self.cur.current_inst() { if !self.cur.func.dfg[inst].opcode().is_ghost() { + // This instruction either has an encoding or has ABI constraints, so visit it to + // insert spills and fills as needed. let encoding = self.cur.func.encodings[inst]; self.visit_inst(ebb, inst, encoding, tracker); tracker.drop_dead(inst); } else { + // This is a ghost instruction with no encoding and no extra constraints, so we can + // just skip over it. self.cur.next_inst(); } }