blob: 83b40c68d45c27d3074e06c448271980cfe282de [file] [log] [blame]
Sanjoy Das04071082016-01-29 00:28:57 +00001; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
Philip Reames63294cb2015-04-26 19:48:03 +00002
3; constants don't get relocated.
Sanjoy Das04071082016-01-29 00:28:57 +00004@G = addrspace(1) global i8 5
5
6declare void @foo()
7
Philip Reames63294cb2015-04-26 19:48:03 +00008define i8 @test() gc "statepoint-example" {
9; CHECK-LABEL: @test
10; CHECK: gc.statepoint
11; CHECK-NEXT: load i8, i8 addrspace(1)* inttoptr (i64 15 to i8 addrspace(1)*)
Sanjoy Das04071082016-01-29 00:28:57 +000012; Mostly just here to show reasonable code test can come from.
Philip Reames63294cb2015-04-26 19:48:03 +000013entry:
Sanjoy Das04071082016-01-29 00:28:57 +000014 call void @foo() [ "deopt"() ]
Philip Reames63294cb2015-04-26 19:48:03 +000015 %res = load i8, i8 addrspace(1)* inttoptr (i64 15 to i8 addrspace(1)*)
16 ret i8 %res
17}
18
Philip Reames63294cb2015-04-26 19:48:03 +000019define i8 @test2(i8 addrspace(1)* %p) gc "statepoint-example" {
20; CHECK-LABEL: @test2
21; CHECK: gc.statepoint
22; CHECK-NEXT: gc.relocate
23; CHECK-NEXT: icmp
Sanjoy Das04071082016-01-29 00:28:57 +000024; Globals don't move and thus don't get relocated
Philip Reames63294cb2015-04-26 19:48:03 +000025entry:
Sanjoy Das04071082016-01-29 00:28:57 +000026 call void @foo() [ "deopt"() ]
Philip Reames63294cb2015-04-26 19:48:03 +000027 %cmp = icmp eq i8 addrspace(1)* %p, null
28 br i1 %cmp, label %taken, label %not_taken
29
Sanjoy Das04071082016-01-29 00:28:57 +000030taken: ; preds = %not_taken, %entry
Philip Reames63294cb2015-04-26 19:48:03 +000031 ret i8 0
32
Sanjoy Das04071082016-01-29 00:28:57 +000033not_taken: ; preds = %entry
Philip Reames63294cb2015-04-26 19:48:03 +000034 %cmp2 = icmp ne i8 addrspace(1)* %p, null
35 br i1 %cmp2, label %taken, label %dead
36
Sanjoy Das04071082016-01-29 00:28:57 +000037dead: ; preds = %not_taken
Philip Reames63294cb2015-04-26 19:48:03 +000038 %addr = getelementptr i8, i8 addrspace(1)* %p, i32 15
Sanjoy Das04071082016-01-29 00:28:57 +000039 %res = load i8, i8 addrspace(1)* %addr
Philip Reames63294cb2015-04-26 19:48:03 +000040 ret i8 %res
41}
42
Philip Reames63294cb2015-04-26 19:48:03 +000043define i8 @test3(i1 %always_true) gc "statepoint-example" {
44; CHECK-LABEL: @test3
45; CHECK: gc.statepoint
46; CHECK-NEXT: load i8, i8 addrspace(1)* @G
47entry:
Sanjoy Das04071082016-01-29 00:28:57 +000048 call void @foo() [ "deopt"() ]
Philip Reames63294cb2015-04-26 19:48:03 +000049 %res = load i8, i8 addrspace(1)* @G, align 1
50 ret i8 %res
51}