[Bug tree-optimization/84011] Optimize switch table with run-time relocation
rguenther at suse dot de
gcc-bugzilla@gcc.gnu.org
Wed Jan 24 14:33:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84011
--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> ---
On Wed, 24 Jan 2018, hjl.tools at gmail dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84011
>
> H.J. Lu <hjl.tools at gmail dot com> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |jakub at redhat dot com
> Depends on| |36881
>
> --- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
> The code in question is done on purpose:
>
> commit 54af7f7e3f0f38a4cd5667fda9fd9a68ad554df0
> Author: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
> Date: Wed Oct 15 06:43:19 2008 +0000
>
> PR tree-optimization/36881
> * tree-switch-conversion.c (check_final_bb): For flag_pic, check
> that each value doesn't need runtime relocations, for !flag_pic
> check that each value is just a valid initializer constant.
>
> * gcc.dg/tree-ssa/pr36881.c: New test.
>
>
> git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141129
> 138bc75d-0d04-0410-961f-82ee72b054a4
>
> Should we revisit this decision?
We could add a hook to allow the target to override. Like
targetm.avoid_runtime_relocations_p () or runtime_relocations_expensive_p
() or just (as it seems for SPU) runtime_relocations_supported_p ()?
As said ideally we'd simply avoid creating relocations for string
constants or other constant initializers. Maybe that's even possible
in some weird ways via using section labels/addresses? Thus make
the table contain
.Lstring1 - .section_start_of_where_Lstring1_is,
...
and thus a constant initializer using some extension to query that
section start or even the offset -- __builtin_offset_from_section_start
("foo")?
More information about the Gcc-bugs
mailing list