about summary refs log tree commit diff homepage
path: root/test/Intrinsics/objectsize.ll
blob: 9fa84de5f03ebaf25a47b6c6153b6076693952dd (plain) (blame)
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
; LLVM 9 added parameter "dynamic" to @llvm.objectsize
; REQUIRES: geq-llvm-9.0
; RUN: %llvmas %s -o=%t.bc
; RUN: rm -rf %t.klee-out
; RUN: %klee -exit-on-error --output-dir=%t.klee-out --optimize=false %t.bc
; ModuleID = 'objectsize.c'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i32 @main() nounwind uwtable {
entry:
  %a = alloca i8*, align 8
  %0 = load i8*, i8** %a, align 8
  %1 = call i64 @llvm.objectsize.i64.p0i8(i8* %0, i1 true, i1 false, i1 false)
  %cmp = icmp ne i64 %1, 0
  br i1 %cmp, label %abort.block, label %continue.block

continue.block:
  %2 = load i8*, i8** %a, align 8
  %3 = call i64 @llvm.objectsize.i64.p0i8(i8* %2, i1 false, i1 false, i1 false)
  %cmp1 = icmp ne i64 %3, -1
  br i1 %cmp1, label %abort.block, label %continue.block2

continue.block2:
; allocate one byte
  %b = alloca i8, align 8
  %4 = call i64 @llvm.objectsize.i64.p0i8(i8* %b, i1 false, i1 false, i1 false)
  %cmp2 = icmp ne i64 %4, 1
  br i1 %cmp2, label %abort.block, label %exit.block

exit.block:
  ret i32 0

abort.block:
  call void @abort()
  unreachable
}

declare i64 @llvm.objectsize.i64.p0i8(i8*, i1, i1, i1) nounwind readnone

declare void @abort() noreturn nounwind