Bug 39247 - FAIL: gcc.dg/tree-prof/bb-reorg.c compilation, -fprofile-use -D_PROFILE_USE
Summary: FAIL: gcc.dg/tree-prof/bb-reorg.c compilation, -fprofile-use -D_PROFILE_USE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-19 16:51 UTC by John David Anglin
Modified: 2009-10-20 15:25 UTC (History)
3 users (show)

See Also:
Host: arm-none-linux-gnueabi
Target: arm-none-linux-gnueabi
Build: arm-none-linux-gnueabi
Known to work:
Known to fail:
Last reconfirmed: 2009-04-19 21:32:40


Attachments
Proposed patch (371 bytes, patch)
2009-10-19 16:19 UTC, Richard Earnshaw
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2009-02-19 16:51:05 UTC
Executing on host: /home/dave/gnu/gcc/objdir/gcc/xgcc -B/home/dave/gnu/gcc/objdi
r/gcc/ /home/dave/gnu/gcc/gcc/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c   -O2 -f
reorder-blocks-and-partition -fprofile-use -D_PROFILE_USE  -lm   -o /home/dave/g
nu/gcc/objdir/gcc/testsuite/gcc/bb-reorg.x02    (timeout = 300)
/tmp/ccsSaXlI.s: Assembler messages:
/tmp/ccsSaXlI.s:73: Error: internal_relocation (type: OFFSET_IMM) not fixed up
/tmp/ccsSaXlI.s:74: Error: internal_relocation (type: OFFSET_IMM) not fixed up
/tmp/ccsSaXlI.s:75: Error: internal_relocation (type: OFFSET_IMM) not fixed up
/tmp/ccsSaXlI.s:88: Error: internal_relocation (type: OFFSET_IMM) not fixed up
/tmp/ccsSaXlI.s:110: Error: internal_relocation (type: OFFSET_IMM) not fixed up
/tmp/ccsSaXlI.s:127: Error: internal_relocation (type: OFFSET_IMM) not fixed up
compiler exited with status 1

-bash-3.2$ ./xgcc -B./ -v
Reading specs from ./specs
Target: arm-none-linux-gnueabi
Configured with: ../gcc/configure --host=arm-none-linux-gnueabi --target=arm-non e-linux-gnueabi --build=arm-none-linux-gnueabi --disable-stage1-checking --enabl e-languages=c,c++,fortran --enable-shared --enable-threads --disable-multilib -- disable-libmudflap --disable-libssp --enable-symvers=gnu --enable-__cxa_atexit - -disable-libstdcxx-pch --disable-checking --prefix=/home/dave/opt/gnu/gcc/gcc-4. 4.0 --with-gmp=/home/dave/opt/gnu
Thread model: posix
gcc version 4.4.0 20090218 (experimental) [trunk revision 144268] (GCC)

