[PATCH] D43052: [ValueTracking] don't crash when assumptions conflict (PR36270)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 8 06:55:03 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324610: [ValueTracking] don't crash when assumptions conflict (PR36270) (authored by spatel, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43052?vs=133334&id=133415#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43052
Files:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/test/Transforms/InstSimplify/assume.ll
Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -816,6 +816,14 @@
KnownBits RHSKnown(BitWidth);
computeKnownBits(A, RHSKnown, Depth+1, Query(Q, I));
+ // If the RHS is known zero, then this assumption must be wrong (nothing
+ // is unsigned less than zero). Signal a conflict and get out of here.
+ if (RHSKnown.isZero()) {
+ Known.Zero.setAllBits();
+ Known.One.setAllBits();
+ break;
+ }
+
// Whatever high bits in c are zero are known to be zero (if c is a power
// of 2, then one more).
if (isKnownToBeAPowerOfTwo(A, false, Depth + 1, Query(Q, I)))
Index: llvm/trunk/test/Transforms/InstSimplify/assume.ll
===================================================================
--- llvm/trunk/test/Transforms/InstSimplify/assume.ll
+++ llvm/trunk/test/Transforms/InstSimplify/assume.ll
@@ -5,6 +5,7 @@
; CHECK: remark: /tmp/s.c:1:13: Detected conflicting code assumptions.
; CHECK: remark: /tmp/s.c:4:10: Detected conflicting code assumptions.
+; CHECK: remark: /tmp/s.c:5:50: Detected conflicting code assumptions.
define void @test1() {
; CHECK-LABEL: @test1(
@@ -50,6 +51,24 @@
ret i8 %add
}
+; Another case of conflicting assumptions. This would crash because we'd
+; try to set more known bits than existed in the known bits struct.
+
+define void @PR36270(i32 %b) !dbg !13 {
+; CHECK-LABEL: @PR36270(
+; CHECK-NEXT: tail call void @llvm.assume(i1 false)
+; CHECK-NEXT: unreachable
+;
+ %B7 = xor i32 -1, 2147483647
+ %and1 = and i32 %b, 3
+ %B12 = lshr i32 %B7, %and1, !dbg !14
+ %C1 = icmp ult i32 %and1, %B12
+ tail call void @llvm.assume(i1 %C1)
+ %cmp2 = icmp eq i32 0, %B12
+ tail call void @llvm.assume(i1 %cmp2)
+ unreachable
+}
+
declare void @llvm.assume(i1) nounwind
!llvm.dbg.cu = !{!0}
@@ -69,4 +88,6 @@
!10 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, variables: !2)
!11 = !DILocation(line: 4, column: 10, scope: !10)
!12 = !DILocation(line: 4, column: 3, scope: !10)
+!13 = distinct !DISubprogram(name: "PR36270", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, variables: !2)
+!14 = !DILocation(line: 5, column: 50, scope: !13)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43052.133415.patch
Type: text/x-patch
Size: 2511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180208/b0911858/attachment.bin>
More information about the llvm-commits
mailing list