aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-03-21 08:22:57 +0000
committerJakub Jelinek <jakub@redhat.com>2017-03-21 08:22:57 +0000
commited16871bacf0ebb27ff1f7ce099596a401dac953 (patch)
tree8889793db5e33901cecca403528c78c5981029d3
parentfea92ef7f4d6f814506b89ba28b9aa2760039983 (diff)
PR sanitizer/78158
* tsan.c (instrument_builtin_call): If the memory model argument is not a constant, assume it is valid. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@246306 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/tsan.c16
2 files changed, 12 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 59be61f58e0..62c63c46a08 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2017-03-21 Jakub Jelinek <jakub@redhat.com>
+ PR sanitizer/78158
+ * tsan.c (instrument_builtin_call): If the memory model argument
+ is not a constant, assume it is valid.
+
PR c/67338
* fold-const.c (round_up_loc): Negate divisor in unsigned type to
avoid UB.
diff --git a/gcc/tsan.c b/gcc/tsan.c
index 2d4ec74cb81..5e5961f4bda 100644
--- a/gcc/tsan.c
+++ b/gcc/tsan.c
@@ -499,8 +499,8 @@ instrument_builtin_call (gimple_stmt_iterator *gsi)
case check_last:
case fetch_op:
last_arg = gimple_call_arg (stmt, num - 1);
- if (!tree_fits_uhwi_p (last_arg)
- || memmodel_base (tree_to_uhwi (last_arg)) >= MEMMODEL_LAST)
+ if (tree_fits_uhwi_p (last_arg)
+ && memmodel_base (tree_to_uhwi (last_arg)) >= MEMMODEL_LAST)
return;
gimple_call_set_fndecl (stmt, decl);
update_stmt (stmt);
@@ -564,11 +564,11 @@ instrument_builtin_call (gimple_stmt_iterator *gsi)
gcc_assert (num == 6);
for (j = 0; j < 6; j++)
args[j] = gimple_call_arg (stmt, j);
- if (!tree_fits_uhwi_p (args[4])
- || memmodel_base (tree_to_uhwi (args[4])) >= MEMMODEL_LAST)
+ if (tree_fits_uhwi_p (args[4])
+ && memmodel_base (tree_to_uhwi (args[4])) >= MEMMODEL_LAST)
return;
- if (!tree_fits_uhwi_p (args[5])
- || memmodel_base (tree_to_uhwi (args[5])) >= MEMMODEL_LAST)
+ if (tree_fits_uhwi_p (args[5])
+ && memmodel_base (tree_to_uhwi (args[5])) >= MEMMODEL_LAST)
return;
update_gimple_call (gsi, decl, 5, args[0], args[1], args[2],
args[4], args[5]);
@@ -642,8 +642,8 @@ instrument_builtin_call (gimple_stmt_iterator *gsi)
return;
}
last_arg = gimple_call_arg (stmt, num - 1);
- if (!tree_fits_uhwi_p (last_arg)
- || memmodel_base (tree_to_uhwi (last_arg)) >= MEMMODEL_LAST)
+ if (tree_fits_uhwi_p (last_arg)
+ && memmodel_base (tree_to_uhwi (last_arg)) >= MEMMODEL_LAST)
return;
t = TYPE_ARG_TYPES (TREE_TYPE (decl));
t = TREE_VALUE (TREE_CHAIN (t));