1 ; RUN: opt < %s -ipsccp -S | FileCheck %s
3 ; musttail call result can\'t be replaced with a constant, unless the call
6 declare i32 @external()
8 define i8* @start(i8 %v) {
10 br i1 %c1, label %true, label %false
12 ; CHECK: %ca = musttail call i8* @side_effects(i8 0)
14 %ca = musttail call i8* @side_effects(i8 %v)
17 %c2 = icmp eq i8 %v, 1
18 br i1 %c2, label %c2_true, label %c2_false
20 %ca1 = musttail call i8* @no_side_effects(i8 %v)
24 ; CHECK: %ca2 = musttail call i8* @dont_zap_me(i8 %v)
26 %ca2 = musttail call i8* @dont_zap_me(i8 %v)
30 define internal i8* @side_effects(i8 %v) {
31 %i1 = call i32 @external()
33 ; since this goes back to `start` the SCPP should be see that the return value
35 ; The call can't be removed due to `external` call above, though.
37 ; CHECK: %ca = musttail call i8* @start(i8 0)
38 %ca = musttail call i8* @start(i8 %v)
40 ; Thus the result must be returned anyway
45 define internal i8* @no_side_effects(i8 %v) readonly nounwind {
46 ; The call to this function is removed, so the return value must be zapped
47 ; CHECK: ret i8* undef
51 define internal i8* @dont_zap_me(i8 %v) {
52 %i1 = call i32 @external()
54 ; The call to this function cannot be removed due to side effects. Thus the
55 ; return value should stay as it is, and should not be zapped.