diff options
author | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2019-10-17 08:59:06 +0000 |
---|---|---|
committer | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2019-10-17 08:59:06 +0000 |
commit | b6534b2a26fa94e4d09d271faf538b1e4b19ab5d (patch) | |
tree | 25ee0b58dd14629264918953c2a0b1fdd64eb932 /clang/lib/CodeGen/CGVTables.cpp | |
parent | 312c4a6e248988a6aca72b47667c25636a319602 (diff) | |
download | bcm5719-llvm-b6534b2a26fa94e4d09d271faf538b1e4b19ab5d.tar.gz bcm5719-llvm-b6534b2a26fa94e4d09d271faf538b1e4b19ab5d.zip |
[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
llvm-svn: 375089
Diffstat (limited to 'clang/lib/CodeGen/CGVTables.cpp')
0 files changed, 0 insertions, 0 deletions