Commit b2a6a2fb by Jakub Jelinek Committed by Jakub Jelinek

re PR target/20561 (Error compiling jdtcore.jar on powerpc)

	PR target/20561
	* cfglayout.c (reemit_insn_block_notes): Don't put block notes in
	between jump table and its label.
	* final.c (shorten_branches): Handle notes in between ADDR_VEC
	resp. ADDR_DIFF_VEC and the label preceeding it.
	(final_scan_insn): Likewise.  Ensure ADDR_VEC resp. ADDR_DIFF_VEC
	is emitted in the right section.

	* gcc.dg/20050321-2.c: New test.

From-SVN: r96867
parent 37048601
2005-03-22 Jakub Jelinek <jakub@redhat.com>
PR target/20561
* cfglayout.c (reemit_insn_block_notes): Don't put block notes in
between jump table and its label.
* final.c (shorten_branches): Handle notes in between ADDR_VEC
resp. ADDR_DIFF_VEC and the label preceeding it.
(final_scan_insn): Likewise. Ensure ADDR_VEC resp. ADDR_DIFF_VEC
is emitted in the right section.
2005-03-22 Kazu Hirata <kazu@cs.umass.edu> 2005-03-22 Kazu Hirata <kazu@cs.umass.edu>
* fold-const.c (fold_unary, fold_binary): Update comments * fold-const.c (fold_unary, fold_binary): Update comments
......
...@@ -523,6 +523,12 @@ reemit_insn_block_notes (void) ...@@ -523,6 +523,12 @@ reemit_insn_block_notes (void)
{ {
tree this_block; tree this_block;
/* Avoid putting scope notes between jump table and its label. */
if (JUMP_P (insn)
&& (GET_CODE (PATTERN (insn)) == ADDR_VEC
|| GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC))
continue;
this_block = insn_scope (insn); this_block = insn_scope (insn);
/* For sequences compute scope resulting from merging all scopes /* For sequences compute scope resulting from merging all scopes
of instructions nested inside. */ of instructions nested inside. */
......
...@@ -835,7 +835,7 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED) ...@@ -835,7 +835,7 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED)
max_log = log; max_log = log;
max_skip = LABEL_ALIGN_MAX_SKIP; max_skip = LABEL_ALIGN_MAX_SKIP;
} }
next = NEXT_INSN (insn); next = next_nonnote_insn (insn);
/* ADDR_VECs only take room if read-only data goes into the text /* ADDR_VECs only take room if read-only data goes into the text
section. */ section. */
if (JUMP_TABLES_IN_TEXT_SECTION || !HAVE_READONLY_DATA_SECTION) if (JUMP_TABLES_IN_TEXT_SECTION || !HAVE_READONLY_DATA_SECTION)
...@@ -1677,6 +1677,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ...@@ -1677,6 +1677,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
#ifdef HAVE_cc0 #ifdef HAVE_cc0
rtx set; rtx set;
#endif #endif
rtx next;
insn_counter++; insn_counter++;
...@@ -1932,10 +1933,11 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ...@@ -1932,10 +1933,11 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
fputs (ASM_APP_OFF, file); fputs (ASM_APP_OFF, file);
app_on = 0; app_on = 0;
} }
if (NEXT_INSN (insn) != 0
&& JUMP_P (NEXT_INSN (insn))) next = next_nonnote_insn (insn);
if (next != 0 && JUMP_P (next))
{ {
rtx nextbody = PATTERN (NEXT_INSN (insn)); rtx nextbody = PATTERN (next);
/* If this label is followed by a jump-table, /* If this label is followed by a jump-table,
make sure we put the label in the read-only section. Also make sure we put the label in the read-only section. Also
...@@ -1956,7 +1958,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ...@@ -1956,7 +1958,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
targetm.asm_out.function_rodata_section (current_function_decl); targetm.asm_out.function_rodata_section (current_function_decl);
#ifdef ADDR_VEC_ALIGN #ifdef ADDR_VEC_ALIGN
log_align = ADDR_VEC_ALIGN (NEXT_INSN (insn)); log_align = ADDR_VEC_ALIGN (next);
#else #else
log_align = exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT); log_align = exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT);
#endif #endif
...@@ -1967,7 +1969,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ...@@ -1967,7 +1969,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
#ifdef ASM_OUTPUT_CASE_LABEL #ifdef ASM_OUTPUT_CASE_LABEL
ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn), ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
NEXT_INSN (insn)); next);
#else #else
targetm.asm_out.internal_label (file, "L", CODE_LABEL_NUMBER (insn)); targetm.asm_out.internal_label (file, "L", CODE_LABEL_NUMBER (insn));
#endif #endif
...@@ -2022,6 +2024,11 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ...@@ -2022,6 +2024,11 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
if (prescan > 0) if (prescan > 0)
break; break;
if (! JUMP_TABLES_IN_TEXT_SECTION)
targetm.asm_out.function_rodata_section (current_function_decl);
else
function_section (current_function_decl);
if (app_on) if (app_on)
{ {
fputs (ASM_APP_OFF, file); fputs (ASM_APP_OFF, file);
...@@ -2157,7 +2164,6 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ...@@ -2157,7 +2164,6 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
{ {
/* A delayed-branch sequence */ /* A delayed-branch sequence */
int i; int i;
rtx next;
if (prescan > 0) if (prescan > 0)
break; break;
......
2005-03-22 Jakub Jelinek <jakub@redhat.com>
PR target/20561
* gcc.dg/20050321-2.c: New test.
2005-03-22 Nathan Sidwell <nathan@codesourcery.com> 2005-03-22 Nathan Sidwell <nathan@codesourcery.com>
PR c++/20465 PR c++/20465
......
/* This testcase could not assemble on ppc32, because the compiler assumed
the huge ADDR_DIFF_VEC will be emitted into rodata section, yet because
of some notes inserted between jump table's CODE_LABEL and the jump table
it ended up in the .text section and thus shorten_branches couldn't
figure out branch to lab is too far. */
/* { dg-do link } */
/* { dg-options "-g1 -fpic" } */
#define A(n) \
case n##1: return n##1 * 131 + 63; \
case n##3: return n##3 * 1231 + 182; \
case n##5: return n##5 * 351 + 1; \
case n##7: return n##7 * 312 + 61; \
case n##9: return n##9 * 17 - 1;
#define B(n) \
A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) \
A(n##5) A(n##6) A(n##7) A(n##8) A(n##9)
#define C(n) \
B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) \
B(n##5) B(n##6) B(n##7) B(n##8) B(n##9)
#define D(n) \
C(n##0) C(n##1) B(n##20) B(n##21) B(n##22)
int
foo (int x)
{
{
lab:;
int a = x;
while (a < 60000)
{
int b = a;
{
int c = b;
switch (c)
{
D(1)
default: break;
}
}
a += 10000;
if (a == 4168)
goto lab;
}
}
return x;
}
int
main (void)
{
foo (71);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment