aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2016-05-09 15:30:32 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2016-05-09 15:30:32 +0000
commitb8065b0d71545c8d7802c400231937a00134991d (patch)
tree17ca09172235f42f9b155a4381183327145e72ef
parent9f0d00a4263289606e55641297e2d5897d92a1e0 (diff)
Fix handling of negative bitpos in expand_debug_expr
expand_debug_expr handled negative bit positions using: else if (bitpos < 0) { HOST_WIDE_INT units = (-bitpos + BITS_PER_UNIT - 1) / BITS_PER_UNIT; op0 = adjust_address_nv (op0, mode1, units); bitpos += units * BITS_PER_UNIT; } Here "units" is the negative of the (negative) byte offset, so I think we should be offsetting OP0 by -units instead. E.g. a bitpos of -17 would give units==3, so this code would move OP0 up by 3 bytes and set bitpos to 7, giving a total bitpos of 31. Just noticed by inspection. An assert triggered for: gcc.target/i386/mpx/bitfields-1-lbv.c gcc.target/i386/mpx/field-addr-7-lbv.c gcc.target/i386/mpx/reference-3-lbv.cpp gcc.target/i386/mpx/reference-4-lbv.cpp at -m32 but otherwise this case doesn't seem to trigger during a bootstrap and regtest. Tested on x86_64-linux-gnu. gcc/ * cfgexpand.c (expand_debug_expr): Fix address offset for negative bitpos. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@236041 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/cfgexpand.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 85f0e6738f6..314f5f6d67f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2016-05-09 Richard Sandiford <richard.sandiford@arm.com>
+ * cfgexpand.c (expand_debug_expr): Fix address offset for negative
+ bitpos.
+
+2016-05-09 Richard Sandiford <richard.sandiford@arm.com>
+
* tree-affine.c (wide_int_constant_multiple_p): Add missing
pointer dereference.
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 21f21c97502..77a1964d4c0 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -4473,7 +4473,7 @@ expand_debug_expr (tree exp)
{
HOST_WIDE_INT units
= (-bitpos + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
- op0 = adjust_address_nv (op0, mode1, units);
+ op0 = adjust_address_nv (op0, mode1, -units);
bitpos += units * BITS_PER_UNIT;
}
else if (bitpos == 0 && bitsize == GET_MODE_BITSIZE (mode))