aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDoug Evans <devans@canuck.cygnus.com>1998-04-20 16:42:50 +0000
committerDoug Evans <devans@gcc.gnu.org>1998-04-20 16:42:50 +0000
commita9a05945da24b9ded567adcb3d81822463c82920 (patch)
tree0a1c56e419640ae571c7e34d557df873827296e8 /gcc
parentdc0f0eb82e44c834c5a0552a036d5e87c7b524aa (diff)
downloadgcc-a9a05945da24b9ded567adcb3d81822463c82920.zip
gcc-a9a05945da24b9ded567adcb3d81822463c82920.tar.gz
gcc-a9a05945da24b9ded567adcb3d81822463c82920.tar.bz2
* flow.c (sbitmap_vector_alloc): Ensure sbitmaps properly aligned.
From-SVN: r19347
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/flow.c23
2 files changed, 21 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fbac26b..871f04d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+Mon Apr 20 12:43:09 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * flow.c (sbitmap_vector_alloc): Ensure sbitmaps properly aligned.
+
Mon Apr 20 15:04:14 1998 John Wehle (john@feith.com)
* i386.md (movsf_push, movdf_push, movxf_push): Allow memory
diff --git a/gcc/flow.c b/gcc/flow.c
index 8e4da8c..d9cd761 100644
--- a/gcc/flow.c
+++ b/gcc/flow.c
@@ -3492,20 +3492,31 @@ sbitmap *
sbitmap_vector_alloc (n_vecs, n_elms)
int n_vecs, n_elms;
{
- int i, bytes, offset, elm_bytes, size, amt;
+ int i, bytes, offset, elm_bytes, size, amt, vector_bytes;
sbitmap *bitmap_vector;
size = SBITMAP_SET_SIZE (n_elms);
bytes = size * sizeof (SBITMAP_ELT_TYPE);
elm_bytes = (sizeof (struct simple_bitmap_def)
+ bytes - sizeof (SBITMAP_ELT_TYPE));
- amt = (n_vecs * sizeof (sbitmap *)) + (n_vecs * elm_bytes);
- bitmap_vector = (sbitmap *) xmalloc (amt);
+ vector_bytes = n_vecs * sizeof (sbitmap *);
- /* ??? There may be alignment problems, `offset' should be rounded up
- each time to account for alignment. Later [if ever]. */
+ /* Round up `vector_bytes' to account for the alignment requirements
+ of an sbitmap. One could allocate the vector-table and set of sbitmaps
+ separately, but that requires maintaining two pointers or creating
+ a cover struct to hold both pointers (so our result is still just
+ one pointer). Neither is a bad idea, but this is simpler for now. */
+ {
+ /* Based on DEFAULT_ALIGNMENT computation in obstack.c. */
+ struct { char x; SBITMAP_ELT_TYPE y; } align;
+ int alignment = (char *) & align.y - & align.x;
+ vector_bytes = (vector_bytes + alignment - 1) & ~ (alignment - 1);
+ }
+
+ amt = vector_bytes + (n_vecs * elm_bytes);
+ bitmap_vector = (sbitmap *) xmalloc (amt);
- for (i = 0, offset = n_vecs * sizeof (sbitmap *);
+ for (i = 0, offset = vector_bytes;
i < n_vecs;
i++, offset += elm_bytes)
{