Mikhail Maltsev
faeea2dc5e
[Analysis] Don't assume that unsigned overflow can't happen in EmitGEPOffset (PR42699)
...
Summary:
Currently when computing a GEP offset using the function EmitGEPOffset
for the following instruction
getelementptr inbounds i32, i32* %p, i64 %offs
we get
mul nuw i64 %offs, 4
Unfortunately we cannot assume that unsigned wrapping won't happen
here because %offs is allowed to be negative.
Making such assumptions can lead to miscompilations: see the new test
test24_neg_offs in InstCombine/icmp.ll. Without the patch InstCombine
would generate the following comparison:
icmp eq i64 %offs, 4611686018427387902; 0x3ffffffffffffffe
Whereas the correct value to compare with is -2.
This patch replaces the NUW flag with NSW in the multiplication
instructions generated by EmitGEPOffset and adjusts the test suite.
https://bugs.llvm.org/show_bug.cgi?id=42699
Reviewers: chandlerc, craig.topper, ostannard, lebedev.ri, spatel, efriedma, nlopes, aqjune
Reviewed By: lebedev.ri
Subscribers: reames, lebedev.ri, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68342
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375089 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-17 08:59:06 +00:00
..
2019-07-16 15:28:29 +00:00
2019-04-17 04:52:47 +00:00
2019-10-11 05:30:18 +00:00
2019-08-23 02:17:04 +00:00
2019-08-03 14:28:34 +00:00
2019-06-17 09:51:07 +00:00
2019-04-17 04:52:47 +00:00
2019-08-20 14:46:02 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-05-29 16:59:48 +00:00
2019-04-17 04:52:47 +00:00
2019-07-10 16:32:20 +00:00
2019-10-14 16:15:14 +00:00
2019-07-09 10:56:18 +00:00
2019-04-17 04:52:47 +00:00
2019-10-13 17:34:08 +00:00
2019-08-15 00:48:51 +00:00
2019-10-11 03:48:56 +00:00
2019-04-17 04:52:47 +00:00
2019-10-04 17:03:46 +00:00
2019-07-28 06:09:56 +00:00
2019-07-28 06:09:56 +00:00
2019-09-29 15:25:24 +00:00
2019-08-07 14:34:41 +00:00
2019-04-17 04:52:47 +00:00
2019-08-16 23:30:16 +00:00
2019-09-10 10:39:09 +00:00
2019-09-19 16:31:17 +00:00
2019-04-17 04:52:47 +00:00
2019-10-13 21:25:53 +00:00
2019-09-10 23:15:38 +00:00
2019-04-17 04:52:47 +00:00
2019-10-14 23:25:25 +00:00
2019-04-17 04:52:47 +00:00
2019-08-09 12:43:25 +00:00
2019-04-17 04:52:47 +00:00
2019-04-18 19:17:14 +00:00
2019-09-03 17:31:19 +00:00
2019-04-17 04:52:47 +00:00
2019-06-28 19:57:31 +00:00
2019-10-16 10:55:06 +00:00
2019-10-04 22:46:42 +00:00
2019-04-17 04:52:47 +00:00
2019-10-16 20:27:10 +00:00
2019-09-05 02:20:39 +00:00
2019-10-08 15:25:56 +00:00
2019-09-20 23:29:17 +00:00
2019-10-17 08:59:06 +00:00
2019-09-05 17:00:32 +00:00
2019-04-17 04:52:47 +00:00
2019-10-02 12:12:02 +00:00
2019-04-17 04:52:47 +00:00
2019-10-14 23:25:25 +00:00
2019-04-17 04:52:47 +00:00
2019-09-12 21:32:27 +00:00
2019-08-03 14:28:34 +00:00
2019-04-17 04:52:47 +00:00
2019-10-03 22:20:04 +00:00
2019-08-02 04:03:37 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-07-07 22:12:01 +00:00
2019-09-26 21:42:45 +00:00
2019-10-14 19:46:34 +00:00
2019-08-21 17:00:57 +00:00
2019-09-11 08:23:23 +00:00
2019-06-12 13:50:47 +00:00
2019-07-09 01:27:45 +00:00
2019-06-17 10:05:18 +00:00
2019-08-21 17:00:57 +00:00
2019-06-19 10:50:47 +00:00
2019-04-17 04:52:47 +00:00
2019-06-19 16:02:54 +00:00
2019-04-17 04:52:47 +00:00
2019-09-26 21:40:27 +00:00
2019-04-17 04:52:47 +00:00
2019-07-15 21:16:29 +00:00
2019-10-17 07:55:55 +00:00
2019-06-12 14:05:58 +00:00
2019-05-29 20:47:59 +00:00
2019-05-23 17:03:43 +00:00
2019-10-14 16:15:14 +00:00
2019-09-11 16:19:50 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-06-03 17:54:15 +00:00
2019-10-03 23:42:44 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-10-10 21:30:43 +00:00
2019-08-03 14:28:34 +00:00
2019-05-23 12:35:26 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-10-15 17:25:36 +00:00
2019-09-19 20:58:51 +00:00
2019-04-17 04:52:47 +00:00
2019-09-30 18:11:22 +00:00
2019-09-27 19:32:43 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-08-23 15:49:38 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-07-24 00:16:23 +00:00
2019-10-09 21:36:03 +00:00
2019-08-07 23:16:29 +00:00
2019-09-07 12:16:14 +00:00
2019-07-31 18:22:22 +00:00
2019-06-17 09:51:07 +00:00
2019-10-14 23:52:39 +00:00
2019-09-18 19:46:57 +00:00
2019-04-17 04:52:47 +00:00
2019-10-16 18:06:24 +00:00
2019-08-14 16:44:07 +00:00
2019-05-14 16:51:18 +00:00
2019-10-15 04:32:07 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-05-24 08:59:17 +00:00
2019-04-17 04:52:47 +00:00
2019-04-17 04:52:47 +00:00
2019-08-09 22:31:59 +00:00
2019-09-26 15:20:17 +00:00
2019-08-03 14:28:34 +00:00