summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Saunders <tsaunders@mozilla.com>2013-12-26 12:12:59 -0500
committerTrevor Saunders <tsaunders@mozilla.com>2014-02-18 22:44:35 -0500
commit5bb1e738296db790df782a851053f3ec0f7a5f2a (patch)
tree218a17d70a5f8c560312c42d3b5bb3b019c70d9e
parentd431ff3b93be64394ac9c95a3c49968c850c2809 (diff)
downloadgcc-5bb1e738296db790df782a851053f3ec0f7a5f2a.tar.gz
add bitmap_head::swap
-rw-r--r--gcc/bitmap.c10
-rw-r--r--gcc/bitmap.h2
-rw-r--r--gcc/df-problems.c22
-rw-r--r--gcc/ira.c2
4 files changed, 20 insertions, 16 deletions
diff --git a/gcc/bitmap.c b/gcc/bitmap.c
index 9d8ebc74558..dfebc11adca 100644
--- a/gcc/bitmap.c
+++ b/gcc/bitmap.c
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#include "system.h"
#include "coretypes.h"
+#include <utility>
#include "obstack.h"
#include "ggc.h"
#include "bitmap.h"
@@ -2223,5 +2224,14 @@ debug (const bitmap_head *ptr)
fprintf (stderr, "<nil>\n");
}
+void
+bitmap_head::swap (bitmap_head *other)
+{
+ other->indx = indx = 0;
+ other->current = current = NULL;
+ std::swap (other->descriptor_id, descriptor_id);
+ std::swap (other->first, first);
+ std::swap (other->obstack, obstack);
+}
#include "gt-bitmap.h"
diff --git a/gcc/bitmap.h b/gcc/bitmap.h
index 98da3c11f6d..d6f2be57d55 100644
--- a/gcc/bitmap.h
+++ b/gcc/bitmap.h
@@ -199,6 +199,8 @@ struct GTY(()) bitmap_head {
}
~bitmap_head () { bitmap_clear (this); }
+ void swap (bitmap_head *);
+
unsigned int indx; /* Index of last element looked at. */
unsigned int descriptor_id; /* Unique identifier for the allocation
site of this bitmap, for detailed
diff --git a/gcc/df-problems.c b/gcc/df-problems.c
index 9149eda6d34..1d4476471bb 100644
--- a/gcc/df-problems.c
+++ b/gcc/df-problems.c
@@ -534,9 +534,7 @@ df_rd_transfer_function (int bb_index)
if (changed)
{
bitmap_clear (out);
- bb_info->out = tmp;
- // kind of hacky but hopefully that'll be fixed by more c++ification
- tmp.first = tmp.current = NULL;
+ tmp.swap (&bb_info->out);
}
else
bitmap_clear (&tmp);
@@ -1284,8 +1282,6 @@ df_lr_verify_transfer_functions (void)
if (!df)
return;
- bitmap_head saved_def;
- bitmap_head saved_use;
bitmap_head all_blocks;
FOR_ALL_BB_FN (bb, cfun)
{
@@ -1300,10 +1296,9 @@ df_lr_verify_transfer_functions (void)
if (!bitmap_bit_p (df_lr->out_of_date_transfer_functions,
bb->index))
{
- bitmap_copy (&saved_def, &bb_info->def);
- bitmap_copy (&saved_use, &bb_info->use);
- bitmap_clear (&bb_info->def);
- bitmap_clear (&bb_info->use);
+ bitmap_head saved_def, saved_use;
+ saved_def.swap (&bb_info->def);
+ saved_use.swap (&bb_info->use);
df_lr_bb_local_compute (bb->index);
gcc_assert (bitmap_equal_p (&saved_def, &bb_info->def));
@@ -1820,8 +1815,6 @@ df_live_verify_transfer_functions (void)
if (!df)
return;
- bitmap_head saved_gen;
- bitmap_head saved_kill;
bitmap_head all_blocks;
df_grow_insn_info ();
@@ -1838,10 +1831,9 @@ df_live_verify_transfer_functions (void)
if (!bitmap_bit_p (df_live->out_of_date_transfer_functions,
bb->index))
{
- bitmap_copy (&saved_gen, &bb_info->gen);
- bitmap_copy (&saved_kill, &bb_info->kill);
- bitmap_clear (&bb_info->gen);
- bitmap_clear (&bb_info->kill);
+ bitmap_head saved_gen, saved_kill;
+ saved_gen.swap (&bb_info->gen);
+ saved_kill.swap (&bb_info->kill);
df_live_bb_local_compute (bb->index);
gcc_assert (bitmap_equal_p (&saved_gen, &bb_info->gen));
diff --git a/gcc/ira.c b/gcc/ira.c
index 32134b8e23a..c9078014dd9 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -4529,7 +4529,7 @@ find_moveable_pseudos (void)
bitmap_head live (*df_get_live_out (bb));
bitmap_and_into (&live, df_get_live_in (bb));
- bitmap_copy (transp, &live);
+ transp->swap (&live);
bitmap_head set;
FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn))