User account creation filtered due to spam.

Bug 43746 - -fmerge-constants and -fmerge-all-constants don't work at AVR target
Summary: -fmerge-constants and -fmerge-all-constants don't work at AVR target
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.5
: P3 enhancement
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
: 21018 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-04-13 08:23 UTC by Tomasz Francuz
Modified: 2011-09-12 10:16 UTC (History)
5 users (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-07-14 07:52:52


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Francuz 2010-04-13 08:23:36 UTC
-fmerge-all-constants and –fmerge-constants don’t work at AVR target.
Example:
const char text1[] PROGMEM=”Test”;
const char text2[] PROGMEM=”Test”;

will still produce duplicated “Test” string in generated code.
Comment 1 Joerg Wunsch 2010-04-13 08:31:34 UTC
I think this is essentially a duplicate of bug #21018.
Comment 2 Tomasz Francuz 2010-04-14 20:45:41 UTC
Yes, it seems that you are right. I mark it as duplicate of bug #21018

*** This bug has been marked as a duplicate of 21018 ***
Comment 3 Eric Weddington 2010-09-20 19:53:46 UTC
Reopening this enhancement request. Bug #21018, which this was marked a duplicate of, is now marked as WONTFIX.
Comment 4 Georg-Johann Lay 2011-07-14 07:49:19 UTC
Author: gjl
Date: Thu Jul 14 07:49:14 2011
New Revision: 176262

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176262
Log:
gcc/
	PR target/43746
	* config/avr/elf.h (TARGET_ASM_SELECT_SECTION): Remove,
	i.e. use default_elf_select_section.
	(TARGET_HAVE_SWITCHABLE_BSS_SECTIONS): Remove.
	(READONLY_DATA_SECTION_ASM_OP): Remove.
	(TARGET_ASM_NAMED_SECTION): Move from here...
	* config/avr/avr.c: ...to here.
	(avr_asm_init_sections): Set unnamed callback of
	readonly_data_section.
	(avr_asm_named_section): Make static.
	
testsuite/
	PR target/43746
	* gcc.dg/array-quals-1.c: Don't xfail on AVR.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.c
    trunk/gcc/config/avr/elf.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/array-quals-1.c
Comment 5 Georg-Johann Lay 2011-07-14 07:52:52 UTC
Set the status to NEW.

The above patch fixes constant merging for constants in .rodata which is mapped into RAM for AVR.

To make it work for .progmem (data in Flash) requires a seperate patch.
Comment 6 Georg-Johann Lay 2011-08-03 19:40:32 UTC
*** Bug 21018 has been marked as a duplicate of this bug. ***
Comment 7 Georg-Johann Lay 2011-09-12 10:06:52 UTC
Author: gjl
Date: Mon Sep 12 10:06:46 2011
New Revision: 178779

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178779
Log:
gcc/
	PR target/43746
	* config/avr/avr.c (AVR_SECTION_PROGMEM): New Define.
	(progmem_section): New Variable.
	(avr_asm_init_sections): Initialize it.
	(TARGET_ASM_SELECT_SECTION): Define to...
	(avr_asm_select_section): ... this new Function.
	(avr_replace_prefix): New Function.
	(avr_asm_function_rodata_section): Use it.
	(avr_insert_attributes): Don't add section attribute for PROGMEM.
	(avr_section_type_flags): Use avr_progmem_p instead of section
	name to detect if object is in PROGMEM.
	(avr_asm_named_section): Set section name prefix for objects in
	PROGMEM.

testsuite/
	PR target/43746
	* testsuite/gcc.target/avr/torture/avr-torture.exp
	(AVR_TORTURE_OPTIONS): Add test cases "-O2 -fdata-sections" and
	"-O2 -fmerge-all-constants".


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp
Comment 8 Georg-Johann Lay 2011-09-12 10:16:25 UTC
Closed as fixed for 4.7 Milestone.

Initially I intended to add a -fprogmem-sections command line option that works similar but independent to -fdata-section.  That way data sections could be used and strings in progmem merged.  However, I did not find a straight forward way without cluttering avr BE with lots of code from varasm.c.  Thus, for now, there is no -fprogmem-sections, i.e. progmem-sections are in sync with data-sections and you have to decide wether you prefer string merging or fine grained sections.