https://llvm.org/bugs/show_bug.cgi?id=31882

            Bug ID: 31882
           Summary: print a remark when an llvm.assume has a false param
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: spatel+l...@rotateright.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

Filing this based on Daniel's example in:
https://reviews.llvm.org/D29404

declare void @llvm.assume(i1) nounwind
define i32 @assume_false(i32 %p) {
entry:
   %cmp = icmp eq i32 %p, 42
   call void @llvm.assume(i1 %cmp)
   br i1 %cmp, label %bb2, label %bb3
bb2:
   %cmp3 = icmp eq i32 %p, 43
   call void @llvm.assume(i1 %cmp3)
   ret i32 15
bb3:
   ret i32 17
}

-----------------------------------------------------------------------

-instsimplify tells us that the 2nd icmp is false via isKnownNonEqual() which
calls computeKnownBits() which calls computeKnownBitsFromAssume():

$ ./opt -instsimplify badass.ll -S
...
declare void @llvm.assume(i1) #0

define i32 @assume_false(i32 %p) {
entry:
  %cmp = icmp eq i32 %p, 42
  call void @llvm.assume(i1 %cmp)
  br i1 %cmp, label %bb2, label %bb3

bb2:                          
  call void @llvm.assume(i1 false)   <--- oops...alternative facts!
  ret i32 15

bb3:    
  ret i32 17
}


--------------------------------------------------------------------------

As mentioned in D29404, we can't print a strong warning, but we can at least
print a weasel-worded remark because it's likely that either the program or the
compiler has a bug when a condition that was supposed to be true was proven
false.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to