1 ; RUN: opt -lower-constant-intrinsics -S < %s | FileCheck %s
3 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"
4 target triple = "x86_64-apple-darwin10.0.0"
6 declare i64 @llvm.objectsize.i64(i8*, i1, i1, i1) nounwind readonly
7 declare i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)*, i1, i1, i1) nounwind readonly
8 declare void @llvm.trap() nounwind
10 ; CHECK-LABEL: @test1(
11 ; objectsize should fold to a constant, which causes the branch to fold to an
13 define i32 @test1(i8* %ptr) nounwind ssp noredzone align 2 {
15 %0 = tail call i64 @llvm.objectsize.i64(i8* %ptr, i1 false, i1 false, i1 false)
16 %1 = icmp ugt i64 %0, 3
17 br i1 %1, label %T, label %trap
20 ; CHECK-NOT: label %trap
22 trap: ; preds = %0, %entry
23 tail call void @llvm.trap() noreturn nounwind
31 ; CHECK-LABEL: @test_objectsize_null_flag(
32 define i64 @test_objectsize_null_flag(i8* %ptr) {
35 %0 = tail call i64 @llvm.objectsize.i64(i8* null, i1 false, i1 true, i1 false)
39 ; CHECK-LABEL: @test_objectsize_null_flag_min(
40 define i64 @test_objectsize_null_flag_min(i8* %ptr) {
43 %0 = tail call i64 @llvm.objectsize.i64(i8* null, i1 true, i1 true, i1 false)
47 ; Test foldable null pointers because we evaluate them with non-exact modes in
49 ; CHECK-LABEL: @test_objectsize_null_flag_noas0(
50 define i64 @test_objectsize_null_flag_noas0() {
53 %0 = tail call i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)* null, i1 false,
58 ; CHECK-LABEL: @test_objectsize_null_flag_min_noas0(
59 define i64 @test_objectsize_null_flag_min_noas0() {
62 %0 = tail call i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)* null, i1 true,
67 ; CHECK-LABEL: @test_objectsize_null_known_flag_noas0
68 define i64 @test_objectsize_null_known_flag_noas0() {
71 %0 = tail call i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)* null, i1 false,
76 ; CHECK-LABEL: @test_objectsize_null_known_flag_min_noas0
77 define i64 @test_objectsize_null_known_flag_min_noas0() {
80 %0 = tail call i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)* null, i1 true,