Retro68/gcc/gcc/ipa-ref.cc

104 lines
2.7 KiB
C++
Raw Normal View History

2012-03-27 23:13:14 +00:00
/* Interprocedural reference lists.
Copyright (C) 2010-2022 Free Software Foundation, Inc.
2012-03-27 23:13:14 +00:00
Contributed by Jan Hubicka
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
2017-04-10 11:32:00 +00:00
#include "tree.h"
2012-03-27 23:13:14 +00:00
#include "cgraph.h"
2015-08-28 15:33:40 +00:00
/* Remove reference. */
2012-03-27 23:13:14 +00:00
void
2015-08-28 15:33:40 +00:00
ipa_ref::remove_reference ()
2012-03-27 23:13:14 +00:00
{
2015-08-28 15:33:40 +00:00
struct ipa_ref_list *list = referred_ref_list ();
struct ipa_ref_list *list2 = referring_ref_list ();
2012-03-27 23:13:14 +00:00
struct ipa_ref *last;
2015-08-28 15:33:40 +00:00
gcc_assert (list->referring[referred_index] == this);
2014-09-21 17:33:12 +00:00
last = list->referring.last ();
2015-08-28 15:33:40 +00:00
if (this != last)
2012-03-27 23:13:14 +00:00
{
2015-08-28 15:33:40 +00:00
if (use == IPA_REF_ALIAS)
{
/* If deleted item is IPA_REF_ALIAS, we have to move last
item of IPA_REF_LIST type to the deleted position. After that
we replace last node with deletion slot. */
struct ipa_ref *last_alias = list->last_alias ();
if (last_alias && referred_index < last_alias->referred_index
&& last_alias != last)
{
unsigned last_alias_index = last_alias->referred_index;
list->referring[referred_index] = last_alias;
list->referring[referred_index]->referred_index = referred_index;
/* New position for replacement is previous index
of the last_alias. */
referred_index = last_alias_index;
}
}
list->referring[referred_index] = list->referring.last ();
list->referring[referred_index]->referred_index= referred_index;
2012-03-27 23:13:14 +00:00
}
2014-09-21 17:33:12 +00:00
list->referring.pop ();
2012-03-27 23:13:14 +00:00
last = &list2->references.last ();
2015-08-28 15:33:40 +00:00
struct ipa_ref *ref = this;
2012-03-27 23:13:14 +00:00
if (ref != last)
{
*ref = *last;
2015-08-28 15:33:40 +00:00
ref->referred_ref_list ()->referring[referred_index] = ref;
2012-03-27 23:13:14 +00:00
}
list2->references.pop ();
2012-03-27 23:13:14 +00:00
}
2015-08-28 15:33:40 +00:00
/* Return true when execution of reference can lead to return from
function. */
2012-03-27 23:13:14 +00:00
bool
2015-08-28 15:33:40 +00:00
ipa_ref::cannot_lead_to_return ()
2012-03-27 23:13:14 +00:00
{
2015-08-28 15:33:40 +00:00
return dyn_cast <cgraph_node *> (referring)->cannot_return_p ();
2012-03-27 23:13:14 +00:00
}
2014-09-21 17:33:12 +00:00
2015-08-28 15:33:40 +00:00
/* Return reference list this reference is in. */
2014-09-21 17:33:12 +00:00
2015-08-28 15:33:40 +00:00
struct ipa_ref_list *
ipa_ref::referring_ref_list (void)
2014-09-21 17:33:12 +00:00
{
2015-08-28 15:33:40 +00:00
return &referring->ref_list;
2014-09-21 17:33:12 +00:00
}
2015-08-28 15:33:40 +00:00
/* Return reference list this reference is in. */
2014-09-21 17:33:12 +00:00
2015-08-28 15:33:40 +00:00
struct ipa_ref_list *
ipa_ref::referred_ref_list (void)
2014-09-21 17:33:12 +00:00
{
2015-08-28 15:33:40 +00:00
return &referred->ref_list;
2014-09-21 17:33:12 +00:00
}