From: Jan Hubicka <hubicka@ucw.cz>
To: Ilya Enkovich <enkovich.gnu@gmail.com>
Cc: Jan Hubicka <hubicka@ucw.cz>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH, CHKP] Fix static const bounds creation in LTO
Date: Fri, 03 Apr 2015 17:01:00 -0000 [thread overview]
Message-ID: <20150403170110.GL21276@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <20150403161131.GB61994@msticlxl57.ims.intel.com>
>
> Thanks a lot for looking into it! Seems originally I mostly got problems due to no DECL_WEAK for generated var, make_decl_one_only seems to work for my tests. Will run more testing to make sure it's OK. Here is a new patch version. Is it OK?
Good ;)
> diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
> index 03f75b3..4daeab6 100644
> --- a/gcc/tree-chkp.c
> +++ b/gcc/tree-chkp.c
> @@ -1876,26 +1876,17 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi)
> /* Return constant static bounds var with specified LB and UB
> if such var exists in varpool. Return NULL otherwise. */
> static tree
> -chkp_find_const_bounds_var (HOST_WIDE_INT lb,
> - HOST_WIDE_INT ub)
> +chkp_find_const_bounds_var (tree id)
> {
> - tree val = targetm.chkp_make_bounds_constant (lb, ub);
> - struct varpool_node *node;
> -
> - /* We expect bounds constant is represented as a complex value
> - of two pointer sized integers. */
> - gcc_assert (TREE_CODE (val) == COMPLEX_CST);
> + struct symtab_node *node = symtab_node::get_for_asmname (id);
Sadly I think this won't work on targets that adds prefix to assembler name,
like djgpp/mingw.
To obtain mangled assembler name you need to call
id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
that in turn requires decl to already exist. That is why I guess you may want
to just build the new var and see if already exists....
Honza
>
> - FOR_EACH_VARIABLE (node)
> - if (POINTER_BOUNDS_P (node->decl)
> - && TREE_READONLY (node->decl)
> - && DECL_INITIAL (node->decl)
> - && TREE_CODE (DECL_INITIAL (node->decl)) == COMPLEX_CST
> - && tree_int_cst_equal (TREE_REALPART (DECL_INITIAL (node->decl)),
> - TREE_REALPART (val))
> - && tree_int_cst_equal (TREE_IMAGPART (DECL_INITIAL (node->decl)),
> - TREE_IMAGPART (val)))
> + if (node)
> + {
> + /* We don't allow this symbol usage for non bounds. */
> + gcc_assert (node->type == SYMTAB_VARIABLE);
> + gcc_assert (POINTER_BOUNDS_P (node->decl));
> return node->decl;
> + }
>
> return NULL;
> }
> @@ -1907,37 +1898,34 @@ chkp_make_static_const_bounds (HOST_WIDE_INT lb,
> HOST_WIDE_INT ub,
> const char *name)
> {
> + tree id = get_identifier (name);
> tree var;
> + varpool_node *node;
>
> /* With LTO we may have constant bounds already in varpool.
> Try to find it. */
> - var = chkp_find_const_bounds_var (lb, ub);
> + var = chkp_find_const_bounds_var (id);
>
> if (var)
> return var;
>
> - var = build_decl (UNKNOWN_LOCATION, VAR_DECL,
> - get_identifier (name), pointer_bounds_type_node);
> + var = build_decl (UNKNOWN_LOCATION, VAR_DECL, id,
> + pointer_bounds_type_node);
>
> - TREE_PUBLIC (var) = 1;
> TREE_USED (var) = 1;
> TREE_READONLY (var) = 1;
> TREE_STATIC (var) = 1;
> TREE_ADDRESSABLE (var) = 0;
> DECL_ARTIFICIAL (var) = 1;
> DECL_READ_P (var) = 1;
> + DECL_INITIAL (var) = targetm.chkp_make_bounds_constant (lb, ub);
> + make_decl_one_only (var, DECL_ASSEMBLER_NAME (var));
> /* We may use this symbol during ctors generation in chkp_finish_file
> when all symbols are emitted. Force output to avoid undefined
> symbols in ctors. */
> - if (!in_lto_p)
> - {
> - DECL_INITIAL (var) = targetm.chkp_make_bounds_constant (lb, ub);
> - DECL_COMDAT (var) = 1;
> - varpool_node::get_create (var)->set_comdat_group (DECL_ASSEMBLER_NAME (var));
> - varpool_node::get_create (var)->force_output = 1;
> - }
> - else
> - DECL_EXTERNAL (var) = 1;
> + node = varpool_node::get_create (var);
> + node->force_output = 1;
> +
> varpool_node::finalize_decl (var);
>
> return var;
next prev parent reply other threads:[~2015-04-03 17:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-02 15:22 Ilya Enkovich
2015-04-02 20:45 ` Jan Hubicka
2015-04-03 16:11 ` Ilya Enkovich
2015-04-03 17:01 ` Jan Hubicka [this message]
2015-04-07 8:10 ` Ilya Enkovich
2015-04-07 20:43 ` Jan Hubicka
2015-04-08 19:39 ` Ilya Enkovich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150403170110.GL21276@atrey.karlin.mff.cuni.cz \
--to=hubicka@ucw.cz \
--cc=enkovich.gnu@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).