1; RUN: opt -codegenprepare -S < %s | FileCheck %s 2 3target 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" 4target triple = "x86_64-apple-darwin10.0.0" 5 6; CHECK-LABEL: @test1( 7; objectsize should fold to a constant, which causes the branch to fold to an 8; uncond branch. Next, we fold the control flow alltogether. 9; rdar://8785296 10define i32 @test1(i8* %ptr) nounwind ssp noredzone align 2 { 11entry: 12 %0 = tail call i64 @llvm.objectsize.i64(i8* %ptr, i1 false, i1 false) 13 %1 = icmp ugt i64 %0, 3 14 br i1 %1, label %T, label %trap 15 16; CHECK: entry: 17; CHECK-NOT: br label % 18 19trap: ; preds = %0, %entry 20 tail call void @llvm.trap() noreturn nounwind 21 unreachable 22 23T: 24; CHECK: ret i32 4 25 ret i32 4 26} 27 28; CHECK-LABEL: @test_objectsize_null_flag( 29define i64 @test_objectsize_null_flag(i8* %ptr) { 30entry: 31 ; CHECK: ret i64 -1 32 %0 = tail call i64 @llvm.objectsize.i64(i8* null, i1 false, i1 true) 33 ret i64 %0 34} 35 36; CHECK-LABEL: @test_objectsize_null_flag_min( 37define i64 @test_objectsize_null_flag_min(i8* %ptr) { 38entry: 39 ; CHECK: ret i64 0 40 %0 = tail call i64 @llvm.objectsize.i64(i8* null, i1 true, i1 true) 41 ret i64 %0 42} 43 44; Test foldable null pointers because we evaluate them with non-exact modes in 45; CodeGenPrepare. 46; CHECK-LABEL: @test_objectsize_null_flag_noas0( 47define i64 @test_objectsize_null_flag_noas0() { 48entry: 49 ; CHECK: ret i64 -1 50 %0 = tail call i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)* null, i1 false, 51 i1 true) 52 ret i64 %0 53} 54 55; CHECK-LABEL: @test_objectsize_null_flag_min_noas0( 56define i64 @test_objectsize_null_flag_min_noas0() { 57entry: 58 ; CHECK: ret i64 0 59 %0 = tail call i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)* null, i1 true, 60 i1 true) 61 ret i64 %0 62} 63 64; CHECK-LABEL: @test_objectsize_null_known_flag_noas0 65define i64 @test_objectsize_null_known_flag_noas0() { 66entry: 67 ; CHECK: ret i64 -1 68 %0 = tail call i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)* null, i1 false, 69 i1 false) 70 ret i64 %0 71} 72 73; CHECK-LABEL: @test_objectsize_null_known_flag_min_noas0 74define i64 @test_objectsize_null_known_flag_min_noas0() { 75entry: 76 ; CHECK: ret i64 0 77 %0 = tail call i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)* null, i1 true, 78 i1 false) 79 ret i64 %0 80} 81 82 83declare i64 @llvm.objectsize.i64(i8*, i1, i1) nounwind readonly 84declare i64 @llvm.objectsize.i64.p1i8(i8 addrspace(1)*, i1, i1) nounwind readonly 85 86declare void @llvm.trap() nounwind 87