public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, alpha]: Fix PR 46533. bootstrap failure
@ 2010-11-20 13:21 Uros Bizjak
  2010-11-21  2:24 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2010-11-20 13:21 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Henderson

[-- Attachment #1: Type: text/plain, Size: 3574 bytes --]

Hello!

Currently, alpha bootstrap fails with:

/home/uros/gcc-build/./prev-gcc/xgcc -B/home/uros/gcc-build/./prev-gcc/
-B/usr/local/alphaev68-unknown-linux-gnu/bin/
-B/usr/local/alphaev68-unknown-linux-gnu/bin/
-B/usr/local/alphaev68-unknown-linux-gnu/lib/ -isystem
/usr/local/alphaev68-unknown-linux-gnu/include -isystem
/usr/local/alphaev68-unknown-linux-gnu/sys-include      -g -O2 -gtoggle
-DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes
-Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long
-Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition
-Wc++-compat -fno-common  -DHAVE_CONFIG_H  -o cc1plus \
          cp/cp-lang.o c-family/stub-objc.o cp/call.o cp/decl.o cp/expr.o
cp/pt.o cp/typeck2.o cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parser.o
cp/ptree.o cp/rtti.o cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o
cp/method.o cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o
cp/optimize.o cp/mangle.o cp/cp-objcp-common.o cp/name-lookup.o
cp/cxx-pretty-print.o cp/cp-gimplify.o tree-mudflap.o attribs.o incpath.o
prefix.o c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o
c-family/c-format.o c-family/c-gimplify.o c-family/c-lex.o c-family/c-omp.o
c-family/c-opts.o c-family/c-pch.o c-family/c-ppoutput.o c-family/c-pragma.o
c-family/c-pretty-print.o c-family/c-semantics.o c-family/c-ada-spec.o
cc1plus-checksum.o main.o tree-browser.o libbackend.a ../libcpp/libcpp.a
../libdecnumber/libdecnumber.a ../libcpp/libcpp.a   ../libiberty/libiberty.a
../libdecnumber/libdecnumber.a  -lcloog -lppl_c -lppl -lgmpxx -lmpc -lmpfr
-lgmp -rdynamic -ldl  -L../zlib -lz
libbackend.a(gimple.o): In function `gimple_types_compatible_p_1':
(.text+0xe7ac): relocation truncated to fit: BRADDR against `.text.unlikely'
libbackend.a(gimple.o): In function `gimple_types_compatible_p_1':
(.text+0xeb28): relocation truncated to fit: BRADDR against `.text.unlikely'
libbackend.a(gimple.o): In function `gimple_types_compatible_p_1':
(.text+0xeb6c): relocation truncated to fit: BRADDR against `.text.unlikely'
libbackend.a(gimple.o): In function `gimple_types_compatible_p_1':
(.text+0xeca4): relocation truncated to fit: BRADDR against `.text.unlikely'
libbackend.a(gimple.o): In function `gimple_types_compatible_p_1':
(.text+0xecf0): relocation truncated to fit: BRADDR against `.text.unlikely'
libbackend.a(gimple.o): In function `gimple_types_compatible_p_1':
(.text+0xed5c): relocation truncated to fit: BRADDR against `.text.unlikely'
libbackend.a(gimple.o): In function `gimple_types_compatible_p_1':
(.text+0xf238): relocation truncated to fit: BRADDR against `.text.unlikely'
collect2: ld returned 1 exit status

The problem is, that gcc assumes that all function, defined in the
same section can be reached by a "near" calls (direct call with 20bit
signed offset). However, various functions, otherwise in the same
section, can be emitted into hot and cold sub-sections, so direct
calls that cross sections can violate this assumption.

Attached patch removes the assumption from gcc, so "far" calls are
always emitted instead. In effect, gcc leaves the job of relaxing
calls (that obviously is not up to) to the linker. In my testing,
linker does its magic quite well and relaxes "far" calls back to
"near" call when hot and cold sections are merged.

2010-11-20  Uros Bizjak  <ubizjak@gmail.com>

	PR target/46533
	* config/alpha/predicates.md (direct_call_operand): Return false
	for !TARGET_SMALL_TEXT targets.

Patch was tested on alphaev68-pc-linux-gnu.

OK for mainline?

Uros.

[-- Attachment #2: a.diff.txt --]
[-- Type: text/plain, Size: 1258 bytes --]

Index: config/alpha/predicates.md
===================================================================
--- config/alpha/predicates.md	(revision 166974)
+++ config/alpha/predicates.md	(working copy)
@@ -266,8 +266,6 @@
 (define_predicate "direct_call_operand"
   (match_operand 0 "samegp_function_operand")
 {
-  tree op_decl, cfun_sec, op_sec;
-
   /* If profiling is implemented via linker tricks, we can't jump
      to the nogp alternate entry point.  Note that crtl->profile
      would not be correct, since that doesn't indicate if the target
@@ -291,21 +289,7 @@
   if (TARGET_SMALL_TEXT)
     return true;
 
-  /* Otherwise, a decl is "near" if it is defined in the same section.  */
-  if (flag_function_sections)
-    return false;
-
-  op_decl = SYMBOL_REF_DECL (op);
-  if (DECL_ONE_ONLY (current_function_decl)
-      || (op_decl && DECL_ONE_ONLY (op_decl)))
-    return false;
-
-  cfun_sec = DECL_SECTION_NAME (current_function_decl);
-  op_sec = op_decl ? DECL_SECTION_NAME (op_decl) : NULL;
-  return ((!cfun_sec && !op_sec)
-	  || (cfun_sec && op_sec
-	      && strcmp (TREE_STRING_POINTER (cfun_sec),
-		         TREE_STRING_POINTER (op_sec)) == 0));
+  return false;
 })
 
 ;; Return 1 if OP is a valid operand for the MEM of a CALL insn.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, alpha]: Fix PR 46533. bootstrap failure
  2010-11-20 13:21 [PATCH, alpha]: Fix PR 46533. bootstrap failure Uros Bizjak
@ 2010-11-21  2:24 ` Richard Henderson
  2010-11-21 12:17   ` Uros Bizjak
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2010-11-21  2:24 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

On 11/20/2010 03:49 AM, Uros Bizjak wrote:
> 	PR target/46533
> 	* config/alpha/predicates.md (direct_call_operand): Return false
> 	for !TARGET_SMALL_TEXT targets.

It would have been nice to be able to determine that the section that
will be used is the same, and continue the short branch.  But that
seems a bit tricky.

Patch is ok.


r~

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, alpha]: Fix PR 46533. bootstrap failure
  2010-11-21  2:24 ` Richard Henderson
@ 2010-11-21 12:17   ` Uros Bizjak
  0 siblings, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2010-11-21 12:17 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Henderson

