56 lines · plain
1; RUN: opt < %s -passes=dse -S | FileCheck %s2 3declare noalias ptr @malloc(i64) "malloc-like"4 5declare void @foo()6declare void @bar(ptr)7 8define void @test() {9 %obj = call ptr @malloc(i64 8)10 store i8 0, ptr %obj11 ; don't remove store. %obj should be treated like it will be read by the @foo.12 ; CHECK: store i8 0, ptr %obj13 call void @foo() ["deopt" (ptr %obj)]14 ret void15}16 17define void @test1() {18 %obj = call ptr @malloc(i64 8)19 store i8 0, ptr %obj20 ; CHECK: store i8 0, ptr %obj21 call void @bar(ptr nocapture %obj)22 ret void23}24 25define void @test2() {26 %obj = call ptr @malloc(i64 8)27 store i8 0, ptr %obj28 ; CHECK-NOT: store i8 0, ptr %obj29 call void @foo()30 ret void31}32 33define void @test3() {34 ; CHECK-LABEL: @test3(35 %s = alloca i6436 ; Verify that this first store is not considered killed by the second one37 ; since it could be observed from the deopt continuation.38 ; CHECK: store i64 1, ptr %s39 store i64 1, ptr %s40 call void @foo() [ "deopt"(ptr %s) ]41 store i64 0, ptr %s42 ret void43}44 45declare noalias ptr @calloc(i64, i64) inaccessiblememonly allockind("alloc,zeroed")46 47define void @test4() {48; CHECK-LABEL: @test449 %local_obj = call ptr @calloc(i64 1, i64 4)50 call void @foo() ["deopt" (ptr %local_obj)]51 store i8 0, ptr %local_obj, align 452 ; CHECK-NOT: store i8 0, ptr %local_obj, align 453 call void @bar(ptr nocapture %local_obj)54 ret void55}56