Imported Upstream version 5.18.0.234

Former-commit-id: 8071ec1a8c5eaa9be24b41745add19297608001f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-01-08 08:22:36 +00:00
parent f32dbaf0b2
commit 212f6bafcb
28494 changed files with 359 additions and 3867025 deletions

View File

@@ -1,386 +0,0 @@
; RUN: opt -S -bdce -instsimplify < %s | FileCheck %s
; RUN: opt -S -instsimplify < %s | FileCheck %s -check-prefix=CHECK-IO
target datalayout = "E-m:e-i64:64-n32:64"
target triple = "powerpc64-unknown-linux-gnu"
; Function Attrs: nounwind readnone
define signext i32 @bar(i32 signext %x) #0 {
entry:
%call = tail call signext i32 @foo(i32 signext 5) #0
%and = and i32 %call, 4
%or = or i32 %and, %x
%call1 = tail call signext i32 @foo(i32 signext 3) #0
%and2 = and i32 %call1, 8
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @foo(i32 signext 2) #0
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @foo(i32 signext 1) #0
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @foo(i32 signext 0) #0
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @foo(i32 signext 4) #0
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%shr = ashr i32 %or15, 4
ret i32 %shr
; CHECK-LABEL: @bar
; CHECK-NOT: tail call signext i32 @foo(i32 signext 5)
; CHECK-NOT: tail call signext i32 @foo(i32 signext 3)
; CHECK: tail call signext i32 @foo(i32 signext 2)
; CHECK: tail call signext i32 @foo(i32 signext 1)
; CHECK: tail call signext i32 @foo(i32 signext 0)
; CHECK: tail call signext i32 @foo(i32 signext 4)
; CHECK: ret i32
; Check that instsimplify is not doing this all on its own.
; CHECK-IO-LABEL: @bar
; CHECK-IO: tail call signext i32 @foo(i32 signext 5)
; CHECK-IO: tail call signext i32 @foo(i32 signext 3)
; CHECK-IO: tail call signext i32 @foo(i32 signext 2)
; CHECK-IO: tail call signext i32 @foo(i32 signext 1)
; CHECK-IO: tail call signext i32 @foo(i32 signext 0)
; CHECK-IO: tail call signext i32 @foo(i32 signext 4)
; CHECK-IO: ret i32
}
; Function Attrs: nounwind readnone
declare signext i32 @foo(i32 signext) #0
; Function Attrs: nounwind readnone
define signext i32 @far(i32 signext %x) #1 {
entry:
%call = tail call signext i32 @goo(i32 signext 5) #1
%and = and i32 %call, 4
%or = or i32 %and, %x
%call1 = tail call signext i32 @goo(i32 signext 3) #1
%and2 = and i32 %call1, 8
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @goo(i32 signext 2) #1
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @goo(i32 signext 1) #1
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @goo(i32 signext 0) #1
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @goo(i32 signext 4) #1
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%shr = ashr i32 %or15, 4
ret i32 %shr
; CHECK-LABEL: @far
; Calls to foo(5) and foo(3) are still there, but their results are not used.
; CHECK: tail call signext i32 @goo(i32 signext 5)
; CHECK-NEXT: tail call signext i32 @goo(i32 signext 3)
; CHECK-NEXT: tail call signext i32 @goo(i32 signext 2)
; CHECK: tail call signext i32 @goo(i32 signext 1)
; CHECK: tail call signext i32 @goo(i32 signext 0)
; CHECK: tail call signext i32 @goo(i32 signext 4)
; CHECK: ret i32
; Check that instsimplify is not doing this all on its own.
; CHECK-IO-LABEL: @far
; CHECK-IO: tail call signext i32 @goo(i32 signext 5)
; CHECK-IO: tail call signext i32 @goo(i32 signext 3)
; CHECK-IO: tail call signext i32 @goo(i32 signext 2)
; CHECK-IO: tail call signext i32 @goo(i32 signext 1)
; CHECK-IO: tail call signext i32 @goo(i32 signext 0)
; CHECK-IO: tail call signext i32 @goo(i32 signext 4)
; CHECK-IO: ret i32
}
declare signext i32 @goo(i32 signext) #1
; Function Attrs: nounwind readnone
define signext i32 @tar1(i32 signext %x) #0 {
entry:
%call = tail call signext i32 @foo(i32 signext 5) #0
%and = and i32 %call, 33554432
%or = or i32 %and, %x
%call1 = tail call signext i32 @foo(i32 signext 3) #0
%and2 = and i32 %call1, 67108864
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @foo(i32 signext 2) #0
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @foo(i32 signext 1) #0
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @foo(i32 signext 0) #0
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @foo(i32 signext 4) #0
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%bs = tail call i32 @llvm.bswap.i32(i32 %or15) #0
%shr = ashr i32 %bs, 4
ret i32 %shr
; CHECK-LABEL: @tar1
; CHECK-NOT: tail call signext i32 @foo(i32 signext 5)
; CHECK-NOT: tail call signext i32 @foo(i32 signext 3)
; CHECK: tail call signext i32 @foo(i32 signext 2)
; CHECK: tail call signext i32 @foo(i32 signext 1)
; CHECK: tail call signext i32 @foo(i32 signext 0)
; CHECK: tail call signext i32 @foo(i32 signext 4)
; CHECK: ret i32
}
; Function Attrs: nounwind readnone
declare i32 @llvm.bswap.i32(i32) #0
; Function Attrs: nounwind readnone
define signext i32 @tim(i32 signext %x) #0 {
entry:
%call = tail call signext i32 @foo(i32 signext 5) #0
%and = and i32 %call, 536870912
%or = or i32 %and, %x
%call1 = tail call signext i32 @foo(i32 signext 3) #0
%and2 = and i32 %call1, 1073741824
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @foo(i32 signext 2) #0
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @foo(i32 signext 1) #0
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @foo(i32 signext 0) #0
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @foo(i32 signext 4) #0
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%bs = tail call i32 @llvm.bitreverse.i32(i32 %or15) #0
%shr = ashr i32 %bs, 4
ret i32 %shr
; CHECK-LABEL: @tim
; CHECK-NOT: tail call signext i32 @foo(i32 signext 5)
; CHECK-NOT: tail call signext i32 @foo(i32 signext 3)
; CHECK: tail call signext i32 @foo(i32 signext 2)
; CHECK: tail call signext i32 @foo(i32 signext 1)
; CHECK: tail call signext i32 @foo(i32 signext 0)
; CHECK: tail call signext i32 @foo(i32 signext 4)
; CHECK: ret i32
}
; Function Attrs: nounwind readnone
declare i32 @llvm.bitreverse.i32(i32) #0
; Function Attrs: nounwind readnone
define signext i32 @tar2(i32 signext %x) #0 {
entry:
%call = tail call signext i32 @foo(i32 signext 5) #0
%and = and i32 %call, 33554432
%or = or i32 %and, %x
%call1 = tail call signext i32 @foo(i32 signext 3) #0
%and2 = and i32 %call1, 67108864
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @foo(i32 signext 2) #0
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @foo(i32 signext 1) #0
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @foo(i32 signext 0) #0
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @foo(i32 signext 4) #0
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%shl = shl i32 %or15, 10
ret i32 %shl
; CHECK-LABEL: @tar2
; CHECK-NOT: tail call signext i32 @foo(i32 signext 5)
; CHECK-NOT: tail call signext i32 @foo(i32 signext 3)
; CHECK: tail call signext i32 @foo(i32 signext 2)
; CHECK: tail call signext i32 @foo(i32 signext 1)
; CHECK: tail call signext i32 @foo(i32 signext 0)
; CHECK: tail call signext i32 @foo(i32 signext 4)
; CHECK: ret i32
}
; Function Attrs: nounwind readnone
define signext i32 @tar3(i32 signext %x) #0 {
entry:
%call = tail call signext i32 @foo(i32 signext 5) #0
%and = and i32 %call, 33554432
%or = or i32 %and, %x
%call1 = tail call signext i32 @foo(i32 signext 3) #0
%and2 = and i32 %call1, 67108864
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @foo(i32 signext 2) #0
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @foo(i32 signext 1) #0
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @foo(i32 signext 0) #0
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @foo(i32 signext 4) #0
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%add = add i32 %or15, 5
%shl = shl i32 %add, 10
ret i32 %shl
; CHECK-LABEL: @tar3
; CHECK-NOT: tail call signext i32 @foo(i32 signext 5)
; CHECK-NOT: tail call signext i32 @foo(i32 signext 3)
; CHECK: tail call signext i32 @foo(i32 signext 2)
; CHECK: tail call signext i32 @foo(i32 signext 1)
; CHECK: tail call signext i32 @foo(i32 signext 0)
; CHECK: tail call signext i32 @foo(i32 signext 4)
; CHECK: ret i32
}
; Function Attrs: nounwind readnone
define signext i32 @tar4(i32 signext %x) #0 {
entry:
%call = tail call signext i32 @foo(i32 signext 5) #0
%and = and i32 %call, 33554432
%or = or i32 %and, %x
%call1 = tail call signext i32 @foo(i32 signext 3) #0
%and2 = and i32 %call1, 67108864
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @foo(i32 signext 2) #0
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @foo(i32 signext 1) #0
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @foo(i32 signext 0) #0
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @foo(i32 signext 4) #0
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%sub = sub i32 %or15, 5
%shl = shl i32 %sub, 10
ret i32 %shl
; CHECK-LABEL: @tar4
; CHECK-NOT: tail call signext i32 @foo(i32 signext 5)
; CHECK-NOT: tail call signext i32 @foo(i32 signext 3)
; CHECK: tail call signext i32 @foo(i32 signext 2)
; CHECK: tail call signext i32 @foo(i32 signext 1)
; CHECK: tail call signext i32 @foo(i32 signext 0)
; CHECK: tail call signext i32 @foo(i32 signext 4)
; CHECK: ret i32
}
; Function Attrs: nounwind readnone
define signext i32 @tar5(i32 signext %x) #0 {
entry:
%call = tail call signext i32 @foo(i32 signext 5) #0
%and = and i32 %call, 33554432
%or = or i32 %and, %x
%call1 = tail call signext i32 @foo(i32 signext 3) #0
%and2 = and i32 %call1, 67108864
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @foo(i32 signext 2) #0
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @foo(i32 signext 1) #0
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @foo(i32 signext 0) #0
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @foo(i32 signext 4) #0
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%xor = xor i32 %or15, 5
%shl = shl i32 %xor, 10
ret i32 %shl
; CHECK-LABEL: @tar5
; CHECK-NOT: tail call signext i32 @foo(i32 signext 5)
; CHECK-NOT: tail call signext i32 @foo(i32 signext 3)
; CHECK: tail call signext i32 @foo(i32 signext 2)
; CHECK: tail call signext i32 @foo(i32 signext 1)
; CHECK: tail call signext i32 @foo(i32 signext 0)
; CHECK: tail call signext i32 @foo(i32 signext 4)
; CHECK: ret i32
}
; Function Attrs: nounwind readnone
define signext i32 @tar7(i32 signext %x, i1 %b) #0 {
entry:
%call = tail call signext i32 @foo(i32 signext 5) #0
%and = and i32 %call, 33554432
%or = or i32 %and, %x
%call1 = tail call signext i32 @foo(i32 signext 3) #0
%and2 = and i32 %call1, 67108864
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @foo(i32 signext 2) #0
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @foo(i32 signext 1) #0
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @foo(i32 signext 0) #0
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @foo(i32 signext 4) #0
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%v = select i1 %b, i32 %or15, i32 5
%shl = shl i32 %v, 10
ret i32 %shl
; CHECK-LABEL: @tar7
; CHECK-NOT: tail call signext i32 @foo(i32 signext 5)
; CHECK-NOT: tail call signext i32 @foo(i32 signext 3)
; CHECK: tail call signext i32 @foo(i32 signext 2)
; CHECK: tail call signext i32 @foo(i32 signext 1)
; CHECK: tail call signext i32 @foo(i32 signext 0)
; CHECK: tail call signext i32 @foo(i32 signext 4)
; CHECK: ret i32
}
; Function Attrs: nounwind readnone
define signext i16 @tar8(i32 signext %x) #0 {
entry:
%call = tail call signext i32 @foo(i32 signext 5) #0
%and = and i32 %call, 33554432
%or = or i32 %and, %x
%call1 = tail call signext i32 @foo(i32 signext 3) #0
%and2 = and i32 %call1, 67108864
%or3 = or i32 %or, %and2
%call4 = tail call signext i32 @foo(i32 signext 2) #0
%and5 = and i32 %call4, 16
%or6 = or i32 %or3, %and5
%call7 = tail call signext i32 @foo(i32 signext 1) #0
%and8 = and i32 %call7, 32
%or9 = or i32 %or6, %and8
%call10 = tail call signext i32 @foo(i32 signext 0) #0
%and11 = and i32 %call10, 64
%or12 = or i32 %or9, %and11
%call13 = tail call signext i32 @foo(i32 signext 4) #0
%and14 = and i32 %call13, 128
%or15 = or i32 %or12, %and14
%tr = trunc i32 %or15 to i16
ret i16 %tr
; CHECK-LABEL: @tar8
; CHECK-NOT: tail call signext i32 @foo(i32 signext 5)
; CHECK-NOT: tail call signext i32 @foo(i32 signext 3)
; CHECK: tail call signext i32 @foo(i32 signext 2)
; CHECK: tail call signext i32 @foo(i32 signext 1)
; CHECK: tail call signext i32 @foo(i32 signext 0)
; CHECK: tail call signext i32 @foo(i32 signext 4)
; CHECK: ret i16
}
attributes #0 = { nounwind readnone }
attributes #1 = { nounwind }

