diff options
-rw-r--r-- | gcc/asan.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/asan.c b/gcc/asan.c index 6e3e1f3d4c8..884fd458bc2 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -645,12 +645,19 @@ handle_builtin_alloca (gimple call, gimple_stmt_iterator *iter) align = MAX (align, ASAN_RED_ZONE_SIZE * BITS_PER_UNIT); tree alloca_rz_mask = build_int_cst (size_type_node, redzone_mask); + tree redzone_size = build_int_cst (size_type_node, ASAN_RED_ZONE_SIZE); - /* partial_size = size & (ASAN_RED_ZONE_SIZE - 1). */ + /* misalign = size & (ASAN_RED_ZONE_SIZE - 1) + partial_size = ASAN_RED_ZONE_SIZE - misalign. */ g = gimple_build_assign_with_ops (BIT_AND_EXPR, make_ssa_name (size_type_node, NULL), old_size, alloca_rz_mask); gimple_seq_add_stmt_without_update (&seq, g); + tree misalign = gimple_assign_lhs (g); + g = gimple_build_assign_with_ops (MINUS_EXPR, + make_ssa_name (size_type_node, NULL), + redzone_size, misalign); + gimple_seq_add_stmt_without_update (&seq, g); tree partial_size = gimple_assign_lhs (g); /* padding = align + ASAN_RED_ZONE_SIZE; |