brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · d5e0dfd Raw
81 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature2; RUN: opt < %s -passes=ipsccp -S | FileCheck %s3; PR364854; musttail call result can\'t be replaced with a constant, unless the call5; can be removed6 7declare i32 @external()8 9define ptr @start(i8 %v) {10; CHECK-LABEL: define {{[^@]+}}@start11; CHECK-SAME: (i8 [[V:%.*]]) {12; CHECK-NEXT:    [[C1:%.*]] = icmp eq i8 [[V]], 013; CHECK-NEXT:    br i1 [[C1]], label [[TRUE:%.*]], label [[FALSE:%.*]]14; CHECK:       true:15; CHECK-NEXT:    [[CA:%.*]] = musttail call ptr @side_effects(i8 0)16; CHECK-NEXT:    ret ptr [[CA]]17; CHECK:       false:18; CHECK-NEXT:    [[C2:%.*]] = icmp eq i8 [[V]], 119; CHECK-NEXT:    br i1 [[C2]], label [[C2_TRUE:%.*]], label [[C2_FALSE:%.*]]20; CHECK:       c2_true:21; CHECK-NEXT:    ret ptr null22; CHECK:       c2_false:23; CHECK-NEXT:    [[CA2:%.*]] = musttail call ptr @dont_zap_me(i8 [[V]])24; CHECK-NEXT:    ret ptr [[CA2]]25;26  %c1 = icmp eq i8 %v, 027  br i1 %c1, label %true, label %false28true:29  %ca = musttail call ptr @side_effects(i8 %v)30  ret ptr %ca31false:32  %c2 = icmp eq i8 %v, 133  br i1 %c2, label %c2_true, label %c2_false34c2_true:35  %ca1 = musttail call ptr @no_side_effects(i8 %v)36  ret ptr %ca137c2_false:38  %ca2 = musttail call ptr @dont_zap_me(i8 %v)39  ret ptr %ca240}41 42define internal ptr @side_effects(i8 %v) {43; CHECK-LABEL: define {{[^@]+}}@side_effects44; CHECK-SAME: (i8 [[V:%.*]]) {45; CHECK-NEXT:    [[I1:%.*]] = call i32 @external()46; CHECK-NEXT:    [[CA:%.*]] = musttail call ptr @start(i8 0)47; CHECK-NEXT:    ret ptr [[CA]]48;49  %i1 = call i32 @external()50 51  ; since this goes back to `start` the SCPP should be see that the return value52  ; is always `null`.53  ; The call can't be removed due to `external` call above, though.54 55  %ca = musttail call ptr @start(i8 %v)56 57  ; Thus the result must be returned anyway58  ret ptr %ca59}60 61; The call to this function is removed, so the return value must be zapped62define internal ptr @no_side_effects(i8 %v) readonly nounwind willreturn {63; CHECK-LABEL: define {{[^@]+}}@no_side_effects64; CHECK-SAME: (i8 [[V:%.*]]) #[[ATTR0:[0-9]+]] {65; CHECK-NEXT:    ret ptr poison66;67  ret ptr null68}69 70; The call to this function cannot be removed due to side effects. Thus the71; return value should stay as it is, and should not be zapped.72define internal ptr @dont_zap_me(i8 %v) {73; CHECK-LABEL: define {{[^@]+}}@dont_zap_me74; CHECK-SAME: (i8 range(i8 2, 0) [[V:%.*]]) {75; CHECK-NEXT:    [[I1:%.*]] = call i32 @external()76; CHECK-NEXT:    ret ptr null77;78  %i1 = call i32 @external()79  ret ptr null80}81