View File

@@ -1,47 +0,0 @@
; Test that BDCE doesn't destroy llvm.dbg.value's argument.
; RUN: opt -bdce %s -S | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; CHECK: define void @f()
; CHECK-NEXT: entry:
; CHECK-NEXT: tail call void (...) @h()
; CHECK-NEXT: %[[CALL:.*]] = tail call i32 (...) @g()
; CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 %[[CALL:.*]]
define void @f() !dbg !6 {
entry:
tail call void (...) @h(), !dbg !9
%call = tail call i32 (...) @g(), !dbg !10
tail call void @llvm.dbg.value(metadata i32 %call, metadata !11, metadata !13), !dbg !14
%patatino = xor i32 %call, %call
tail call void (...) @h(), !dbg !15
ret void, !dbg !16
}
declare void @h(...)
declare i32 @g(...)
declare void @llvm.dbg.value(metadata, metadata, metadata)
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4}
!llvm.ident = !{!5}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 288665) (llvm/trunk 288725)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "patatino.c", directory: "/home/davide/work/llvm/build-clang/bin")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{!"clang version 4.0.0 (trunk 288665) (llvm/trunk 288725)"}
!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !7, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: false, unit: !0, variables: !2)
!7 = !DISubroutineType(types: !8)
!8 = !{null}
!9 = !DILocation(line: 4, column: 3, scope: !6)
!10 = !DILocation(line: 5, column: 11, scope: !6)
!11 = !DILocalVariable(name: "a", scope: !6, file: !1, line: 5, type: !12)
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!13 = !DIExpression()
!14 = !DILocation(line: 5, column: 7, scope: !6)
!15 = !DILocation(line: 6, column: 3, scope: !6)
!16 = !DILocation(line: 7, column: 1, scope: !6)

