summaryrefslogtreecommitdiff
path: root/gcc/asan.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-02-12 12:23:08 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2019-02-12 12:23:08 +0000
commitc4d5763224c7817ad5cb671e651e69b2708d49f0 (patch)
tree984a6629a81e3e7fba97e199c1de44dd7ac97c73 /gcc/asan.c
parentbaaf860b3364f2efac1cb04a1430f82f867768ef (diff)
asan.c (asan_expand_mark_ifn): Take into account the alignment of the object to pick the size of stores on...
* asan.c (asan_expand_mark_ifn): Take into account the alignment of the object to pick the size of stores on strict-alignment platforms. * config/sparc/sparc.md (*movsi_insn): Minor tweak. (*movdi_insn_sp32): Likewise. (*movdi_insn_sp64): Likewise. From-SVN: r268792
Diffstat (limited to 'gcc/asan.c')
-rw-r--r--gcc/asan.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/asan.c b/gcc/asan.c
index f7986d89f83..65b12473c00 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -3218,7 +3218,10 @@ asan_expand_mark_ifn (gimple_stmt_iterator *iter)
/* Generate direct emission if size_in_bytes is small. */
if (size_in_bytes <= ASAN_PARAM_USE_AFTER_SCOPE_DIRECT_EMISSION_THRESHOLD)
{
- unsigned HOST_WIDE_INT shadow_size = shadow_mem_size (size_in_bytes);
+ const unsigned HOST_WIDE_INT shadow_size
+ = shadow_mem_size (size_in_bytes);
+ const unsigned int shadow_align
+ = (get_pointer_alignment (base) / BITS_PER_UNIT) >> ASAN_SHADOW_SHIFT;
tree shadow = build_shadow_mem_access (iter, loc, base_addr,
shadow_ptr_types[0], true);
@@ -3226,9 +3229,11 @@ asan_expand_mark_ifn (gimple_stmt_iterator *iter)
for (unsigned HOST_WIDE_INT offset = 0; offset < shadow_size;)
{
unsigned size = 1;
- if (shadow_size - offset >= 4)
+ if (shadow_size - offset >= 4
+ && (!STRICT_ALIGNMENT || shadow_align >= 4))
size = 4;
- else if (shadow_size - offset >= 2)
+ else if (shadow_size - offset >= 2
+ && (!STRICT_ALIGNMENT || shadow_align >= 2))
size = 2;
unsigned HOST_WIDE_INT last_chunk_size = 0;