File: builtin-object-size-phi.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (421 lines) | stat: -rw-r--r-- 16,205 bytes parent folder | download | duplicates (6)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=lower-constant-intrinsics  -S < %s | FileCheck %s


target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

declare dso_local noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr allocsize(0)
declare i64 @llvm.objectsize.i64.p0(ptr, i1 immarg, i1 immarg, i1 immarg)

@buffer = dso_local global [4 x i8] zeroinitializer, align 1

define dso_local i64 @pick_max(i32 noundef %n) local_unnamed_addr {
; CHECK-LABEL: @pick_max(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT:    br i1 [[COND]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    [[MALLOCED:%.*]] = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8)
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[P:%.*]] = phi ptr [ [[MALLOCED]], [[IF_ELSE]] ], [ @buffer, [[ENTRY:%.*]] ]
; CHECK-NEXT:    ret i64 8
;
entry:
  %cond = icmp eq i32 %n, 0
  br i1 %cond, label %if.else, label %if.end

if.else:
  %malloced = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8)
  br label %if.end

if.end:
  %p = phi ptr [ %malloced, %if.else ], [ @buffer, %entry ]
  %size = call i64 @llvm.objectsize.i64.p0(ptr %p, i1 false, i1 true, i1 false)
  ret i64 %size
}

define dso_local i64 @pick_min(i32 noundef %n) local_unnamed_addr {
; CHECK-LABEL: @pick_min(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT:    br i1 [[COND]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    [[MALLOCED:%.*]] = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8)
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[P:%.*]] = phi ptr [ [[MALLOCED]], [[IF_ELSE]] ], [ @buffer, [[ENTRY:%.*]] ]
; CHECK-NEXT:    ret i64 4
;
entry:
  %cond = icmp eq i32 %n, 0
  br i1 %cond, label %if.else, label %if.end

if.else:
  %malloced = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8)
  br label %if.end

if.end:
  %p = phi ptr [ %malloced, %if.else ], [ @buffer, %entry ]
  %size = call i64 @llvm.objectsize.i64.p0(ptr %p, i1 true, i1 true, i1 false)
  ret i64 %size
}

define i64 @pick_max_same(i32 %n) {
; CHECK-LABEL: @pick_max_same(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[BUFFER:%.*]] = alloca i8, i64 20, align 1
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT:    br i1 [[COND]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    [[OFFSETED:%.*]] = getelementptr i8, ptr [[BUFFER]], i64 10
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[P:%.*]] = phi ptr [ [[OFFSETED]], [[IF_ELSE]] ], [ [[BUFFER]], [[ENTRY:%.*]] ]
; CHECK-NEXT:    ret i64 20
;
entry:
  %buffer = alloca i8, i64 20
  %cond = icmp eq i32 %n, 0
  br i1 %cond, label %if.else, label %if.end

if.else:
  %offseted = getelementptr i8, ptr %buffer, i64 10
  br label %if.end

if.end:
  %p = phi ptr [ %offseted, %if.else ], [ %buffer, %entry ]
  %size = call i64 @llvm.objectsize.i64.p0(ptr %p, i1 false, i1 true, i1 false)
  ret i64 %size
}

define i64 @pick_min_same(i32 %n) {
; CHECK-LABEL: @pick_min_same(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[BUFFER:%.*]] = alloca i8, i64 20, align 1
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT:    br i1 [[COND]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    [[OFFSETED:%.*]] = getelementptr i8, ptr [[BUFFER]], i64 10
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[P:%.*]] = phi ptr [ [[OFFSETED]], [[IF_ELSE]] ], [ [[BUFFER]], [[ENTRY:%.*]] ]
; CHECK-NEXT:    ret i64 10
;
entry:
  %buffer = alloca i8, i64 20
  %cond = icmp eq i32 %n, 0
  br i1 %cond, label %if.else, label %if.end

if.else:
  %offseted = getelementptr i8, ptr %buffer, i64 10
  br label %if.end

if.end:
  %p = phi ptr [ %offseted, %if.else ], [ %buffer, %entry ]
  %size = call i64 @llvm.objectsize.i64.p0(ptr %p, i1 true, i1 true, i1 false)
  ret i64 %size
}