View File

@@ -1,34 +0,0 @@
; RUN: opt -bdce -S < %s | FileCheck %s
; RUN: opt -passes=bdce -S < %s | FileCheck %s
declare i32 @strlen(i8*) readonly nounwind
define void @test1() {
call i32 @strlen( i8* null )
ret void
; CHECK-LABEL: @test1
; CHECK-NOT: call
; CHECK: ret void
}
define i32 @test2() personality i32 (...)* @__gxx_personality_v0 {
; invoke of pure function should not be deleted!
invoke i32 @strlen( i8* null ) readnone
to label %Cont unwind label %Other
Cont: ; preds = %0
ret i32 0
Other: ; preds = %0
%exn = landingpad {i8*, i32}
cleanup
ret i32 1
; CHECK-LABEL: @test2
; CHECK: invoke
; CHECK: ret i32 1
}
declare i32 @__gxx_personality_v0(...)

View File

@@ -1,18 +0,0 @@
; RUN: opt -S -bdce < %s | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"
define void @PR34211(i16* %p) {
; CHECK-LABEL: @PR34211
%not_demanded_but_not_dead = load volatile i16, i16* %p
call void @no_side_effects_so_dead(i16 %not_demanded_but_not_dead)
ret void
; CHECK: %not_demanded_but_not_dead = load volatile i16, i16* %p
; CHECK-NEXT: ret void
}
declare void @no_side_effects_so_dead(i16) #0
attributes #0 = { nounwind readnone }

