This is the mail archive of the gcc-patches@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]

[PATCH, alpha]: Fix g++.dg/other/pr22003.C ICE


Hello!

This ICE exposes the problem with generation of thunks with -freorder-blocks-and-partition. The problem is, that function data, needed to switch sections (i.e. names of hot and cold sections), is not available any more after free_after_compilation is called throuh ASM_DECLARE_FUNCTION_SIZE macro (aka alpha_end_function). free_after_compilation is called in order to free data that was allocated by our specific way that thunks are generated (see alpha_emit_mi_thunk_osf). alpha_end_function that scans insn stream is called throuh ASM_DECLARE_FUNCTION_SIZE macro, so insn stream that is allocated by alpha_emit_mi_thunk can be released no earlier than after the insn scan loop in alpha_end_function.

However, when -freorder-blocks-and-partition is in effect, compilation still needs crtl data to output section labels and switch sections after ASM_DECLARE_FUNCTION_SIZE is called (see assemble_end_function in varasm.c). Calling free_after_compilation from alpha_end_function is thus wrong.

Attached patch fixes this problem by freeing just crtl->emit structure that is populated by alpha_emit_mi_thunk_osf, preserving other function data. The crtl structure is still cleared by "*clean_state" pass, so there is no leakage.

Also, emit_insn function needs insn locators (make insn_locator calls curr_insn_locator), so this patch moves insn locator initialization before the first call of emit_insn, and frees locators after all insn processing is done in alpha_end_function. Oh, and we are sure that alpha_output_mi_thunk_osf always processes thunks so assert is not needed ;)

2009-08-18 Uros Bizjak <ubizjak@gmail.com>

    * config/alpha/alpha.c (alpha_output_mi_thunk_osf): Allocate insn
    locators before emit_insn is called.  Remove assert that
    cfun->is_thunk.
    (alpha_end_function): Clear crtl->emit structure and free insn
    locators if cfun->is_thunk is true.

The patch was bootstrapped and regression tested on alphaev68-linux-gnu and fixes:

FAIL: g++.dg/other/pr22003.C (internal compiler error)
FAIL: g++.dg/other/pr22003.C (test for excess errors)

OK for mainline, 4.4 and 4.3 ?

Uros.

Attachment: a.diff.txt
Description: Text document


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