This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/39118] x86_64 red zone violation
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Feb 2009 14:50:12 -0000
- Subject: [Bug target/39118] x86_64 red zone violation
- References: <bug-39118-1313@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from ubizjak at gmail dot com 2009-02-06 14:50 -------
(In reply to comment #3)
> Yes, -fno-omit-frame-pointer, sorry.
>
> I don't see why this has anything to do with -fno-omit-frame-pointer per se.
> As far as I can see so far the same problem can arise with any function which
> happens to require a frame pointer for some reason, such as a call to
> __builtin_return_address or if profiling is turned on.
-fno-omit-frame-pointer just forces usage of frame pointer in x86_64 case to
trigger this problem. When frame pointer is used, there is no connection
between %ebp and %esp at the point where prologue ends. The offset between %ebp
and %esp is calculated at this point, but scheduler can still move instructions
referring to %ebp all the way to (insn 567).
(insn/f 567 566 568 2 pr39118.c:6 (set (reg/f:DI 6 bp)
(reg/f:DI 7 sp)) -1 (nil))
(insn/f 568 567 569 2 pr39118.c:6 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0
S8 A8])
(reg:DI 44 r15)) -1 (nil))
...
(insn/f 572 571 573 2 pr39118.c:6 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0
S8 A8])
(reg:DI 3 bx)) -1 (nil))
(note 574 573 93 2 NOTE_INSN_PROLOGUE_END)
(insn:HI 93 574 94 2 pr39118.c:6 (set (mem/c:DI (plus:DI (reg/f:DI 6 bp)
(const_int -136 [0xffffffffffffff78])) [14 buf+0 S8 A8])
(reg:DI 4 si [ buf ])) 89 {*movdi_1_rex64} (nil))
(insn:HI 94 93 95 2 pr39118.c:6 (set (mem/c:SI (plus:DI (reg/f:DI 6 bp)
(const_int -140 [0xffffffffffffff74])) [15 len+0 S4 A8])
(reg:SI 1 dx [ len ])) 47 {*movsi_1} (nil))
This problem can be solved in the most elegant way by inserting some kind of
artificial instruction at the end of prologue, perhaps
(set %rbp)(unspec [(%rsp)] UNSPEC_REDZONE_BLOCKAGE)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39118