This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/32450] -pg causes miscompilation
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jul 2007 09:29:43 -0000
- Subject: [Bug target/32450] -pg causes miscompilation
- References: <bug-32450-6642@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #23 from ubizjak at gmail dot com 2007-07-05 09:29 -------
This is generic sched2 problem and affects all targets. The problem is that the
call to mcount is emitted in final pass, so scheduler can't see it, and is free
to move insns before
(note 26 25 2 NOTE_INSN_PROLOGUE_END)
that marks "call mcount" insertion point.
It happens that on core2, scheduler moves compare before the note, and we got:
.LCFI5:
cmpl $9, __cp_log_handling_MOD_stack_pointer(%rip)
call mcount
jle .L6
Using -fno-schedule-insns2 fixes this problem.
There are two ways to fix this problem:
- The gcc way is to insert clobber of CC reg after the prologue end note.
- The libc way is to fix _mcount to really do what it claims to do:
/* We need a special version of the `mcount' function since for ix86 it
must not clobber any register...
and also save/restore flags reg to the stack.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32450