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