1 ; RUN: opt < %s -instcombine -S | FileCheck %s 2 ; PR1201 3 define i32 @main(i32 %argc, i8** %argv) { 4 %c_19 = alloca i8* 5 %malloc_206 = tail call i8* @malloc(i32 mul (i32 ptrtoint (i8* getelementptr (i8* null, i32 1) to i32), i32 10)) 6 store i8* %malloc_206, i8** %c_19 7 %tmp_207 = load i8** %c_19 8 tail call void @free(i8* %tmp_207) 9 ret i32 0 10 ; CHECK-NOT: malloc 11 ; CHECK-NOT: free 12 ; CHECK: ret i32 0 13 } 14 15 declare noalias i8* @malloc(i32) 16 declare void @free(i8*) 17 18 define i1 @foo() { 19 ; CHECK: @foo 20 ; CHECK-NEXT: ret i1 false 21 %m = call i8* @malloc(i32 1) 22 %z = icmp eq i8* %m, null 23 call void @free(i8* %m) 24 ret i1 %z 25 } 26 27 declare void @llvm.lifetime.start(i64, i8*) 28 declare void @llvm.lifetime.end(i64, i8*) 29 30 define void @test3() { 31 ; CHECK: @test3 32 ; CHECK-NEXT: ret void 33 %a = call noalias i8* @malloc(i32 10) 34 call void @llvm.lifetime.start(i64 10, i8* %a) 35 call void @llvm.lifetime.end(i64 10, i8* %a) 36 ret void 37 } 38 39 ;; This used to crash. 40 define void @test4() { 41 ; CHECK: @test4 42 ; CHECK-NEXT: ret void 43 %A = call i8* @malloc(i32 16000) 44 %B = bitcast i8* %A to double* 45 %C = bitcast double* %B to i8* 46 call void @free(i8* %C) 47 ret void 48 } 49