-bash-3.2$ as --version
GNU assembler (GNU Binutils) 2.19.1
Copyright 2007 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `armv5tejl-unknown-linux-gnueabi'.

gcc.dg/tree-prof/pr34999.c fails same way.
Comment 1 jsm-csl@polyomino.org.uk 2009-02-19 21:11:28 UTC
Subject: Re:   New: FAIL: gcc.dg/tree-prof/bb-reorg.c
 compilation,  -fprofile-use -D_PROFILE_USE

The ARM constant pool code needs to handle a 
NOTE_INSN_SWITCH_TEXT_SECTIONS note in some way as indicating insns on one 
side mustn't use constant pool entries on the other side.  One possible 
approach would be treating such a note as an insn of length 4100, but 
there might be a cleaner way.

Comment 2 Ramana Radhakrishnan 2009-04-19 21:32:40 UTC
Still occurs with trunk today.
Comment 3 Mikael Pettersson 2009-10-18 12:55:42 UTC
On ARM, gcc generates assembly code for the bb-reorg.c test case that gas fails to assemble. The pr34999.c test case fails for the same reason. The following  reduced assembly snippet illustrates it:

> cat bb-reorg.s
        .text
        .align  2
        .global main
main:
        ldr     r0, .L30
        mov     pc, lr
        .section        .text.unlikely
        .align  2
.L30:   .word   1819043176
> as bb-reorg.s
bb-reorg.s: Assembler messages:
bb-reorg.s:5: Error: internal_relocation (type: OFFSET_IMM) not fixed up

This still occurs with the recently released binutils-2.20.

Does gcc generate invalid assembly code, or is the assembly code valid and gas is in error for failing to handle it?

Should the bb-reorg and pr34999 test cases be XFAILed on arm until this is resolved?
Comment 4 Richard Earnshaw 2009-10-19 15:18:43 UTC
(In reply to comment #3)
>         .text
>         ldr     r0, .L30
...
>         .section        .text.unlikely
> .L30:   .word   1819043176

This is broken.  We can't reference from .text to .text.unlikely since we can't guarantee that the section will be within 4k of the location doing the load.
Comment 5 Richard Earnshaw 2009-10-19 15:26:40 UTC
(In reply to comment #1)
> Subject: Re:   New: FAIL: gcc.dg/tree-prof/bb-reorg.c
>  compilation,  -fprofile-use -D_PROFILE_USE
> 
> The ARM constant pool code needs to handle a 
> NOTE_INSN_SWITCH_TEXT_SECTIONS note in some way as indicating insns on one 
> side mustn't use constant pool entries on the other side.  One possible 
> approach would be treating such a note as an insn of length 4100, but 
> there might be a cleaner way.
> 

I don't think there should be such notes on ARM due to the branch-range limitation.  We can't arbitrarily jump between sections in Thumb state, for example

Comment 6 Steven Bosscher 2009-10-19 15:42:56 UTC
You should not depend on NOTE_INSN_SWITCH_TEXT_SECTIONS. There are other ways to see if a jump goes from one section to another: edge->flags & EDGE_CROSSING (preferred), and REG_CROSSING_JUMP notes (more reliable in post-pass_free_cfg world).

There is no hook to disable the hot-cold partitioning pass right now. For thumb mode, the ARM back end should just set flag_reorder_blocks_and_partition = 0, like Xtensa and MIPS (for MIPS16 mode) already do, for similar reasons.
Comment 7 Richard Earnshaw 2009-10-19 15:50:50 UTC
(In reply to comment #6)
> You should not depend on NOTE_INSN_SWITCH_TEXT_SECTIONS. There are other ways
> to see if a jump goes from one section to another: edge->flags & EDGE_CROSSING
> (preferred), and REG_CROSSING_JUMP notes (more reliable in post-pass_free_cfg
> world).
> 
> There is no hook to disable the hot-cold partitioning pass right now. For thumb
> mode, the ARM back end should just set flag_reorder_blocks_and_partition = 0,
> like Xtensa and MIPS (for MIPS16 mode) already do, for similar reasons.
> 
Indeed.  In fact even for ARM state, we can only support this option if both the insn-address code correctly separates hot and cold addresses (and I suspect it doesn't) and the literal-pool extraction code correctly extracts the above information (which it certainly doesn't).

So at present we have no choice but to disable this optimization for all ARM configurations.
Comment 8 Richard Earnshaw 2009-10-19 16:19:47 UTC
Created attachment 18826 [details]
Proposed patch

Currently only very lightly tested, but this should solve the issue.
Comment 9 jsm-csl@polyomino.org.uk 2009-10-19 16:44:27 UTC
Subject: Re:  FAIL: gcc.dg/tree-prof/bb-reorg.c compilation,
  -fprofile-use -D_PROFILE_USE

On Mon, 19 Oct 2009, rearnsha at gcc dot gnu dot org wrote:

> I don't think there should be such notes on ARM due to the branch-range
> limitation.  We can't arbitrarily jump between sections in Thumb state, for
> example

Nowadays GNU ld supports generating long branch stubs on ARM.  It's 
intended for calls in large programs, but shouldn't it be possible to get 
the compiler to generate jumps between sections within a function that the 
linker can then make use the long branch stubs if necessary?  (Given a 
solution to the constant pools issue.)

Comment 10 jsm-csl@polyomino.org.uk 2009-10-19 16:46:14 UTC
Subject: Re:  FAIL: gcc.dg/tree-prof/bb-reorg.c compilation,
  -fprofile-use -D_PROFILE_USE

On Mon, 19 Oct 2009, rearnsha at gcc dot gnu dot org wrote:

> Created an attachment (id=18826)
>  --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18826&action=view)
> Proposed patch
> 
> Currently only very lightly tested, but this should solve the issue.

The diagnostic should not end with ".".

Comment 11 Richard Earnshaw 2009-10-19 17:51:58 UTC
(In reply to comment #9)
> Subject: Re:  FAIL: gcc.dg/tree-prof/bb-reorg.c compilation,
>   -fprofile-use -D_PROFILE_USE
> 
> On Mon, 19 Oct 2009, rearnsha at gcc dot gnu dot org wrote:
> 
> > I don't think there should be such notes on ARM due to the branch-range
> > limitation.  We can't arbitrarily jump between sections in Thumb state, for
> > example
> 
> Nowadays GNU ld supports generating long branch stubs on ARM.  It's 
> intended for calls in large programs, but shouldn't it be possible to get 
> the compiler to generate jumps between sections within a function that the 
> linker can then make use the long branch stubs if necessary?  (Given a 
> solution to the constant pools issue.)
> 

The compiler generated stubs are permitted to clobber registers that would not normally be affected (namely IP), so we'd need to build that knowledge into the compiler.  Actually, the manual suggests the compiler can deal with this without the need for using the range-limited branches since it will generate indirect jumps.

The literal-pool problem still needs to be solved though and that's non-trivial.
Comment 12 Richard Earnshaw 2009-10-20 15:18:07 UTC
Subject: Bug 39247

Author: rearnsha
Date: Tue Oct 20 15:17:30 2009
New Revision: 153018

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153018
Log:
	PR target/39247
	* arm.c (arm_override_options): Forcibly disable hot/cold block
	partitioning.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.c

Comment 13 Richard Earnshaw 2009-10-20 15:25:55 UTC
Fixed on trunk.