reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
; RUN: opt < %s -simplifycfg -S | FileCheck %s
; PR2967

target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32"
target triple = "i386-pc-linux-gnu"

define void @test1(i32 %x) nounwind {
entry:
        %0 = icmp eq i32 %x, 0          ; <i1> [#uses=1]
        br i1 %0, label %bb, label %return

bb:             ; preds = %entry
        %1 = load volatile i32, i32* null
        unreachable
        
        br label %return
return:         ; preds = %entry
        ret void
; CHECK-LABEL: @test1(
; CHECK: load volatile
}

define void @test1_no_null_opt(i32 %x) nounwind #0 {
entry:
        %0 = icmp eq i32 %x, 0          ; <i1> [#uses=1]
        br i1 %0, label %bb, label %return

bb:             ; preds = %entry
        %1 = load volatile i32, i32* null
        unreachable

        br label %return
return:         ; preds = %entry
        ret void
; CHECK-LABEL: @test1_no_null_opt(
; CHECK: load volatile
; CHECK: unreachable
}

; rdar://7958343
define void @test2() nounwind {
entry:
        store i32 4,i32* null
        ret void

; CHECK-LABEL: @test2(
; CHECK: call void @llvm.trap
; CHECK: unreachable
}

define void @test2_no_null_opt() nounwind #0 {
entry:
        store i32 4,i32* null
        ret void
; CHECK-LABEL: @test2_no_null_opt(
; CHECK: store i32 4, i32* null
; CHECK-NOT: call void @llvm.trap
; CHECK: ret
}

; PR7369
define void @test3() nounwind {
entry:
        store volatile i32 4, i32* null
        ret void

; CHECK-LABEL: @test3(
; CHECK: store volatile i32 4, i32* null
; CHECK: ret
}

define void @test3_no_null_opt() nounwind #0 {
entry:
        store volatile i32 4, i32* null
        ret void

; CHECK-LABEL: @test3_no_null_opt(
; CHECK: store volatile i32 4, i32* null
; CHECK: ret
}

; Check store before unreachable.
define void @test4(i1 %C, i32* %P) {
; CHECK-LABEL: @test4(
; CHECK: entry:
; CHECK-NEXT: br i1 %C
entry:
  br i1 %C, label %T, label %F
T:
  store volatile i32 0, i32* %P
  unreachable
F:
  ret void
}

; Check cmpxchg before unreachable.
define void @test5(i1 %C, i32* %P) {
; CHECK-LABEL: @test5(
; CHECK: entry:
; CHECK-NEXT: br i1 %C
entry:
  br i1 %C, label %T, label %F
T:
  cmpxchg volatile i32* %P, i32 0, i32 1 seq_cst seq_cst
  unreachable
F:
  ret void
}

; Check atomicrmw before unreachable.
define void @test6(i1 %C, i32* %P) {
; CHECK-LABEL: @test6(
; CHECK: entry:
; CHECK-NEXT: br i1 %C
entry:
  br i1 %C, label %T, label %F
T:
  atomicrmw volatile xchg i32* %P, i32 0 seq_cst
  unreachable
F:
  ret void
}

attributes #0 = { "null-pointer-is-valid"="true" }