]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/lto/lto-symtab.h
Update copyright years.
[thirdparty/gcc.git] / gcc / lto / lto-symtab.h
CommitLineData
6b9ac179 1/* LTO symbol table merging.
7adcbafe 2 Copyright (C) 2009-2022 Free Software Foundation, Inc.
6b9ac179
JH
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20extern void lto_symtab_merge_decls (void);
21extern void lto_symtab_merge_symbols (void);
22extern tree lto_symtab_prevailing_decl (tree decl);
3fddb2ef 23extern tree lto_symtab_prevailing_virtual_decl (tree decl);
6b9ac179
JH
24
25/* Mark DECL to be previailed by PREVAILING.
63e434ca 26 Use DECL_LANG_FLAG_0 and DECL_CHAIN as special markers; those do not
6b9ac179 27 disturb debug_tree and diagnostics.
56aae4b7 28 We are safe to modify them as we wish, because the declarations disappear
6b9ac179
JH
29 from the IL after the merging. */
30
31inline void
32lto_symtab_prevail_decl (tree prevailing, tree decl)
33{
63e434ca 34 gcc_checking_assert (! DECL_LANG_FLAG_0 (decl));
3fddb2ef 35 gcc_assert (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl));
6b9ac179 36 DECL_CHAIN (decl) = prevailing;
63e434ca 37 DECL_LANG_FLAG_0 (decl) = 1;
6b9ac179
JH
38}
39
40/* Given the decl DECL, return the prevailing decl with the same name. */
41
42inline tree
43lto_symtab_prevailing_decl (tree decl)
44{
63e434ca 45 if (DECL_LANG_FLAG_0 (decl))
6b9ac179
JH
46 return DECL_CHAIN (decl);
47 else
3fddb2ef
JH
48 {
49 if ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
50 && DECL_VIRTUAL_P (decl)
51 && (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
52 && !symtab_node::get (decl))
53 return lto_symtab_prevailing_virtual_decl (decl);
54 return decl;
55 }
6b9ac179 56}