diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-12-10 07:44:18 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-12-10 07:44:18 +0000 |
commit | 9ffeb5ce2127b8a371bb27556bd7f719aac8fb1c (patch) | |
tree | c3243146716e433a79445edc57aef3842b72177b | |
parent | 0ebcc56542aa91fe5bf2d7a9d2406824d65c08be (diff) | |
download | gcc-9ffeb5ce2127b8a371bb27556bd7f719aac8fb1c.tar.gz |
* asan.c (instrument_derefs): Handle bitfield COMPONENT_REFs
accesses as reads/writes to their DECL_BIT_FIELD_REPRESENTATIVE.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194344 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/asan.c | 15 |
2 files changed, 16 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c2f13d2a728..41f4116c05b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2012-12-10 Jakub Jelinek <jakub@redhat.com> + + * asan.c (instrument_derefs): Handle bitfield COMPONENT_REFs + accesses as reads/writes to their DECL_BIT_FIELD_REPRESENTATIVE. + 2012-12-08 Eric Botcazou <ebotcazou@adacore.com> * lto-streamer-out.c (lto_write_tree): Do not reset the DECL_INITIAL of diff --git a/gcc/asan.c b/gcc/asan.c index 41c5c3345f8..b8f36cb5851 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -797,9 +797,6 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, || (unsigned HOST_WIDE_INT) size_in_bytes - 1 >= 16) return; - /* For now just avoid instrumenting bit field acceses. - Fixing it is doable, but expected to be messy. */ - HOST_WIDE_INT bitsize, bitpos; tree offset; enum machine_mode mode; @@ -808,7 +805,17 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, &mode, &unsignedp, &volatilep, false); if (bitpos % (size_in_bytes * BITS_PER_UNIT) || bitsize != size_in_bytes * BITS_PER_UNIT) - return; + { + if (TREE_CODE (t) == COMPONENT_REF + && DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1)) != NULL_TREE) + { + tree repr = DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1)); + instrument_derefs (iter, build3 (COMPONENT_REF, TREE_TYPE (repr), + TREE_OPERAND (t, 0), repr, + NULL_TREE), location, is_store); + } + return; + } base = build_fold_addr_expr (t); build_check_stmt (location, base, iter, /*before_p=*/true, |