aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp/testdata/consteval.ll
blob: d0c0e3b66961fefd12cda907cafcb985a10c218e (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 i8* 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 i8* inttoptr (i64 1024 to i8*), null
  br i1 %nil, label %a, label %b
a:
  ; should not be reached
  store i8 1, i8* @intToPtrResult
  ret void
b:
  ; should be reached
  store i8 2, i8* @intToPtrResult
  ret void
}

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

define internal void @testConstGEP() {
  store i8* getelementptr inbounds (i8, i8* bitcast ({i16, i8, i8}* @someArray to i8*), i32 2), i8** @someArrayPointer
  ret void
}

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