[Bug target/56807] mingw32: Conflict between stack realignment and stack probe destroys function argument in EAX
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56807 Anton Mitrofanov changed: What|Removed |Added CC||BugMaster at narod dot ru --- Comment #18 from Anton Mitrofanov --- This patch is ok for mingw32 target but may produce incorrect code for x86_64 linux target in case of saving/restoring both rax and r10. In that case during restoring of rax register (in "if (r10_live && eax_live)" path of http://gcc.gnu.org/viewcvs/gcc/trunk/gcc/config/i386/i386.c?r1=205860&r2=205859&pathrev=205860) we will make move from incorrect address [rsp + allocate - UNITS_PER_WORD] while the saved value will be at address [rsp + allocate + UNITS_PER_WORD]. Here is possible code that can be generated (by looking at current gcc source code): // suppose rsp == 1000 here push rax // rsp == 992 ; [992] == rax push r10 // rsp == 984 ; [984] == r10 mov rax, 400 // where 400 is allocate value call allocate_stack sub rsp, rax // rax == 400 so rsp == 584 mov r10, [rsp + 400] // 584 + 400 == 984 ; r10 = [984] mov rax, [rsp + 400 - 8] // 584 + 400 - 8 == 976 ; rax = [976] <- WRONG Instead the last instruction should be mov rax, [rsp + 400 + 8] // 584 + 400 + 8 == 992 ; rax = [992] Sorry, I can't write test case to trigger this code path so I will leave this comment here and not create new bug report (if you want you can move it to new bug report).
[Bug target/56807] mingw32: Conflict between stack realignment and stack probe destroys function argument in EAX
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56807 --- Comment #20 from Anton Mitrofanov --- I was talking about: if (r10_live && eax_live) { t = plus_constant (Pmode, stack_pointer_rtx, allocate); emit_move_insn (gen_rtx_REG (word_mode, R10_REG), gen_frame_mem (word_mode, t)); t = plus_constant (Pmode, stack_pointer_rtx, allocate - UNITS_PER_WORD); emit_move_insn (gen_rtx_REG (word_mode, AX_REG), gen_frame_mem (word_mode, t)); } And especially: t = plus_constant (Pmode, stack_pointer_rtx, allocate - UNITS_PER_WORD);
[Bug target/56807] mingw32: Conflict between stack realignment and stack probe destroys function argument in EAX
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56807 --- Comment #21 from Anton Mitrofanov --- It should be: t = plus_constant (Pmode, stack_pointer_rtx, allocate + UNITS_PER_WORD);
[Bug target/56807] mingw32: Conflict between stack realignment and stack probe destroys function argument in EAX
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56807 --- Comment #23 from Anton Mitrofanov --- >Is it possible to write a test with eax_live == true and r10_live == true? I am really dunno. As I said I can't write sample which will trigger it (that is why it is only comment and not new bug report). But this code path exist so probably someone suggested that it can be triggered (otherwise what for to write it instead of some assert)? >That piece of code is only trigged by -mstack-arg-probe, which is specific to Windows Can it really be used only for Windows target? I am not very good with gcc on other targets so don't know if it have any effect on linux or anything other.