@@ -1018,5 +1018,72 @@ else:
10181018 ret ptr %p
10191019}
10201020
1021+ define i1 @improve_existing_captures (ptr captures(address) %p ) {
1022+ ; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1023+ ; FNATTRS-LABEL: define i1 @improve_existing_captures
1024+ ; FNATTRS-SAME: (ptr readnone captures(address_is_null) [[P:%.*]]) #[[ATTR0]] {
1025+ ; FNATTRS-NEXT: [[CMP:%.*]] = icmp eq ptr [[P]], null
1026+ ; FNATTRS-NEXT: ret i1 [[CMP]]
1027+ ;
1028+ ; ATTRIBUTOR: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1029+ ; ATTRIBUTOR-LABEL: define i1 @improve_existing_captures
1030+ ; ATTRIBUTOR-SAME: (ptr nofree readnone captures(address) [[P:%.*]]) #[[ATTR0]] {
1031+ ; ATTRIBUTOR-NEXT: [[CMP:%.*]] = icmp eq ptr [[P]], null
1032+ ; ATTRIBUTOR-NEXT: ret i1 [[CMP]]
1033+ ;
1034+ %cmp = icmp eq ptr %p , null
1035+ ret i1 %cmp
1036+ }
1037+
1038+ define void @dont_increase_existing_captures (ptr captures(address) %p ) {
1039+ ; COMMON-LABEL: define void @dont_increase_existing_captures
1040+ ; COMMON-SAME: (ptr captures(address) [[P:%.*]]) {
1041+ ; COMMON-NEXT: call void @capture(ptr [[P]])
1042+ ; COMMON-NEXT: ret void
1043+ ;
1044+ call void @capture (ptr %p )
1045+ ret void
1046+ }
1047+
1048+ define void @dont_increase_existing_captures_trivial_scc (ptr captures(address) %p ) {
1049+ ; COMMON-LABEL: define void @dont_increase_existing_captures_trivial_scc
1050+ ; COMMON-SAME: (ptr captures(address) [[P:%.*]]) {
1051+ ; COMMON-NEXT: call void @capture(ptr captures(address, read_provenance) [[P]])
1052+ ; COMMON-NEXT: call void @dont_increase_existing_captures_trivial_scc(ptr [[P]])
1053+ ; COMMON-NEXT: ret void
1054+ ;
1055+ call void @capture (ptr captures(address, read_provenance) %p )
1056+ call void @dont_increase_existing_captures_trivial_scc (ptr %p )
1057+ ret void
1058+ }
1059+
1060+ define void @dont_increase_existing_captures_scc1 (ptr captures(address) %p ) {
1061+ ; COMMON-LABEL: define void @dont_increase_existing_captures_scc1
1062+ ; COMMON-SAME: (ptr captures(address) [[P:%.*]]) {
1063+ ; COMMON-NEXT: call void @dont_increase_existing_captures_scc2(ptr [[P]])
1064+ ; COMMON-NEXT: ret void
1065+ ;
1066+ call void @dont_increase_existing_captures_scc2 (ptr %p )
1067+ ret void
1068+ }
1069+
1070+ define void @dont_increase_existing_captures_scc2 (ptr %p ) {
1071+ ; FNATTRS-LABEL: define void @dont_increase_existing_captures_scc2
1072+ ; FNATTRS-SAME: (ptr captures(address, read_provenance) [[P:%.*]]) {
1073+ ; FNATTRS-NEXT: call void @capture(ptr captures(address, read_provenance) [[P]])
1074+ ; FNATTRS-NEXT: call void @dont_increase_existing_captures_scc1(ptr [[P]])
1075+ ; FNATTRS-NEXT: ret void
1076+ ;
1077+ ; ATTRIBUTOR-LABEL: define void @dont_increase_existing_captures_scc2
1078+ ; ATTRIBUTOR-SAME: (ptr [[P:%.*]]) {
1079+ ; ATTRIBUTOR-NEXT: call void @capture(ptr captures(address, read_provenance) [[P]])
1080+ ; ATTRIBUTOR-NEXT: call void @dont_increase_existing_captures_scc1(ptr [[P]])
1081+ ; ATTRIBUTOR-NEXT: ret void
1082+ ;
1083+ call void @capture (ptr captures(address, read_provenance) %p )
1084+ call void @dont_increase_existing_captures_scc1 (ptr %p )
1085+ ret void
1086+ }
1087+
10211088declare ptr @llvm.launder.invariant.group.p0 (ptr )
10221089declare ptr @llvm.strip.invariant.group.p0 (ptr )
0 commit comments