1 ; RUN: opt -S -passes=dse < %s | FileCheck %s
4 declare noalias ptr @malloc(i32) nounwind
6 define void @test_0() {
7 ; CHECK-LABEL: @test_0(
8 %m = call ptr @malloc(i32 24)
9 tail call void @f() [ "unknown"(ptr %m) ]
10 ; CHECK: store i8 -19, ptr %m
15 define ptr @test_1() {
16 ; CHECK-LABEL: @test_1(
17 %m = call ptr @malloc(i32 24)
18 tail call void @f() [ "unknown"(ptr %m) ]
23 ; CHECK: tail call void @f() [ "unknown"(ptr %m) ]
24 ; CHECK: store i8 -19, ptr %m
25 ; CHECK: tail call void @f()
26 ; CHECK: store i8 101, ptr %m
31 define void @test_2() {
32 ; Since the deopt operand bundle does not escape %m (see caveat below), it is
33 ; legal to elide the final store that location.
35 ; CHECK-LABEL: @test_2(
36 %m = call ptr @malloc(i32 24)
37 tail call void @f() [ "deopt"(ptr %m) ]
41 ; CHECK: tail call void @f() [ "deopt"(ptr %m) ]
42 ; CHECK-NEXT: ret void
45 define ptr @test_3() {
46 ; Since the deopt operand bundle does not escape %m (see caveat below), @f
47 ; cannot observe the stores to %m
49 ; CHECK-LABEL: @test_3(
50 %m = call ptr @malloc(i32 24)
51 tail call void @f() [ "deopt"(ptr %m) ]
59 ; Caveat: technically, %m can only escape if the calling function is deoptimized
60 ; at the call site (i.e. the call returns to the "deopt" continuation). Since
61 ; the calling function body will be invalidated in that case, the calling
62 ; function can be optimized under the assumption that %m does not escape.