This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/32450] -pg causes miscompilation



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]