define dso_local i64 @pick_max_large(i1 %c) local_unnamed_addr {
; CHECK-LABEL: @pick_max_large(
; CHECK-NEXT:    [[BUFFER:%.*]] = alloca i8, i64 -7, align 1
; CHECK-NEXT:    [[S:%.*]] = select i1 [[C:%.*]], ptr null, ptr [[BUFFER]]
; CHECK-NEXT:    ret i64 -1
;
  %buffer = alloca i8, i64 -7 ; Actually a very large positive integer
  %s = select i1 %c, ptr null, ptr %buffer
  %objsize = tail call i64 @llvm.objectsize.i64.p0(ptr %s, i1 false, i1 false, i1 false)
  ret i64 %objsize

}

define dso_local i64 @pick_max_one_oob(i1 %c0, i1 %c1) {
; CHECK-LABEL: @pick_max_one_oob(
; CHECK-NEXT:    [[P:%.*]] = alloca [2 x i8], align 1
; CHECK-NEXT:    br i1 [[C0:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
; CHECK:       if.then:
; CHECK-NEXT:    [[P_THEN:%.*]] = getelementptr inbounds [2 x i8], ptr [[P]], i64 0, i64 1
; CHECK-NEXT:    br label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    [[P_ELSE:%.*]] = getelementptr inbounds [2 x i8], ptr [[P]], i64 0, i64 -1
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[P_END:%.*]] = phi ptr [ [[P_ELSE]], [[IF_ELSE]] ], [ [[P_THEN]], [[IF_THEN]] ]
; CHECK-NEXT:    [[OBJSIZE:%.*]] = select i1 [[C1:%.*]], i64 -1, i64 0
; CHECK-NEXT:    ret i64 [[OBJSIZE]]
;
  %p = alloca [2 x i8], align 1
  br i1 %c0, label %if.then, label %if.else

if.then:
  %p.then = getelementptr inbounds [2 x i8], ptr %p, i64 0, i64 1
  br label %if.end

if.else:
  %p.else = getelementptr inbounds [2 x i8], ptr %p, i64 0, i64 -1
  br label %if.end

if.end:
  %p.end = phi ptr [%p.else, %if.else], [%p.then, %if.then]
  %objsize.max = call i64 @llvm.objectsize.i64.p0(ptr %p.end, i1 false, i1 true, i1 false)
  %objsize.min = call i64 @llvm.objectsize.i64.p0(ptr %p.end, i1 true, i1 true, i1 false)
  %objsize = select i1 %c1, i64 %objsize.max, i64 %objsize.min
  ret i64 %objsize
}


define i64 @pick_negative_offset(i32 %n) {
; CHECK-LABEL: @pick_negative_offset(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[BUFFER0:%.*]] = alloca i8, i64 20, align 1
; CHECK-NEXT:    [[OFFSETED0:%.*]] = getelementptr i8, ptr [[BUFFER0]], i64 20
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT:    br i1 [[COND]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    [[BUFFER1:%.*]] = alloca i8, i64 20, align 1
; CHECK-NEXT:    [[OFFSETED1:%.*]] = getelementptr i8, ptr [[BUFFER1]], i64 20
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[P:%.*]] = phi ptr [ [[OFFSETED1]], [[IF_ELSE]] ], [ [[OFFSETED0]], [[ENTRY:%.*]] ]
; CHECK-NEXT:    [[POFFSETED:%.*]] = getelementptr i8, ptr [[P]], i64 -4
; CHECK-NEXT:    ret i64 4
;
entry:
  %buffer0 = alloca i8, i64 20
  %offseted0 = getelementptr i8, ptr %buffer0, i64 20
  %cond = icmp eq i32 %n, 0
  br i1 %cond, label %if.else, label %if.end

if.else:
  %buffer1 = alloca i8, i64 20
  %offseted1 = getelementptr i8, ptr %buffer1, i64 20
  br label %if.end

if.end:
  %p = phi ptr [ %offseted1, %if.else ], [ %offseted0, %entry ]
  %poffseted = getelementptr i8, ptr %p, i64 -4
  %size = call i64 @llvm.objectsize.i64.p0(ptr %poffseted, i1 false, i1 false, i1 false)
  ret i64 %size
}

define i64 @pick_negative_offset_different_width(i32 %n) {
; CHECK-LABEL: @pick_negative_offset_different_width(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[BUFFER0:%.*]] = alloca i8, i64 4, align 1
; CHECK-NEXT:    [[BUFFER1:%.*]] = alloca i8, i64 8, align 1
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT:    br i1 [[COND]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
; CHECK:       if.then:
; CHECK-NEXT:    [[OFFSETED0:%.*]] = getelementptr i8, ptr [[BUFFER0]], i64 1
; CHECK-NEXT:    br label [[IF_END1:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    [[OFFSETED1:%.*]] = getelementptr i8, ptr [[BUFFER1]], i64 6
; CHECK-NEXT:    br label [[IF_END1]]
; CHECK:       if.end:
; CHECK-NEXT:    [[P:%.*]] = phi ptr [ [[OFFSETED0]], [[IF_ELSE]] ], [ [[OFFSETED1]], [[IF_END]] ]
; CHECK-NEXT:    [[POFFSETED:%.*]] = getelementptr i8, ptr [[P]], i64 -2
; CHECK-NEXT:    ret i64 5
;
entry:
  %buffer0 = alloca i8, i64 4
  %buffer1 = alloca i8, i64 8
  %cond = icmp eq i32 %n, 0
  br i1 %cond, label %if.then, label %if.else

if.then:
  %offseted0 = getelementptr i8, ptr %buffer0, i64 1
  br label %if.end

if.else:
  %offseted1 = getelementptr i8, ptr %buffer1, i64 6
  br label %if.end

if.end:
  %p = phi ptr [ %offseted0, %if.then ], [ %offseted1, %if.else ]
  %poffseted = getelementptr i8, ptr %p, i64 -2
  %size = call i64 @llvm.objectsize.i64.p0(ptr %poffseted, i1 false, i1 false, i1 false)
  ret i64 %size
}

define i64 @pick_negative_offset_with_nullptr(i32 %n) {
; CHECK-LABEL: @pick_negative_offset_with_nullptr(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[BUFFER0:%.*]] = alloca i8, i64 20, align 1
; CHECK-NEXT:    [[OFFSETED0:%.*]] = getelementptr i8, ptr [[BUFFER0]], i64 20
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT:    br i1 [[COND]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[P0:%.*]] = phi ptr [ [[OFFSETED0]], [[ENTRY:%.*]] ], [ null, [[IF_ELSE]] ]
; CHECK-NEXT:    [[P1:%.*]] = phi ptr [ null, [[IF_ELSE]] ], [ [[OFFSETED0]], [[ENTRY]] ]
; CHECK-NEXT:    [[P0OFFSETED:%.*]] = getelementptr i8, ptr [[P0]], i64 -4
; CHECK-NEXT:    [[P1OFFSETED:%.*]] = getelementptr i8, ptr [[P1]], i64 -4
; CHECK-NEXT:    ret i64 4
;
entry:
  %buffer0 = alloca i8, i64 20
  %offseted0 = getelementptr i8, ptr %buffer0, i64 20
  %cond = icmp eq i32 %n, 0
  br i1 %cond, label %if.else, label %if.end

if.else:
  br label %if.end

if.end:
  %p0 = phi ptr [ %offseted0, %entry ], [ null, %if.else ]
  %p1 = phi ptr [ null, %if.else ], [ %offseted0, %entry ]
  %p0offseted = getelementptr i8, ptr %p0, i64 -4
  %p1offseted = getelementptr i8, ptr %p1, i64 -4
  %size0 = call i64 @llvm.objectsize.i64.p0(ptr %p0offseted, i1 false, i1 false, i1 false)
  %size1 = call i64 @llvm.objectsize.i64.p0(ptr %p1offseted, i1 false, i1 false, i1 false)
  %size = select i1 %cond, i64 %size0, i64 %size1
  ret i64 %size
}

define i64 @pick_negative_offset_with_unsized_nullptr(i32 %n) {
; CHECK-LABEL: @pick_negative_offset_with_unsized_nullptr(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[BUFFER0:%.*]] = alloca i8, i64 20, align 1
; CHECK-NEXT:    [[OFFSETED0:%.*]] = getelementptr i8, ptr [[BUFFER0]], i64 20
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT:    br i1 [[COND]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[P0:%.*]] = phi ptr [ [[OFFSETED0]], [[ENTRY:%.*]] ], [ null, [[IF_ELSE]] ]
; CHECK-NEXT:    [[P1:%.*]] = phi ptr [ null, [[IF_ELSE]] ], [ [[OFFSETED0]], [[ENTRY]] ]
; CHECK-NEXT:    [[P0OFFSETED:%.*]] = getelementptr i8, ptr [[P0]], i64 -4
; CHECK-NEXT:    [[P1OFFSETED:%.*]] = getelementptr i8, ptr [[P1]], i64 -4
; CHECK-NEXT:    ret i64 -1
;
entry:
  %buffer0 = alloca i8, i64 20
  %offseted0 = getelementptr i8, ptr %buffer0, i64 20
  %cond = icmp eq i32 %n, 0
  br i1 %cond, label %if.else, label %if.end

if.else:
  br label %if.end

if.end:
  %p0 = phi ptr [ %offseted0, %entry ], [ null, %if.else ]
  %p1 = phi ptr [ null, %if.else ], [ %offseted0, %entry ]
  %p0offseted = getelementptr i8, ptr %p0, i64 -4
  %p1offseted = getelementptr i8, ptr %p1, i64 -4
  %size0 = call i64 @llvm.objectsize.i64.p0(ptr %p0offseted, i1 false, i1 true, i1 false)
  %size1 = call i64 @llvm.objectsize.i64.p0(ptr %p1offseted, i1 false, i1 true, i1 false)
  %size = select i1 %cond, i64 %size0, i64 %size1
  ret i64 %size
}

define i64 @chain_pick_negative_offset_with_nullptr(i32 %x) {
; CHECK-LABEL: @chain_pick_negative_offset_with_nullptr(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[ARRAY:%.*]] = alloca [4 x i32], align 4
; CHECK-NEXT:    [[C:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK-NEXT:    [[P:%.*]] = getelementptr i8, ptr [[ARRAY]], i64 8
; CHECK-NEXT:    [[COND:%.*]] = select i1 [[C]], ptr [[P]], ptr null
; CHECK-NEXT:    [[P4:%.*]] = getelementptr i8, ptr [[COND]], i64 8
; CHECK-NEXT:    [[COND6:%.*]] = select i1 [[C]], ptr [[P4]], ptr null
; CHECK-NEXT:    [[P7:%.*]] = getelementptr i8, ptr [[COND6]], i64 -4
; CHECK-NEXT:    ret i64 4
;
entry:
  %array = alloca [4 x i32]
  %c = icmp eq i32 %x, 0
  %p = getelementptr i8, ptr %array, i64 8
  %cond = select i1 %c, ptr %p, ptr null
  %p4 = getelementptr i8, ptr %cond, i64 8
  %cond6 = select i1 %c, ptr %p4, ptr null
  %p7 = getelementptr i8, ptr %cond6, i64 -4
  %size = call i64 @llvm.objectsize.i64.p0(ptr %p7, i1 false, i1 false, i1 false)
  ret i64 %size
}


define i64 @negative_offset_dynamic_eval(i32 %x, i64 %i) {
; CHECK-LABEL: @negative_offset_dynamic_eval(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[ARRAY1:%.*]] = alloca [4 x i32], align 16
; CHECK-NEXT:    [[ARRAY2:%.*]] = alloca [8 x i32], align 16
; CHECK-NEXT:    [[TOBOOL_NOT:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK-NEXT:    br i1 [[TOBOOL_NOT]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
; CHECK:       if.then:
; CHECK-NEXT:    br label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[ARRAY2]], i64 16
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[TMP0:%.*]] = phi i64 [ 16, [[IF_THEN]] ], [ 32, [[IF_ELSE]] ]
; CHECK-NEXT:    [[TMP5:%.*]] = phi i64 [ 0, [[IF_THEN]] ], [ 16, [[IF_ELSE]] ]
; CHECK-NEXT:    [[PTR:%.*]] = phi ptr [ [[ARRAY1]], [[IF_THEN]] ], [ [[ADD_PTR]], [[IF_ELSE]] ]
; CHECK-NEXT:    [[ADD_PTR2_IDX:%.*]] = mul i64 [[I:%.*]], 4
; CHECK-NEXT:    [[TMP6:%.*]] = add i64 [[TMP5]], [[ADD_PTR2_IDX]]
; CHECK-NEXT:    [[ADD_PTR2:%.*]] = getelementptr inbounds i32, ptr [[PTR]], i64 [[I]]
; CHECK-NEXT:    [[TMP1:%.*]] = sub i64 [[TMP0]], [[TMP6]]
; CHECK-NEXT:    [[TMP2:%.*]] = icmp ult i64 [[TMP0]], [[TMP6]]
; CHECK-NEXT:    [[TMP3:%.*]] = select i1 [[TMP2]], i64 0, i64 [[TMP1]]
; CHECK-NEXT:    [[TMP4:%.*]] = icmp ne i64 [[TMP3]], -1
; CHECK-NEXT:    call void @llvm.assume(i1 [[TMP4]])
; CHECK-NEXT:    ret i64 [[TMP3]]
;
entry:
  %array1 = alloca [4 x i32], align 16
  %array2 = alloca [8 x i32], align 16
  %tobool.not = icmp eq i32 %x, 0
  br i1 %tobool.not, label %if.else, label %if.then

if.then:
  br label %if.end

if.else:
  %add.ptr = getelementptr inbounds i8, ptr %array2, i64 16
  br label %if.end

if.end:
  %ptr = phi ptr [ %array1, %if.then ], [ %add.ptr, %if.else ]
  %add.ptr2 = getelementptr inbounds i32, ptr %ptr, i64 %i
  %objsize = call i64 @llvm.objectsize.i64.p0(ptr %add.ptr2, i1 false, i1 true, i1 true)
  ret i64 %objsize
}


define i64 @outofbound_offset_eval(i32 %x) {
; CHECK-LABEL: @outofbound_offset_eval(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[ARRAY:%.*]] = alloca [4 x i8], align 16
; CHECK-NEXT:    [[TOBOOL_NOT:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK-NEXT:    br i1 [[TOBOOL_NOT]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
; CHECK:       if.then:
; CHECK-NEXT:    [[ADD_PTR0:%.*]] = getelementptr i8, ptr [[ARRAY]], i64 10
; CHECK-NEXT:    br label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    [[ADD_PTR1:%.*]] = getelementptr i8, ptr [[ARRAY]], i64 12
; CHECK-NEXT:    br label [[IF_END]]
; CHECK:       if.end:
; CHECK-NEXT:    [[PTR:%.*]] = phi ptr [ [[ADD_PTR0]], [[IF_THEN]] ], [ [[ADD_PTR1]], [[IF_ELSE]] ]
; CHECK-NEXT:    [[ADD_PTR2:%.*]] = getelementptr i8, ptr [[PTR]], i64 -10
; CHECK-NEXT:    ret i64 4
;
entry:
  %array = alloca [4 x i8], align 16
  %tobool.not = icmp eq i32 %x, 0
  br i1 %tobool.not, label %if.else, label %if.then

if.then:
  %add.ptr0 = getelementptr i8, ptr %array, i64 10
  br label %if.end

if.else:
  %add.ptr1 = getelementptr i8, ptr %array, i64 12
  br label %if.end

if.end:
  %ptr = phi ptr [ %add.ptr0, %if.then ], [ %add.ptr1, %if.else ]
  %add.ptr2 = getelementptr i8, ptr %ptr, i64 -10
  %objsize = call i64 @llvm.objectsize.i64.p0(ptr %add.ptr2, i1 false, i1 false, i1 false)
  ret i64 %objsize
}