target-i386: Don't left shift negative constant

Left shift of negative values is undefined behavior. Detected by clang:
qemu/target-i386/translate.c:2423:26: runtime error:
left shift of negative value -8

This changes the code to reverse the sign after the left shift.

Backports commit 712b4243c761cb6ab6a4367a160fd2a42e2d4b76 from qemu
This commit is contained in:
Eduardo Habkost 2018-02-17 13:45:16 -05:00 committed by Lioncash
parent 942c18ead7
commit 67f13016b3
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -2749,7 +2749,7 @@ static void gen_pusha(DisasContext *s)
TCGv **cpu_T = (TCGv **)tcg_ctx->cpu_T;
gen_op_movl_A0_reg(tcg_ctx, R_ESP);
gen_op_addl_A0_im(tcg_ctx, -8 << s->dflag);
gen_op_addl_A0_im(tcg_ctx, -(8 << s->dflag));
if (!s->ss32)
tcg_gen_ext16u_tl(tcg_ctx, cpu_A0, cpu_A0);
tcg_gen_mov_tl(tcg_ctx, *cpu_T[1], cpu_A0);