aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp/testdata/consteval.ll
blob: 05d377f1b61d9925758253b8bbd63bcbb24bffde (plain)
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
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64--linux"

@intToPtrResult = global i8 0
@ptrToIntResult = global i8 0
@icmpResult = global i8 0
@someArray = internal global {i16, i8, i8} zeroinitializer
@someArrayPointer = global ptr zeroinitializer

define void @runtime.initAll() {
  call void @main.init()
  ret void
}

define internal void @main.init() {
  call void @testIntToPtr()
  call void @testPtrToInt()
  call void @testConstGEP()
  call void @testICmp()
  ret void
}

define internal void @testIntToPtr() {
  %nil = icmp eq ptr inttoptr (i64 1024 to ptr), null
  br i1 %nil, label %a, label %b
a:
  ; should not be reached
  store i8 1, ptr @intToPtrResult
  ret void
b:
  ; should be reached
  store i8 2, ptr @intToPtrResult
  ret void
}

define internal void @testPtrToInt() {
  %zero = icmp eq i64 ptrtoint (ptr @ptrToIntResult to i64), 0
  br i1 %zero, label %a, label %b
a:
  ; should not be reached
  store i8 1, ptr @ptrToIntResult
  ret void
b:
  ; should be reached
  store i8 2, ptr @ptrToIntResult
  ret void
}

define internal void @testConstGEP() {
  store ptr getelementptr inbounds (i8, ptr @someArray, i32 2), ptr @someArrayPointer
  ret void
}

define internal void @testICmp() {
  br i1 icmp eq (i64 ptrtoint (ptr @ptrToIntResult to i64), i64 0), label %equal, label %unequal
equal:
  ; should not be reached
  store i8 1, ptr @icmpResult
  ret void
unequal:
  ; should be reached
  store i8 2, ptr @icmpResult
  ret void
  ret void
}