1. [Analysis] Don't assume that unsigned overflow can't happen in (details)
  2. Try to fix the assert in Alignment::alignAddr to work on 32-bit (details)
Commit b6534b2a26fa94e4d09d271faf538b1e4b19ab5d by mikhail.maltsev
[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.
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:
llvm-svn: 375089
The file was modifiedllvm/test/Transforms/InstCombine/gep-custom-dl.ll
The file was modifiedllvm/test/Transforms/InstCombine/icmp.ll
The file was modifiedllvm/test/Transforms/InstCombine/icmp-custom-dl.ll
The file was modifiedllvm/test/Transforms/InstCombine/getelementptr.ll
The file was modifiedllvm/include/llvm/Analysis/Utils/Local.h
The file was modifiedllvm/test/Transforms/InstCombine/sub.ll
Commit 77cad0b047e3c56e7205c5880fe57354d2d4867c by hans
Try to fix the assert in Alignment::alignAddr to work on 32-bit
Hopefully fixing the AlignmentDeathTest.AlignAddr failures (e.g. at
llvm-svn: 375090
The file was modifiedllvm/include/llvm/Support/Alignment.h