1 ; Test objectsize bounds checking that won't verify until after -instcombine.
2 ; RUN: opt < %s -disable-verify -instcombine -S | opt -S | FileCheck %s
3 ; We need target data to get the sizes of the arrays and structures.
4 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-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
6 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly
8 ; CHECK-LABEL: @PR13390(
9 define i32 @PR13390(i1 %bool, i8* %a) {
11 %cond = or i1 %bool, true
12 br i1 %cond, label %return, label %xpto
15 %select = select i1 %bool, i8* %select, i8* %a
16 %select2 = select i1 %bool, i8* %a, i8* %select2
17 %0 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %select, i1 true)
18 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %select2, i1 true)
20 ; CHECK: ret i32 undef
27 define i32 @PR13390_logical(i1 %bool, i8* %a) {
29 %cond = select i1 %bool, i1 true, i1 true
30 br i1 %cond, label %return, label %xpto
33 %select = select i1 %bool, i8* %select, i8* %a
34 %select2 = select i1 %bool, i8* %a, i8* %select2
35 %0 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %select, i1 true)
36 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %select2, i1 true)
38 ; CHECK: ret i32 undef
45 ; CHECK-LABEL: @PR13621(
46 define i32 @PR13621(i1 %bool) nounwind {
48 %cond = or i1 %bool, true
49 br i1 %cond, label %return, label %xpto
51 ; technically reachable, but this malformed IR may appear as a result of constant propagation
53 %gep2 = getelementptr i8, i8* %gep, i32 1
54 %gep = getelementptr i8, i8* %gep2, i32 1
55 %o = call i32 @llvm.objectsize.i32.p0i8(i8* %gep, i1 true)
56 ; CHECK: ret i32 undef
63 define i32 @PR13621_logical(i1 %bool) nounwind {
65 %cond = select i1 %bool, i1 true, i1 true
66 br i1 %cond, label %return, label %xpto
68 ; technically reachable, but this malformed IR may appear as a result of constant propagation
70 %gep2 = getelementptr i8, i8* %gep, i32 1
71 %gep = getelementptr i8, i8* %gep2, i32 1
72 %o = call i32 @llvm.objectsize.i32.p0i8(i8* %gep, i1 true)
73 ; CHECK: ret i32 undef