diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-02-06 18:26:06 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-02-06 18:26:06 +0000 |
commit | 54656ca7db7649b6d2cd2fc59dc87d52794247d6 (patch) | |
tree | 3eaf0278985aafd5a6051d562e8cbfb8b45b5baf /llvm/test/Transforms/InstSimplify/assume.ll | |
parent | c574297de631edc8ff4e7f2e7998fb76a0502f6e (diff) | |
download | bcm5719-llvm-54656ca7db7649b6d2cd2fc59dc87d52794247d6.tar.gz bcm5719-llvm-54656ca7db7649b6d2cd2fc59dc87d52794247d6.zip |
[ValueTracking] emit a remark when we detect a conflicting assumption (PR31809)
This is a follow-up to D29395 where we try to be good citizens and let the user know that
we've probably gone off the rails.
This should allow us to resolve:
https://llvm.org/bugs/show_bug.cgi?id=31809
Differential Revision: https://reviews.llvm.org/D29404
llvm-svn: 294208
Diffstat (limited to 'llvm/test/Transforms/InstSimplify/assume.ll')
-rw-r--r-- | llvm/test/Transforms/InstSimplify/assume.ll | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/llvm/test/Transforms/InstSimplify/assume.ll b/llvm/test/Transforms/InstSimplify/assume.ll index 4255238126b..66f2120f292 100644 --- a/llvm/test/Transforms/InstSimplify/assume.ll +++ b/llvm/test/Transforms/InstSimplify/assume.ll @@ -1,5 +1,10 @@ ; NOTE: Assertions have been autogenerated by update_test_checks.py -; RUN: opt -instsimplify -S < %s | FileCheck %s +; RUN: opt -instsimplify -S < %s 2>&1 -pass-remarks-analysis=.* | FileCheck %s + +; Verify that warnings are emitted for the 2nd and 3rd tests. + +; CHECK: remark: /tmp/s.c:1:13: Detected conflicting code assumptions. +; CHECK: remark: /tmp/s.c:4:10: Detected conflicting code assumptions. define void @test1() { ; CHECK-LABEL: @test1( @@ -15,12 +20,12 @@ define void @test1() { ; return value. There's no way to win (we can't undo transforms that happened ; based on half-truths), so just don't crash. -define i64 @PR31809() { +define i64 @PR31809() !dbg !7 { ; CHECK-LABEL: @PR31809( ; CHECK-NEXT: ret i64 3 ; %a = alloca i32 - %t1 = ptrtoint i32* %a to i64 + %t1 = ptrtoint i32* %a to i64, !dbg !9 %cond = icmp eq i64 %t1, 3 call void @llvm.assume(i1 %cond) ret i64 %t1 @@ -30,14 +35,14 @@ define i64 @PR31809() { ; so just don't crash. The second icmp+assume gets processed later, so that ; determines the return value. -define i8 @conflicting_assumptions(i8 %x) { +define i8 @conflicting_assumptions(i8 %x) !dbg !10 { ; CHECK-LABEL: @conflicting_assumptions( ; CHECK-NEXT: call void @llvm.assume(i1 false) ; CHECK-NEXT: [[COND2:%.*]] = icmp eq i8 %x, 4 ; CHECK-NEXT: call void @llvm.assume(i1 [[COND2]]) ; CHECK-NEXT: ret i8 5 ; - %add = add i8 %x, 1 + %add = add i8 %x, 1, !dbg !11 %cond1 = icmp eq i8 %x, 3 call void @llvm.assume(i1 %cond1) %cond2 = icmp eq i8 %x, 4 @@ -47,3 +52,21 @@ define i8 @conflicting_assumptions(i8 %x) { declare void @llvm.assume(i1) nounwind +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2) +!1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"PIC Level", i32 2} +!6 = !{!"clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)"} +!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, variables: !2) +!8 = !DISubroutineType(types: !2) +!9 = !DILocation(line: 1, column: 13, scope: !7) +!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) + |