View File

@@ -1,100 +0,0 @@
; RUN: opt -bdce %s -S | FileCheck %s
; The 'nuw' on the subtract allows us to deduce that %setbit is not demanded.
; But if we change that value to '0', then the 'nuw' is no longer valid. If we don't
; remove the 'nuw', another pass (-instcombine) may make a transform based on an
; that incorrect assumption and we can miscompile:
; https://bugs.llvm.org/show_bug.cgi?id=33695
define i1 @PR33695(i1 %b, i8 %x) {
; CHECK-LABEL: @PR33695(
; CHECK-NEXT: [[SETBIT:%.*]] = or i8 %x, 64
; CHECK-NEXT: [[LITTLE_NUMBER:%.*]] = zext i1 %b to i8
; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl i8 0, 1
; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[BIG_NUMBER]], [[LITTLE_NUMBER]]
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[SUB]] to i1
; CHECK-NEXT: ret i1 [[TRUNC]]
;
%setbit = or i8 %x, 64
%little_number = zext i1 %b to i8
%big_number = shl i8 %setbit, 1
%sub = sub nuw i8 %big_number, %little_number
%trunc = trunc i8 %sub to i1
ret i1 %trunc
}
; Similar to above, but now with more no-wrap.
; https://bugs.llvm.org/show_bug.cgi?id=34037
define i64 @PR34037(i64 %m, i32 %r, i64 %j, i1 %b, i32 %k, i64 %p) {
; CHECK-LABEL: @PR34037(
; CHECK-NEXT: [[CONV:%.*]] = zext i32 %r to i64
; CHECK-NEXT: [[AND:%.*]] = and i64 %m, 0
; CHECK-NEXT: [[NEG:%.*]] = xor i64 0, 34359738367
; CHECK-NEXT: [[OR:%.*]] = or i64 %j, 0
; CHECK-NEXT: [[SHL:%.*]] = shl i64 0, 29
; CHECK-NEXT: [[CONV1:%.*]] = select i1 %b, i64 7, i64 0
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[SHL]], [[CONV1]]
; CHECK-NEXT: [[CONV2:%.*]] = zext i32 %k to i64
; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[SUB]], [[CONV2]]
; CHECK-NEXT: [[CONV4:%.*]] = and i64 %p, 65535
; CHECK-NEXT: [[AND5:%.*]] = and i64 [[MUL]], [[CONV4]]
; CHECK-NEXT: ret i64 [[AND5]]
;
%conv = zext i32 %r to i64
%and = and i64 %m, %conv
%neg = xor i64 %and, 34359738367
%or = or i64 %j, %neg
%shl = shl i64 %or, 29
%conv1 = select i1 %b, i64 7, i64 0
%sub = sub nuw nsw i64 %shl, %conv1
%conv2 = zext i32 %k to i64
%mul = mul nsw i64 %sub, %conv2
%conv4 = and i64 %p, 65535
%and5 = and i64 %mul, %conv4
ret i64 %and5
}
; This is a manufactured example based on the 1st test to prove that the
; assumption-killing algorithm stops at the call. Ie, it does not remove
; nsw/nuw from the 'add' because a call demands all bits of its argument.
declare i1 @foo(i1)
define i1 @poison_on_call_user_is_ok(i1 %b, i8 %x) {
; CHECK-LABEL: @poison_on_call_user_is_ok(
; CHECK-NEXT: [[SETBIT:%.*]] = or i8 %x, 64
; CHECK-NEXT: [[LITTLE_NUMBER:%.*]] = zext i1 %b to i8
; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl i8 0, 1
; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[BIG_NUMBER]], [[LITTLE_NUMBER]]
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[SUB]] to i1
; CHECK-NEXT: [[CALL_RESULT:%.*]] = call i1 @foo(i1 [[TRUNC]])
; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i1 [[CALL_RESULT]], true
; CHECK-NEXT: [[MUL:%.*]] = mul i1 [[TRUNC]], [[ADD]]
; CHECK-NEXT: ret i1 [[MUL]]
;
%setbit = or i8 %x, 64
%little_number = zext i1 %b to i8
%big_number = shl i8 %setbit, 1
%sub = sub nuw i8 %big_number, %little_number
%trunc = trunc i8 %sub to i1
%call_result = call i1 @foo(i1 %trunc)
%add = add nsw nuw i1 %call_result, 1
%mul = mul i1 %trunc, %add
ret i1 %mul
}
; We were asserting that all users of a trivialized integer-type instruction were
; also integer-typed, but that's too strong. The alloca has a pointer-type result.
define void @PR34179(i32* %a) {
; CHECK-LABEL: @PR34179(
; CHECK-NEXT: [[T0:%.*]] = load volatile i32, i32* %a
; CHECK-NEXT: ret void
;
%t0 = load volatile i32, i32* %a
%vla = alloca i32, i32 %t0
ret void
}

View File

@@ -1,37 +0,0 @@
; RUN: opt -bdce -S < %s | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
declare i32 @__gxx_personality_v0(...)
define fastcc void @_ZN11__sanitizerL12TestRegistryEPNS_14ThreadRegistryEb() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
entry:
br i1 undef, label %if.else, label %entry.if.end_crit_edge
if.else:
ret void
invoke.cont70:
store i32 %call71, i32* undef, align 4
br label %if.else
; CHECK-LABEL: @_ZN11__sanitizerL12TestRegistryEPNS_14ThreadRegistryEb
; CHECK: store i32 %call71
lpad65.loopexit.split-lp.loopexit.split-lp:
br label %if.else
lpad65.loopexit.split-lp.loopexit.split-lp.loopexit:
%lpad.loopexit1121 = landingpad { i8*, i32 }
cleanup
br label %lpad65.loopexit.split-lp.loopexit.split-lp
entry.if.end_crit_edge:
%call71 = invoke i32 @_ZN11__sanitizer14ThreadRegistry12CreateThreadEmbjPv()
to label %invoke.cont70 unwind label %lpad65.loopexit.split-lp.loopexit.split-lp.loopexit
}
declare i32 @_ZN11__sanitizer14ThreadRegistry12CreateThreadEmbjPv()
attributes #0 = { uwtable }

