• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4target 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"
5
6declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly
7
8; CHECK-LABEL: @PR13390(
9define i32 @PR13390(i1 %bool, i8* %a) {
10entry:
11  %cond = or i1 %bool, true
12  br i1 %cond, label %return, label %xpto
13
14xpto:
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)
19  %2 = add i32 %0, %1
20; CHECK: ret i32 undef
21  ret i32 %2
22
23return:
24  ret i32 42
25}
26
27; CHECK-LABEL: @PR13621(
28define i32 @PR13621(i1 %bool) nounwind {
29entry:
30  %cond = or i1 %bool, true
31  br i1 %cond, label %return, label %xpto
32
33; technically reachable, but this malformed IR may appear as a result of constant propagation
34xpto:
35  %gep2 = getelementptr i8, i8* %gep, i32 1
36  %gep = getelementptr i8, i8* %gep2, i32 1
37  %o = call i32 @llvm.objectsize.i32.p0i8(i8* %gep, i1 true)
38; CHECK: ret i32 undef
39  ret i32 %o
40
41return:
42  ret i32 7
43}
44