]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add relation processing to ubsan builtins.
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 12 Jul 2021 18:38:42 +0000 (14:38 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Mon, 12 Jul 2021 23:14:30 +0000 (19:14 -0400)
Ubsan builtins call the plus/minus/multiple fold routines, but did not
use any relation information between the 2 operands that is available.
query and pass any relations.
This resolves gcc.dg/pr97505.c when operating in ranger-only mode.

* gimple-range-fold.cc (fold_using_range::range_of_builtin_ubsan_call):
Query relation between the 2 operands and use it.

gcc/gimple-range-fold.cc

index 1fa4ace32b910e0eb4ecbe96280cb13d4e8dfb41..eff5d1f89f21c7d457421f9a42700bea54aef065 100644 (file)
@@ -825,12 +825,14 @@ fold_using_range::range_of_builtin_ubsan_call (irange &r, gcall *call,
   tree arg1 = gimple_call_arg (call, 1);
   src.get_operand (ir0, arg0);
   src.get_operand (ir1, arg1);
+  // Check for any relation between arg0 and arg1.
+  relation_kind relation = src.query_relation (arg0, arg1);
 
   bool saved_flag_wrapv = flag_wrapv;
   // Pretend the arithmetic is wrapping.  If there is any overflow,
   // we'll complain, but will actually do wrapping operation.
   flag_wrapv = 1;
-  op->fold_range (r, type, ir0, ir1);
+  op->fold_range (r, type, ir0, ir1, relation);
   flag_wrapv = saved_flag_wrapv;
 
   // If for both arguments vrp_valueize returned non-NULL, this should