On Sun, Nov 21, 2010 at 1:21 AM, Richard Henderson <rth@redhat.com> wrote:
> On 11/20/2010 03:49 AM, Uros Bizjak wrote:
>>       PR target/46533
>>       * config/alpha/predicates.md (direct_call_operand): Return false
>>       for !TARGET_SMALL_TEXT targets.
>
> It would have been nice to be able to determine that the section that
> will be used is the same, and continue the short branch.  But that
> seems a bit tricky.
>
> Patch is ok.

Thanks!

Please note that even for the calls in the same section, offset of +/-
1M is IMO a bit too small to handle all the cases. Linker has all the
data, so it will relax all appropriate calls, leaving only an extra
unop after relaxation.

I also committed a small testsuite patch, calls are always emitted as
"far" in the assembly.

2010-11-21  Uros Bizjak  <ubizjak@gmail.com>

	PR target/46533
	* gcc.dg/inline-2.c: Do not scan for "jsr" on alpha*-*-*  targets.

Tested on alphaec68-pc-linux-gnu, committed to mainline SVN.

Uros.

Index: gcc.dg/inline-2.c
===================================================================
--- gcc.dg/inline-2.c	(revision 166974)
+++ gcc.dg/inline-2.c	(working copy)
@@ -14,6 +14,5 @@
   return foo() + foo() + 1;
 }

-/* { dg-final { scan-assembler-not "jsr" { target alpha*-*-* } } } */
 /* { dg-final { scan-assembler-not "PLT" { target i?86-*-* x86_64-*-* } } } */
 /* { dg-final { scan-assembler-not "plt" { target powerpc*-*-* } } } */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-21  8:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-20 13:21 [PATCH, alpha]: Fix PR 46533. bootstrap failure Uros Bizjak
2010-11-21  2:24 ` Richard Henderson
2010-11-21 12:17   ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).