Discussion:
Emit jump insn in function prologue
Peter Leist
2009-04-24 09:50:42 UTC
Permalink
Hi all,

can I use emit_cmp_and_jump_insns while creating the function prologue/epilogue?
If I try, I always get an error at runtime

func.c:33: internal compiler error: in make_edges, at cfgbuild.c:354

I think this is because the jump doesn't get an JUMP_LABEL associated to it.
Is there an other way at this pass to add loops to the code?

thanks,
peter
Ian Lance Taylor
2009-04-24 17:27:00 UTC
Permalink
Post by Peter Leist
can I use emit_cmp_and_jump_insns while creating the function prologue/epilogue?
If I try, I always get an error at runtime
func.c:33: internal compiler error: in make_edges, at cfgbuild.c:354
I think this is because the jump doesn't get an JUMP_LABEL associated to it.
Is there an other way at this pass to add loops to the code?
Using a general function like emit_cmp_and_jump_insns when generating
the prologue is somewhat risky, because emit_cmp_and_jump_insns expects
to be run before reload. It freely calls functions like force_reg and
gen_reg_rtx which may not be used before reload.

In the function prologue you should know precisely which insns you want
to emit. It will be safer in general to use emit_insn (gen_XXX ())
rather than to call a general routine.

I don't know of any existing cases where the prologue needs a jump, but
it should be easy enough to emit a jump insn and set JUMP_LABEL
yourself.

Ian
Jan Hubicka
2009-04-24 18:38:29 UTC
Permalink
Post by Ian Lance Taylor
Post by Peter Leist
can I use emit_cmp_and_jump_insns while creating the function prologue/epilogue?
If I try, I always get an error at runtime
func.c:33: internal compiler error: in make_edges, at cfgbuild.c:354
I think this is because the jump doesn't get an JUMP_LABEL associated to it.
Is there an other way at this pass to add loops to the code?
Using a general function like emit_cmp_and_jump_insns when generating
the prologue is somewhat risky, because emit_cmp_and_jump_insns expects
to be run before reload. It freely calls functions like force_reg and
gen_reg_rtx which may not be used before reload.
In the function prologue you should know precisely which insns you want
to emit. It will be safer in general to use emit_insn (gen_XXX ())
rather than to call a general routine.
I don't know of any existing cases where the prologue needs a jump, but
it should be easy enough to emit a jump insn and set JUMP_LABEL
yourself.
x86_64 has jump around saving SSE regs for variadic function prologue.

Honza
Post by Ian Lance Taylor
Ian
Ian Lance Taylor
2009-04-24 19:11:59 UTC
Permalink
Post by Jan Hubicka
Post by Ian Lance Taylor
I don't know of any existing cases where the prologue needs a jump, but
it should be easy enough to emit a jump insn and set JUMP_LABEL
yourself.
x86_64 has jump around saving SSE regs for variadic function prologue.
Doesn't count, because that is done in the TARGET_SETUP_INCOMING_VARARGS
hook which is called before reload. The interesting case here is
prologue generation done after reload.

Ian
Eric Botcazou
2009-04-24 19:17:49 UTC
Permalink
Post by Ian Lance Taylor
Doesn't count, because that is done in the TARGET_SETUP_INCOMING_VARARGS
hook which is called before reload. The interesting case here is
prologue generation done after reload.
Alpha emits a loop in the prologue to check the stack as per the Tru64 ABI.
--
Eric Botcazou
Ian Lance Taylor
2009-04-24 20:23:56 UTC
Permalink
Post by Eric Botcazou
Post by Ian Lance Taylor
Doesn't count, because that is done in the TARGET_SETUP_INCOMING_VARARGS
hook which is called before reload. The interesting case here is
prologue generation done after reload.
Alpha emits a loop in the prologue to check the stack as per the Tru64 ABI.
You're right. It does it wrapped up a single insn, though, so the jump
is never seen at the RTL level. The prologue_stack_probe_loop insn does
this:
operands[2] = gen_label_rtx ();
(*targetm.asm_out.internal_label) (asm_out_file, "L",
CODE_LABEL_NUMBER (operands[2]));
return "stq $31,-8192(%1)\;subq %0,1,%0\;lda %1,-8192(%1)\;bne %0,%l2";

Ian

Loading...