2010-05-09 06:15:59 +08:00
|
|
|
; RUN: opt < %s -simplifycfg -S | FileCheck %s
|
2008-10-30 01:46:26 +08:00
|
|
|
; 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"
|
|
|
|
|
2010-05-09 06:15:59 +08:00
|
|
|
define void @test1(i32 %x) nounwind {
|
2008-10-30 01:46:26 +08:00
|
|
|
entry:
|
|
|
|
%0 = icmp eq i32 %x, 0 ; <i1> [#uses=1]
|
|
|
|
br i1 %0, label %bb, label %return
|
|
|
|
|
|
|
|
bb: ; preds = %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load volatile i32, i32* null
|
2008-10-30 01:46:26 +08:00
|
|
|
unreachable
|
2010-05-09 06:15:59 +08:00
|
|
|
|
2008-10-30 01:46:26 +08:00
|
|
|
br label %return
|
|
|
|
return: ; preds = %entry
|
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
2011-08-13 06:50:01 +08:00
|
|
|
; CHECK: load volatile
|
2010-05-09 06:15:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; rdar://7958343
|
|
|
|
define void @test2() nounwind {
|
|
|
|
entry:
|
|
|
|
store i32 4,i32* null
|
|
|
|
ret void
|
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
2016-06-25 16:19:55 +08:00
|
|
|
; CHECK: call void @llvm.trap
|
2010-05-09 06:15:59 +08:00
|
|
|
; CHECK: unreachable
|
2008-10-30 01:46:26 +08:00
|
|
|
}
|
2010-06-14 00:16:54 +08:00
|
|
|
|
|
|
|
; PR7369
|
|
|
|
define void @test3() nounwind {
|
|
|
|
entry:
|
2011-08-13 06:50:01 +08:00
|
|
|
store volatile i32 4, i32* null
|
2010-06-14 00:16:54 +08:00
|
|
|
ret void
|
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
2011-08-13 06:50:01 +08:00
|
|
|
; CHECK: store volatile i32 4, i32* null
|
2010-06-14 00:16:54 +08:00
|
|
|
; CHECK: ret
|
|
|
|
}
|
2011-08-16 07:59:28 +08:00
|
|
|
|
|
|
|
; Check store before unreachable.
|
|
|
|
define void @test4(i1 %C, i32* %P) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test4(
|
2011-08-16 07:59:28 +08:00
|
|
|
; 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) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test5(
|
2011-08-16 07:59:28 +08:00
|
|
|
; CHECK: entry:
|
|
|
|
; CHECK-NEXT: br i1 %C
|
|
|
|
entry:
|
|
|
|
br i1 %C, label %T, label %F
|
|
|
|
T:
|
2014-03-11 18:48:52 +08:00
|
|
|
cmpxchg volatile i32* %P, i32 0, i32 1 seq_cst seq_cst
|
2011-08-16 07:59:28 +08:00
|
|
|
unreachable
|
|
|
|
F:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Check atomicrmw before unreachable.
|
|
|
|
define void @test6(i1 %C, i32* %P) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test6(
|
2011-08-16 07:59:28 +08:00
|
|
|
; 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
|
|
|
|
}
|
|
|
|
|