View File

@@ -1,46 +0,0 @@
; Test that BDCE doesn't destroy llvm.dbg.value's argument.
; RUN: opt -bdce %s -S | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; CHECK: define void @f()
; CHECK-NEXT: entry:
; CHECK-NEXT: tail call void (...) @h()
; CHECK-NEXT: %[[CALL:.*]] = tail call i32 (...) @g()
; CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 %[[CALL:.*]]
define void @f() !dbg !6 {
entry:
tail call void (...) @h(), !dbg !9
%call = tail call i32 (...) @g(), !dbg !10
tail call void @llvm.dbg.value(metadata i32 %call, metadata !11, metadata !13), !dbg !14
tail call void (...) @h(), !dbg !15
ret void, !dbg !16
}
declare void @h(...)
declare i32 @g(...)
declare void @llvm.dbg.value(metadata, metadata, metadata)
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4}
!llvm.ident = !{!5}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 288665) (llvm/trunk 288725)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "patatino.c", directory: "/home/davide/work/llvm/build-clang/bin")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{!"clang version 4.0.0 (trunk 288665) (llvm/trunk 288725)"}
!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !7, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: false, unit: !0, variables: !2)
!7 = !DISubroutineType(types: !8)
!8 = !{null}
!9 = !DILocation(line: 4, column: 3, scope: !6)
!10 = !DILocation(line: 5, column: 11, scope: !6)
!11 = !DILocalVariable(name: "a", scope: !6, file: !1, line: 5, type: !12)
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!13 = !DIExpression()
!14 = !DILocation(line: 5, column: 7, scope: !6)
!15 = !DILocation(line: 6, column: 3, scope: !6)
!16 = !DILocation(line: 7, column: 1, scope: !6)