1 ; RUN: opt < %s -basicaa -dse -S | FileCheck %s 2 3 target datalayout = "e-p:64:64:64" 4 5 declare void @free(i8* nocapture) 6 declare noalias i8* @malloc(i64) 7 8 ; CHECK-LABEL: @test( 9 ; CHECK-NEXT: bitcast 10 ; CHECK-NEXT: @free 11 ; CHECK-NEXT: ret void 12 define void @test(i32* %Q, i32* %P) { 13 %DEAD = load i32* %Q ; <i32> [#uses=1] 14 store i32 %DEAD, i32* %P 15 %1 = bitcast i32* %P to i8* 16 tail call void @free(i8* %1) 17 ret void 18 } 19 20 ; CHECK-LABEL: @test2( 21 ; CHECK-NEXT: bitcast 22 ; CHECK-NEXT: @free 23 ; CHECK-NEXT: ret void 24 define void @test2({i32, i32}* %P) { 25 %Q = getelementptr {i32, i32} *%P, i32 0, i32 1 26 store i32 4, i32* %Q 27 %1 = bitcast {i32, i32}* %P to i8* 28 tail call void @free(i8* %1) 29 ret void 30 } 31 32 ; CHECK-LABEL: @test3( 33 ; CHECK-NOT: store 34 ; CHECK: ret void 35 define void @test3() { 36 %m = call i8* @malloc(i64 24) 37 store i8 0, i8* %m 38 %m1 = getelementptr i8* %m, i64 1 39 store i8 1, i8* %m1 40 call void @free(i8* %m) 41 ret void 42 } 43 44 ; PR11240 45 ; CHECK-LABEL: @test4( 46 ; CHECK-NOT: store 47 ; CHECK: ret void 48 define void @test4(i1 %x) nounwind { 49 entry: 50 %alloc1 = tail call noalias i8* @malloc(i64 4) nounwind 51 br i1 %x, label %skipinit1, label %init1 52 53 init1: 54 store i8 1, i8* %alloc1 55 br label %skipinit1 56 57 skipinit1: 58 tail call void @free(i8* %alloc1) nounwind 59 ret void 60 } 61 62 ; CHECK-LABEL: @test5( 63 define void @test5() { 64 br label %bb 65 66 bb: 67 tail call void @free(i8* undef) nounwind 68 br label %bb 69 } 70 71