brintos

brintos / llvm-project-archived public Read only

0
0
Text · 39.9 KiB · 034b5ef Raw
901 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals2; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-annotate-decl-cs  -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT3; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC4 5@g = global ptr null		; <ptr> [#uses=1]6 7;.8; CHECK: @g = global ptr null9; CHECK: @lookup_table = global [2 x i1] [i1 false, i1 true]10; CHECK: @g2 = global ptr null11; CHECK: @g3 = global ptr null12;.13define ptr @c1(ptr %q) {14; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)15; CHECK-LABEL: define {{[^@]+}}@c116; CHECK-SAME: (ptr nofree readnone returned "no-capture-maybe-returned" [[Q:%.*]]) #[[ATTR0:[0-9]+]] {17; CHECK-NEXT:    ret ptr [[Q]]18;19  ret ptr %q20}21 22; It would also be acceptable to mark %q as readnone. Update @c3 too.23define void @c2(ptr %q) {24; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)25; CHECK-LABEL: define {{[^@]+}}@c226; CHECK-SAME: (ptr nofree writeonly [[Q:%.*]]) #[[ATTR1:[0-9]+]] {27; CHECK-NEXT:    store ptr [[Q]], ptr @g, align 828; CHECK-NEXT:    ret void29;30  store ptr %q, ptr @g31  ret void32}33 34define void @c3(ptr %q) {35; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)36; TUNIT-LABEL: define {{[^@]+}}@c337; TUNIT-SAME: (ptr nofree writeonly [[Q:%.*]]) #[[ATTR1]] {38; TUNIT-NEXT:    call void @c2(ptr nofree writeonly [[Q]]) #[[ATTR17:[0-9]+]]39; TUNIT-NEXT:    ret void40;41; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)42; CGSCC-LABEL: define {{[^@]+}}@c343; CGSCC-SAME: (ptr nofree writeonly [[Q:%.*]]) #[[ATTR2:[0-9]+]] {44; CGSCC-NEXT:    call void @c2(ptr nofree writeonly [[Q]]) #[[ATTR20:[0-9]+]]45; CGSCC-NEXT:    ret void46;47  call void @c2(ptr %q)48  ret void49}50 51define i1 @c4(ptr %q, i32 %bitno) {52; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)53; CHECK-LABEL: define {{[^@]+}}@c454; CHECK-SAME: (ptr nofree readnone [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR0]] {55; CHECK-NEXT:    [[TMP:%.*]] = ptrtoint ptr [[Q]] to i3256; CHECK-NEXT:    [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]57; CHECK-NEXT:    [[BIT:%.*]] = trunc i32 [[TMP2]] to i158; CHECK-NEXT:    br i1 [[BIT]], label [[L1:%.*]], label [[L0:%.*]]59; CHECK:       l0:60; CHECK-NEXT:    ret i1 false61; CHECK:       l1:62; CHECK-NEXT:    ret i1 true63;64  %tmp = ptrtoint ptr %q to i3265  %tmp2 = lshr i32 %tmp, %bitno66  %bit = trunc i32 %tmp2 to i167  br i1 %bit, label %l1, label %l068l0:69  ret i1 0 ; escaping value not caught by def-use chaining.70l1:71  ret i1 1 ; escaping value not caught by def-use chaining.72}73 74; c4b is c4 but without the escaping part75define i1 @c4b(ptr %q, i32 %bitno) {76; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)77; CHECK-LABEL: define {{[^@]+}}@c4b78; CHECK-SAME: (ptr nofree readnone captures(none) [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR0]] {79; CHECK-NEXT:    [[TMP:%.*]] = ptrtoint ptr [[Q]] to i3280; CHECK-NEXT:    [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]81; CHECK-NEXT:    [[BIT:%.*]] = trunc i32 [[TMP2]] to i182; CHECK-NEXT:    br i1 [[BIT]], label [[L1:%.*]], label [[L0:%.*]]83; CHECK:       l0:84; CHECK-NEXT:    ret i1 false85; CHECK:       l1:86; CHECK-NEXT:    ret i1 false87;88  %tmp = ptrtoint ptr %q to i3289  %tmp2 = lshr i32 %tmp, %bitno90  %bit = trunc i32 %tmp2 to i191  br i1 %bit, label %l1, label %l092l0:93  ret i1 0 ; not escaping!94l1:95  ret i1 0 ; not escaping!96}97 98@lookup_table = global [2 x i1] [ i1 0, i1 1 ]99 100define i1 @c5(ptr %q, i32 %bitno) {101; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)102; TUNIT-LABEL: define {{[^@]+}}@c5103; TUNIT-SAME: (ptr nofree readonly [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR2:[0-9]+]] {104; TUNIT-NEXT:    [[TMP:%.*]] = ptrtoint ptr [[Q]] to i32105; TUNIT-NEXT:    [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]106; TUNIT-NEXT:    [[BIT:%.*]] = and i32 [[TMP2]], 1107; TUNIT-NEXT:    [[LOOKUP:%.*]] = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 [[BIT]]108; TUNIT-NEXT:    [[VAL:%.*]] = load i1, ptr [[LOOKUP]], align 1109; TUNIT-NEXT:    ret i1 [[VAL]]110;111; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)112; CGSCC-LABEL: define {{[^@]+}}@c5113; CGSCC-SAME: (ptr nofree readonly [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR3:[0-9]+]] {114; CGSCC-NEXT:    [[TMP:%.*]] = ptrtoint ptr [[Q]] to i32115; CGSCC-NEXT:    [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]116; CGSCC-NEXT:    [[BIT:%.*]] = and i32 [[TMP2]], 1117; CGSCC-NEXT:    [[LOOKUP:%.*]] = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 [[BIT]]118; CGSCC-NEXT:    [[VAL:%.*]] = load i1, ptr [[LOOKUP]], align 1119; CGSCC-NEXT:    ret i1 [[VAL]]120;121  %tmp = ptrtoint ptr %q to i32122  %tmp2 = lshr i32 %tmp, %bitno123  %bit = and i32 %tmp2, 1124  ; subtle escape mechanism follows125  %lookup = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 %bit126  %val = load i1, ptr %lookup127  ret i1 %val128}129 130declare void @throw_if_bit_set(ptr, i8) readonly131 132define i1 @c6(ptr %q, i8 %bit) personality ptr @__gxx_personality_v0 {133; TUNIT: Function Attrs: nosync memory(read)134; TUNIT-LABEL: define {{[^@]+}}@c6135; TUNIT-SAME: (ptr readonly [[Q:%.*]], i8 [[BIT:%.*]]) #[[ATTR4:[0-9]+]] personality ptr @__gxx_personality_v0 {136; TUNIT-NEXT:    invoke void @throw_if_bit_set(ptr readonly [[Q]], i8 [[BIT]]) #[[ATTR4]]137; TUNIT-NEXT:            to label [[RET0:%.*]] unwind label [[RET1:%.*]]138; TUNIT:       ret0:139; TUNIT-NEXT:    ret i1 false140; TUNIT:       ret1:141; TUNIT-NEXT:    [[EXN:%.*]] = landingpad { ptr, i32 }142; TUNIT-NEXT:            cleanup143; TUNIT-NEXT:    ret i1 true144;145; CGSCC: Function Attrs: nosync memory(read)146; CGSCC-LABEL: define {{[^@]+}}@c6147; CGSCC-SAME: (ptr readonly [[Q:%.*]], i8 [[BIT:%.*]]) #[[ATTR5:[0-9]+]] personality ptr @__gxx_personality_v0 {148; CGSCC-NEXT:    invoke void @throw_if_bit_set(ptr readonly [[Q]], i8 [[BIT]]) #[[ATTR5]]149; CGSCC-NEXT:            to label [[RET0:%.*]] unwind label [[RET1:%.*]]150; CGSCC:       ret0:151; CGSCC-NEXT:    ret i1 false152; CGSCC:       ret1:153; CGSCC-NEXT:    [[EXN:%.*]] = landingpad { ptr, i32 }154; CGSCC-NEXT:            cleanup155; CGSCC-NEXT:    ret i1 true156;157  invoke void @throw_if_bit_set(ptr %q, i8 %bit)158  to label %ret0 unwind label %ret1159ret0:160  ret i1 0161ret1:162  %exn = landingpad {ptr, i32}163  cleanup164  ret i1 1165}166 167declare i32 @__gxx_personality_v0(...)168 169define ptr @lookup_bit(ptr %q, i32 %bitno) readnone nounwind {170; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)171; CHECK-LABEL: define {{[^@]+}}@lookup_bit172; CHECK-SAME: (ptr nofree readnone [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR0]] {173; CHECK-NEXT:    [[TMP:%.*]] = ptrtoint ptr [[Q]] to i32174; CHECK-NEXT:    [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]175; CHECK-NEXT:    [[BIT:%.*]] = and i32 [[TMP2]], 1176; CHECK-NEXT:    [[LOOKUP:%.*]] = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 [[BIT]]177; CHECK-NEXT:    ret ptr [[LOOKUP]]178;179  %tmp = ptrtoint ptr %q to i32180  %tmp2 = lshr i32 %tmp, %bitno181  %bit = and i32 %tmp2, 1182  %lookup = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 %bit183  ret ptr %lookup184}185 186define i1 @c7(ptr %q, i32 %bitno) {187; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)188; TUNIT-LABEL: define {{[^@]+}}@c7189; TUNIT-SAME: (ptr nofree readonly [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR2]] {190; TUNIT-NEXT:    [[PTR:%.*]] = call ptr @lookup_bit(ptr noalias nofree readnone [[Q]], i32 [[BITNO]]) #[[ATTR18:[0-9]+]]191; TUNIT-NEXT:    [[VAL:%.*]] = load i1, ptr [[PTR]], align 1192; TUNIT-NEXT:    ret i1 [[VAL]]193;194; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(read)195; CGSCC-LABEL: define {{[^@]+}}@c7196; CGSCC-SAME: (ptr nofree readonly [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR6:[0-9]+]] {197; CGSCC-NEXT:    [[PTR:%.*]] = call ptr @lookup_bit(ptr noalias nofree readnone [[Q]], i32 [[BITNO]]) #[[ATTR21:[0-9]+]]198; CGSCC-NEXT:    [[VAL:%.*]] = load i1, ptr [[PTR]], align 1199; CGSCC-NEXT:    ret i1 [[VAL]]200;201  %ptr = call ptr @lookup_bit(ptr %q, i32 %bitno)202  %val = load i1, ptr %ptr203  ret i1 %val204}205 206 207define i32 @nc1(ptr %q, ptr %p, i1 %b) {208; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn209; TUNIT-LABEL: define {{[^@]+}}@nc1210; TUNIT-SAME: (ptr nofree [[Q:%.*]], ptr nofree captures(none) [[P:%.*]], i1 [[B:%.*]]) #[[ATTR5:[0-9]+]] {211; TUNIT-NEXT:  e:212; TUNIT-NEXT:    br label [[L:%.*]]213; TUNIT:       l:214; TUNIT-NEXT:    [[X:%.*]] = phi ptr [ [[P]], [[E:%.*]] ]215; TUNIT-NEXT:    [[Y:%.*]] = phi ptr [ [[Q]], [[E]] ]216; TUNIT-NEXT:    [[TMP2:%.*]] = select i1 [[B]], ptr [[P]], ptr [[Q]]217; TUNIT-NEXT:    [[VAL:%.*]] = load i32, ptr [[TMP2]], align 4218; TUNIT-NEXT:    store i32 0, ptr [[P]], align 4219; TUNIT-NEXT:    store ptr [[Q]], ptr @g, align 8220; TUNIT-NEXT:    ret i32 [[VAL]]221;222; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn223; CGSCC-LABEL: define {{[^@]+}}@nc1224; CGSCC-SAME: (ptr nofree [[Q:%.*]], ptr nofree captures(none) [[P:%.*]], i1 [[B:%.*]]) #[[ATTR7:[0-9]+]] {225; CGSCC-NEXT:  e:226; CGSCC-NEXT:    br label [[L:%.*]]227; CGSCC:       l:228; CGSCC-NEXT:    [[X:%.*]] = phi ptr [ [[P]], [[E:%.*]] ]229; CGSCC-NEXT:    [[Y:%.*]] = phi ptr [ [[Q]], [[E]] ]230; CGSCC-NEXT:    [[TMP2:%.*]] = select i1 [[B]], ptr [[P]], ptr [[Q]]231; CGSCC-NEXT:    [[VAL:%.*]] = load i32, ptr [[TMP2]], align 4232; CGSCC-NEXT:    store i32 0, ptr [[P]], align 4233; CGSCC-NEXT:    store ptr [[Q]], ptr @g, align 8234; CGSCC-NEXT:    ret i32 [[VAL]]235;236e:237  br label %l238l:239  %x = phi ptr [ %p, %e ]240  %y = phi ptr [ %q, %e ]241  %tmp2 = select i1 %b, ptr %x, ptr %y242  %val = load i32, ptr %tmp2		; <i32> [#uses=1]243  store i32 0, ptr %x244  store ptr %y, ptr @g245  ret i32 %val246}247 248define i32 @nc1_addrspace(ptr %q, ptr addrspace(1) %p, i1 %b) {249; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn250; TUNIT-LABEL: define {{[^@]+}}@nc1_addrspace251; TUNIT-SAME: (ptr nofree [[Q:%.*]], ptr addrspace(1) nofree captures(none) [[P:%.*]], i1 [[B:%.*]]) #[[ATTR5]] {252; TUNIT-NEXT:  e:253; TUNIT-NEXT:    br label [[L:%.*]]254; TUNIT:       l:255; TUNIT-NEXT:    [[X:%.*]] = phi ptr addrspace(1) [ [[P]], [[E:%.*]] ]256; TUNIT-NEXT:    [[Y:%.*]] = phi ptr [ [[Q]], [[E]] ]257; TUNIT-NEXT:    [[TMP:%.*]] = addrspacecast ptr addrspace(1) [[P]] to ptr258; TUNIT-NEXT:    [[TMP2:%.*]] = select i1 [[B]], ptr [[TMP]], ptr [[Q]]259; TUNIT-NEXT:    [[VAL:%.*]] = load i32, ptr [[TMP2]], align 4260; TUNIT-NEXT:    store i32 0, ptr [[TMP]], align 4261; TUNIT-NEXT:    store ptr [[Q]], ptr @g, align 8262; TUNIT-NEXT:    ret i32 [[VAL]]263;264; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn265; CGSCC-LABEL: define {{[^@]+}}@nc1_addrspace266; CGSCC-SAME: (ptr nofree [[Q:%.*]], ptr addrspace(1) nofree captures(none) [[P:%.*]], i1 [[B:%.*]]) #[[ATTR7]] {267; CGSCC-NEXT:  e:268; CGSCC-NEXT:    br label [[L:%.*]]269; CGSCC:       l:270; CGSCC-NEXT:    [[X:%.*]] = phi ptr addrspace(1) [ [[P]], [[E:%.*]] ]271; CGSCC-NEXT:    [[Y:%.*]] = phi ptr [ [[Q]], [[E]] ]272; CGSCC-NEXT:    [[TMP:%.*]] = addrspacecast ptr addrspace(1) [[P]] to ptr273; CGSCC-NEXT:    [[TMP2:%.*]] = select i1 [[B]], ptr [[TMP]], ptr [[Q]]274; CGSCC-NEXT:    [[VAL:%.*]] = load i32, ptr [[TMP2]], align 4275; CGSCC-NEXT:    store i32 0, ptr [[TMP]], align 4276; CGSCC-NEXT:    store ptr [[Q]], ptr @g, align 8277; CGSCC-NEXT:    ret i32 [[VAL]]278;279e:280  br label %l281l:282  %x = phi ptr addrspace(1) [ %p, %e ]283  %y = phi ptr [ %q, %e ]284  %tmp = addrspacecast ptr addrspace(1) %x to ptr		; <ptr> [#uses=2]285  %tmp2 = select i1 %b, ptr %tmp, ptr %y286  %val = load i32, ptr %tmp2		; <i32> [#uses=1]287  store i32 0, ptr %tmp288  store ptr %y, ptr @g289  ret i32 %val290}291 292define void @nc2(ptr %p, ptr %q) {293; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn294; TUNIT-LABEL: define {{[^@]+}}@nc2295; TUNIT-SAME: (ptr nofree captures(none) [[P:%.*]], ptr nofree [[Q:%.*]]) #[[ATTR5]] {296; TUNIT-NEXT:    [[TMP1:%.*]] = call i32 @nc1(ptr nofree [[Q]], ptr nofree captures(none) [[P]], i1 noundef false) #[[ATTR19:[0-9]+]]297; TUNIT-NEXT:    ret void298;299; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn300; CGSCC-LABEL: define {{[^@]+}}@nc2301; CGSCC-SAME: (ptr nofree align 4 captures(none) [[P:%.*]], ptr nofree [[Q:%.*]]) #[[ATTR8:[0-9]+]] {302; CGSCC-NEXT:    [[TMP1:%.*]] = call i32 @nc1(ptr nofree [[Q]], ptr nofree align 4 captures(none) [[P]], i1 noundef false) #[[ATTR22:[0-9]+]]303; CGSCC-NEXT:    ret void304;305  %1 = call i32 @nc1(ptr %q, ptr %p, i1 0)		; <i32> [#uses=0]306  ret void307}308 309 310define void @nc3(ptr %p) {311; CHECK-LABEL: define {{[^@]+}}@nc3312; CHECK-SAME: (ptr nofree noundef nonnull captures(none) [[P:%.*]]) {313; CHECK-NEXT:    call void [[P]]()314; CHECK-NEXT:    ret void315;316  call void %p()317  ret void318}319 320; The following test is tricky because improvements to AAIsDead can cause the call to be removed.321; FIXME: readonly and nocapture missing on the pointer.322declare void @external(ptr readonly) nounwind argmemonly323define void @nc4(ptr %p) {324; TUNIT: Function Attrs: nounwind memory(argmem: readwrite)325; TUNIT-LABEL: define {{[^@]+}}@nc4326; TUNIT-SAME: (ptr nofree [[P:%.*]]) #[[ATTR6:[0-9]+]] {327; TUNIT-NEXT:    call void @external(ptr nofree readonly [[P]]) #[[ATTR20:[0-9]+]]328; TUNIT-NEXT:    ret void329;330; CGSCC: Function Attrs: nounwind memory(argmem: readwrite)331; CGSCC-LABEL: define {{[^@]+}}@nc4332; CGSCC-SAME: (ptr nofree [[P:%.*]]) #[[ATTR9:[0-9]+]] {333; CGSCC-NEXT:    call void @external(ptr nofree readonly [[P]]) #[[ATTR23:[0-9]+]]334; CGSCC-NEXT:    ret void335;336  call void @external(ptr %p)337  ret void338}339 340define void @callsite_readonly_nounwind_not_willreturn(ptr %f, ptr %p) {341; CHECK-LABEL: define {{[^@]+}}@callsite_readonly_nounwind_not_willreturn342; CHECK-SAME: (ptr nofree noundef nonnull captures(none) [[F:%.*]], ptr [[P:%.*]]) {343; CHECK-NEXT:    call void [[F]](ptr captures(none) [[P]])344; CHECK-NEXT:    ret void345;346  call void %f(ptr %p) readonly nounwind347  call void %f(ptr nocapture %p)348  ret void349}350 351define void @callsite_readonly_nounwind_willreturn(ptr %f, ptr %p) {352; CHECK-LABEL: define {{[^@]+}}@callsite_readonly_nounwind_willreturn353; CHECK-SAME: (ptr nofree noundef nonnull captures(none) [[F:%.*]], ptr [[P:%.*]]) {354; CHECK-NEXT:    call void [[F]](ptr captures(none) [[P]])355; CHECK-NEXT:    ret void356;357  call void %f(ptr %p) readonly nounwind willreturn358  call void %f(ptr nocapture %p)359  ret void360}361 362; It would be acceptable to add readnone to %y1_1 and %y1_2.363define void @test1_1(ptr %x1_1, ptr %y1_1, i1 %c) {364; TUNIT: Function Attrs: nofree nosync nounwind memory(write)365; TUNIT-LABEL: define {{[^@]+}}@test1_1366; TUNIT-SAME: (ptr nofree readnone captures(none) [[X1_1:%.*]], ptr nofree readnone captures(none) [[Y1_1:%.*]], i1 [[C:%.*]]) #[[ATTR7:[0-9]+]] {367; TUNIT-NEXT:    [[TMP1:%.*]] = call ptr @test1_2(ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone "no-capture-maybe-returned" [[Y1_1]], i1 noundef [[C]]) #[[ATTR7]]368; TUNIT-NEXT:    store ptr null, ptr @g, align 8369; TUNIT-NEXT:    ret void370;371; CGSCC: Function Attrs: nofree nosync nounwind memory(write)372; CGSCC-LABEL: define {{[^@]+}}@test1_1373; CGSCC-SAME: (ptr nofree readnone captures(none) [[X1_1:%.*]], ptr nofree readnone captures(none) [[Y1_1:%.*]], i1 [[C:%.*]]) #[[ATTR10:[0-9]+]] {374; CGSCC-NEXT:    [[TMP1:%.*]] = call ptr @test1_2(ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone "no-capture-maybe-returned" [[Y1_1]], i1 noundef [[C]]) #[[ATTR10]]375; CGSCC-NEXT:    store ptr null, ptr @g, align 8376; CGSCC-NEXT:    ret void377;378  call ptr @test1_2(ptr %x1_1, ptr %y1_1, i1 %c)379  store ptr null, ptr @g380  ret void381}382 383define ptr @test1_2(ptr %x1_2, ptr %y1_2, i1 %c) {384; TUNIT: Function Attrs: nofree nosync nounwind memory(write)385; TUNIT-LABEL: define {{[^@]+}}@test1_2386; TUNIT-SAME: (ptr nofree readnone captures(none) [[X1_2:%.*]], ptr nofree readnone returned "no-capture-maybe-returned" [[Y1_2:%.*]], i1 noundef [[C:%.*]]) #[[ATTR7]] {387; TUNIT-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]388; TUNIT:       t:389; TUNIT-NEXT:    call void @test1_1(ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone captures(none) [[Y1_2]], i1 noundef [[C]]) #[[ATTR7]]390; TUNIT-NEXT:    store ptr null, ptr @g, align 8391; TUNIT-NEXT:    br label [[F]]392; TUNIT:       f:393; TUNIT-NEXT:    ret ptr [[Y1_2]]394;395; CGSCC: Function Attrs: nofree nosync nounwind memory(write)396; CGSCC-LABEL: define {{[^@]+}}@test1_2397; CGSCC-SAME: (ptr nofree readnone captures(none) [[X1_2:%.*]], ptr nofree readnone returned "no-capture-maybe-returned" [[Y1_2:%.*]], i1 noundef [[C:%.*]]) #[[ATTR10]] {398; CGSCC-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]399; CGSCC:       t:400; CGSCC-NEXT:    call void @test1_1(ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone captures(none) [[Y1_2]], i1 noundef [[C]]) #[[ATTR10]]401; CGSCC-NEXT:    store ptr null, ptr @g, align 8402; CGSCC-NEXT:    br label [[F]]403; CGSCC:       f:404; CGSCC-NEXT:    ret ptr [[Y1_2]]405;406  br i1 %c, label %t, label %f407t:408  call void @test1_1(ptr %x1_2, ptr %y1_2, i1 %c)409  store ptr null, ptr @g410  br label %f411f:412  ret ptr %y1_2413}414 415define void @test2(ptr %x2) {416; TUNIT: Function Attrs: nofree nosync nounwind memory(write)417; TUNIT-LABEL: define {{[^@]+}}@test2418; TUNIT-SAME: (ptr nofree readnone captures(none) [[X2:%.*]]) #[[ATTR7]] {419; TUNIT-NEXT:    call void @test2(ptr noalias nofree readnone captures(none) undef) #[[ATTR7]]420; TUNIT-NEXT:    store ptr null, ptr @g, align 8421; TUNIT-NEXT:    ret void422;423; CGSCC: Function Attrs: nofree nosync nounwind memory(write)424; CGSCC-LABEL: define {{[^@]+}}@test2425; CGSCC-SAME: (ptr nofree readnone captures(none) [[X2:%.*]]) #[[ATTR10]] {426; CGSCC-NEXT:    call void @test2(ptr noalias nofree readnone captures(none) undef) #[[ATTR10]]427; CGSCC-NEXT:    store ptr null, ptr @g, align 8428; CGSCC-NEXT:    ret void429;430  call void @test2(ptr %x2)431  store ptr null, ptr @g432  ret void433}434 435define void @test3(ptr %x3, ptr %y3, ptr %z3) {436; TUNIT: Function Attrs: nofree nosync nounwind memory(write)437; TUNIT-LABEL: define {{[^@]+}}@test3438; TUNIT-SAME: (ptr nofree readnone captures(none) [[X3:%.*]], ptr nofree readnone captures(none) [[Y3:%.*]], ptr nofree readnone captures(none) [[Z3:%.*]]) #[[ATTR7]] {439; TUNIT-NEXT:    call void @test3(ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone captures(none) undef) #[[ATTR7]]440; TUNIT-NEXT:    store ptr null, ptr @g, align 8441; TUNIT-NEXT:    ret void442;443; CGSCC: Function Attrs: nofree nosync nounwind memory(write)444; CGSCC-LABEL: define {{[^@]+}}@test3445; CGSCC-SAME: (ptr nofree readnone captures(none) [[X3:%.*]], ptr nofree readnone captures(none) [[Y3:%.*]], ptr nofree readnone captures(none) [[Z3:%.*]]) #[[ATTR10]] {446; CGSCC-NEXT:    call void @test3(ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone captures(none) undef) #[[ATTR10]]447; CGSCC-NEXT:    store ptr null, ptr @g, align 8448; CGSCC-NEXT:    ret void449;450  call void @test3(ptr %z3, ptr %y3, ptr %x3)451  store ptr null, ptr @g452  ret void453}454 455define void @test4_1(ptr %x4_1, i1 %c) {456; TUNIT: Function Attrs: nofree nosync nounwind memory(write)457; TUNIT-LABEL: define {{[^@]+}}@test4_1458; TUNIT-SAME: (ptr nofree readnone captures(none) [[X4_1:%.*]], i1 [[C:%.*]]) #[[ATTR7]] {459; TUNIT-NEXT:    [[TMP1:%.*]] = call ptr @test4_2(ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone "no-capture-maybe-returned" [[X4_1]], ptr noalias nofree readnone captures(none) undef, i1 noundef [[C]]) #[[ATTR7]]460; TUNIT-NEXT:    store ptr null, ptr @g, align 8461; TUNIT-NEXT:    ret void462;463; CGSCC: Function Attrs: nofree nosync nounwind memory(write)464; CGSCC-LABEL: define {{[^@]+}}@test4_1465; CGSCC-SAME: (ptr nofree readnone captures(none) [[X4_1:%.*]], i1 [[C:%.*]]) #[[ATTR10]] {466; CGSCC-NEXT:    [[TMP1:%.*]] = call ptr @test4_2(ptr noalias nofree readnone captures(none) undef, ptr noalias nofree readnone "no-capture-maybe-returned" [[X4_1]], ptr noalias nofree readnone captures(none) undef, i1 noundef [[C]]) #[[ATTR10]]467; CGSCC-NEXT:    store ptr null, ptr @g, align 8468; CGSCC-NEXT:    ret void469;470  call ptr @test4_2(ptr %x4_1, ptr %x4_1, ptr %x4_1, i1 %c)471  store ptr null, ptr @g472  ret void473}474 475define ptr @test4_2(ptr %x4_2, ptr %y4_2, ptr %z4_2, i1 %c) {476; TUNIT: Function Attrs: nofree nosync nounwind memory(write)477; TUNIT-LABEL: define {{[^@]+}}@test4_2478; TUNIT-SAME: (ptr nofree readnone captures(none) [[X4_2:%.*]], ptr nofree readnone returned "no-capture-maybe-returned" [[Y4_2:%.*]], ptr nofree readnone captures(none) [[Z4_2:%.*]], i1 noundef [[C:%.*]]) #[[ATTR7]] {479; TUNIT-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]480; TUNIT:       t:481; TUNIT-NEXT:    call void @test4_1(ptr nofree noundef readnone null, i1 noundef [[C]]) #[[ATTR7]]482; TUNIT-NEXT:    store ptr null, ptr @g, align 8483; TUNIT-NEXT:    br label [[F]]484; TUNIT:       f:485; TUNIT-NEXT:    ret ptr [[Y4_2]]486;487; CGSCC: Function Attrs: nofree nosync nounwind memory(write)488; CGSCC-LABEL: define {{[^@]+}}@test4_2489; CGSCC-SAME: (ptr nofree readnone captures(none) [[X4_2:%.*]], ptr nofree readnone returned "no-capture-maybe-returned" [[Y4_2:%.*]], ptr nofree readnone captures(none) [[Z4_2:%.*]], i1 noundef [[C:%.*]]) #[[ATTR10]] {490; CGSCC-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]491; CGSCC:       t:492; CGSCC-NEXT:    call void @test4_1(ptr nofree noundef readnone null, i1 noundef [[C]]) #[[ATTR10]]493; CGSCC-NEXT:    store ptr null, ptr @g, align 8494; CGSCC-NEXT:    br label [[F]]495; CGSCC:       f:496; CGSCC-NEXT:    ret ptr [[Y4_2]]497;498  br i1 %c, label %t, label %f499t:500  call void @test4_1(ptr null, i1 %c)501  store ptr null, ptr @g502  br label %f503f:504  ret ptr %y4_2505}506 507declare ptr @test5_1(ptr %x5_1)508 509define void @test5_2(ptr %x5_2) {510; CHECK-LABEL: define {{[^@]+}}@test5_2511; CHECK-SAME: (ptr [[X5_2:%.*]]) {512; CHECK-NEXT:    [[TMP1:%.*]] = call ptr @test5_1(ptr [[X5_2]])513; CHECK-NEXT:    store ptr null, ptr @g, align 8514; CHECK-NEXT:    ret void515;516  call ptr @test5_1(ptr %x5_2)517  store ptr null, ptr @g518  ret void519}520 521declare void @test6_1(ptr %x6_1, ptr nocapture %y6_1, ...)522 523define void @test6_2(ptr %x6_2, ptr %y6_2, ptr %z6_2) {524; CHECK-LABEL: define {{[^@]+}}@test6_2525; CHECK-SAME: (ptr [[X6_2:%.*]], ptr captures(none) [[Y6_2:%.*]], ptr [[Z6_2:%.*]]) {526; CHECK-NEXT:    call void (ptr, ptr, ...) @test6_1(ptr [[X6_2]], ptr captures(none) [[Y6_2]], ptr [[Z6_2]])527; CHECK-NEXT:    store ptr null, ptr @g, align 8528; CHECK-NEXT:    ret void529;530  call void (ptr, ptr, ...) @test6_1(ptr %x6_2, ptr %y6_2, ptr %z6_2)531  store ptr null, ptr @g532  ret void533}534 535define void @test_cmpxchg(ptr %p) {536; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)537; TUNIT-LABEL: define {{[^@]+}}@test_cmpxchg538; TUNIT-SAME: (ptr nofree noundef nonnull align 4 captures(none) dereferenceable(4) [[P:%.*]]) #[[ATTR8:[0-9]+]] {539; TUNIT-NEXT:    [[TMP1:%.*]] = cmpxchg ptr [[P]], i32 0, i32 1 acquire monotonic, align 4540; TUNIT-NEXT:    ret void541;542; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)543; CGSCC-LABEL: define {{[^@]+}}@test_cmpxchg544; CGSCC-SAME: (ptr nofree noundef nonnull align 4 captures(none) dereferenceable(4) [[P:%.*]]) #[[ATTR11:[0-9]+]] {545; CGSCC-NEXT:    [[TMP1:%.*]] = cmpxchg ptr [[P]], i32 0, i32 1 acquire monotonic, align 4546; CGSCC-NEXT:    ret void547;548  cmpxchg ptr %p, i32 0, i32 1 acquire monotonic549  ret void550}551 552define void @test_cmpxchg_ptr(ptr %p, ptr %q) {553; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)554; TUNIT-LABEL: define {{[^@]+}}@test_cmpxchg_ptr555; TUNIT-SAME: (ptr nofree noundef nonnull align 8 captures(none) dereferenceable(8) [[P:%.*]], ptr nofree [[Q:%.*]]) #[[ATTR8]] {556; TUNIT-NEXT:    [[TMP1:%.*]] = cmpxchg ptr [[P]], ptr null, ptr [[Q]] acquire monotonic, align 8557; TUNIT-NEXT:    ret void558;559; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)560; CGSCC-LABEL: define {{[^@]+}}@test_cmpxchg_ptr561; CGSCC-SAME: (ptr nofree noundef nonnull align 8 captures(none) dereferenceable(8) [[P:%.*]], ptr nofree [[Q:%.*]]) #[[ATTR11]] {562; CGSCC-NEXT:    [[TMP1:%.*]] = cmpxchg ptr [[P]], ptr null, ptr [[Q]] acquire monotonic, align 8563; CGSCC-NEXT:    ret void564;565  cmpxchg ptr %p, ptr null, ptr %q acquire monotonic566  ret void567}568 569define void @test_atomicrmw(ptr %p) {570; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)571; TUNIT-LABEL: define {{[^@]+}}@test_atomicrmw572; TUNIT-SAME: (ptr nofree noundef nonnull align 4 captures(none) dereferenceable(4) [[P:%.*]]) #[[ATTR8]] {573; TUNIT-NEXT:    [[TMP1:%.*]] = atomicrmw add ptr [[P]], i32 1 seq_cst, align 4574; TUNIT-NEXT:    ret void575;576; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)577; CGSCC-LABEL: define {{[^@]+}}@test_atomicrmw578; CGSCC-SAME: (ptr nofree noundef nonnull align 4 captures(none) dereferenceable(4) [[P:%.*]]) #[[ATTR11]] {579; CGSCC-NEXT:    [[TMP1:%.*]] = atomicrmw add ptr [[P]], i32 1 seq_cst, align 4580; CGSCC-NEXT:    ret void581;582  atomicrmw add ptr %p, i32 1 seq_cst583  ret void584}585 586define void @test_volatile(ptr %x) {587; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)588; TUNIT-LABEL: define {{[^@]+}}@test_volatile589; TUNIT-SAME: (ptr nofree align 4 [[X:%.*]]) #[[ATTR8]] {590; TUNIT-NEXT:  entry:591; TUNIT-NEXT:    [[GEP:%.*]] = getelementptr i32, ptr [[X]], i64 1592; TUNIT-NEXT:    store volatile i32 0, ptr [[GEP]], align 4593; TUNIT-NEXT:    ret void594;595; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)596; CGSCC-LABEL: define {{[^@]+}}@test_volatile597; CGSCC-SAME: (ptr nofree align 4 [[X:%.*]]) #[[ATTR11]] {598; CGSCC-NEXT:  entry:599; CGSCC-NEXT:    [[GEP:%.*]] = getelementptr i32, ptr [[X]], i64 1600; CGSCC-NEXT:    store volatile i32 0, ptr [[GEP]], align 4601; CGSCC-NEXT:    ret void602;603entry:604  %gep = getelementptr i32, ptr %x, i64 1605  store volatile i32 0, ptr %gep, align 4606  ret void607}608 609define void @nocaptureLaunder(ptr %p) {610; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)611; TUNIT-LABEL: define {{[^@]+}}@nocaptureLaunder612; TUNIT-SAME: (ptr nofree captures(none) [[P:%.*]]) #[[ATTR9:[0-9]+]] {613; TUNIT-NEXT:  entry:614; TUNIT-NEXT:    [[B:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr nofree [[P]]) #[[ATTR21:[0-9]+]]615; TUNIT-NEXT:    store i8 42, ptr [[B]], align 1616; TUNIT-NEXT:    ret void617;618; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)619; CGSCC-LABEL: define {{[^@]+}}@nocaptureLaunder620; CGSCC-SAME: (ptr nofree captures(none) [[P:%.*]]) #[[ATTR12:[0-9]+]] {621; CGSCC-NEXT:  entry:622; CGSCC-NEXT:    [[B:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr nofree [[P]]) #[[ATTR24:[0-9]+]]623; CGSCC-NEXT:    store i8 42, ptr [[B]], align 1624; CGSCC-NEXT:    ret void625;626entry:627  %b = call ptr @llvm.launder.invariant.group.p0(ptr %p)628  store i8 42, ptr %b629  ret void630}631 632@g2 = global ptr null633define void @captureLaunder(ptr %p) {634; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn635; TUNIT-LABEL: define {{[^@]+}}@captureLaunder636; TUNIT-SAME: (ptr nofree [[P:%.*]]) #[[ATTR5]] {637; TUNIT-NEXT:    [[B:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr nofree [[P]]) #[[ATTR21]]638; TUNIT-NEXT:    store ptr [[B]], ptr @g2, align 8639; TUNIT-NEXT:    ret void640;641; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn642; CGSCC-LABEL: define {{[^@]+}}@captureLaunder643; CGSCC-SAME: (ptr nofree [[P:%.*]]) #[[ATTR7]] {644; CGSCC-NEXT:    [[B:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr nofree [[P]]) #[[ATTR24]]645; CGSCC-NEXT:    store ptr [[B]], ptr @g2, align 8646; CGSCC-NEXT:    ret void647;648  %b = call ptr @llvm.launder.invariant.group.p0(ptr %p)649  store ptr %b, ptr @g2650  ret void651}652 653define void @nocaptureStrip(ptr %p) {654; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)655; TUNIT-LABEL: define {{[^@]+}}@nocaptureStrip656; TUNIT-SAME: (ptr nofree writeonly captures(none) [[P:%.*]]) #[[ATTR10:[0-9]+]] {657; TUNIT-NEXT:  entry:658; TUNIT-NEXT:    [[B:%.*]] = call ptr @llvm.strip.invariant.group.p0(ptr noalias nofree readnone [[P]]) #[[ATTR22:[0-9]+]]659; TUNIT-NEXT:    store i8 42, ptr [[B]], align 1660; TUNIT-NEXT:    ret void661;662; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)663; CGSCC-LABEL: define {{[^@]+}}@nocaptureStrip664; CGSCC-SAME: (ptr nofree writeonly captures(none) [[P:%.*]]) #[[ATTR13:[0-9]+]] {665; CGSCC-NEXT:  entry:666; CGSCC-NEXT:    [[B:%.*]] = call ptr @llvm.strip.invariant.group.p0(ptr noalias nofree readnone [[P]]) #[[ATTR21]]667; CGSCC-NEXT:    store i8 42, ptr [[B]], align 1668; CGSCC-NEXT:    ret void669;670entry:671  %b = call ptr @llvm.strip.invariant.group.p0(ptr %p)672  store i8 42, ptr %b673  ret void674}675 676@g3 = global ptr null677define void @captureStrip(ptr %p) {678; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)679; TUNIT-LABEL: define {{[^@]+}}@captureStrip680; TUNIT-SAME: (ptr nofree writeonly [[P:%.*]]) #[[ATTR1]] {681; TUNIT-NEXT:    [[B:%.*]] = call ptr @llvm.strip.invariant.group.p0(ptr noalias nofree readnone [[P]]) #[[ATTR22]]682; TUNIT-NEXT:    store ptr [[B]], ptr @g3, align 8683; TUNIT-NEXT:    ret void684;685; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)686; CGSCC-LABEL: define {{[^@]+}}@captureStrip687; CGSCC-SAME: (ptr nofree writeonly [[P:%.*]]) #[[ATTR1]] {688; CGSCC-NEXT:    [[B:%.*]] = call ptr @llvm.strip.invariant.group.p0(ptr noalias nofree readnone [[P]]) #[[ATTR21]]689; CGSCC-NEXT:    store ptr [[B]], ptr @g3, align 8690; CGSCC-NEXT:    ret void691;692  %b = call ptr @llvm.strip.invariant.group.p0(ptr %p)693  store ptr %b, ptr @g3694  ret void695}696 697define i1 @captureICmp(ptr %x) {698; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)699; CHECK-LABEL: define {{[^@]+}}@captureICmp700; CHECK-SAME: (ptr nofree readnone [[X:%.*]]) #[[ATTR0]] {701; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq ptr [[X]], null702; CHECK-NEXT:    ret i1 [[TMP1]]703;704  %1 = icmp eq ptr %x, null705  ret i1 %1706}707 708define i1 @captureICmpRev(ptr %x) {709; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)710; CHECK-LABEL: define {{[^@]+}}@captureICmpRev711; CHECK-SAME: (ptr nofree readnone [[X:%.*]]) #[[ATTR0]] {712; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq ptr null, [[X]]713; CHECK-NEXT:    ret i1 [[TMP1]]714;715  %1 = icmp eq ptr null, %x716  ret i1 %1717}718 719define i1 @nocaptureInboundsGEPICmp(ptr %x) {720; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)721; CHECK-LABEL: define {{[^@]+}}@nocaptureInboundsGEPICmp722; CHECK-SAME: (ptr nofree readnone captures(none) [[X:%.*]]) #[[ATTR0]] {723; CHECK-NEXT:    ret i1 false724;725  %1 = getelementptr inbounds i32, ptr %x, i32 5726  %2 = icmp eq ptr %1, null727  ret i1 %2728}729 730define i1 @nocaptureInboundsGEPICmpRev(ptr %x) {731; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)732; CHECK-LABEL: define {{[^@]+}}@nocaptureInboundsGEPICmpRev733; CHECK-SAME: (ptr nofree readnone captures(none) [[X:%.*]]) #[[ATTR0]] {734; CHECK-NEXT:    ret i1 true735;736  %1 = getelementptr inbounds i32, ptr %x, i32 5737  %2 = icmp ne ptr null, %1738  ret i1 %2739}740 741define i1 @nocaptureDereferenceableOrNullICmp(ptr dereferenceable_or_null(4) %x) {742; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)743; CHECK-LABEL: define {{[^@]+}}@nocaptureDereferenceableOrNullICmp744; CHECK-SAME: (ptr nofree noundef readnone dereferenceable_or_null(4) [[X:%.*]]) #[[ATTR0]] {745; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq ptr [[X]], null746; CHECK-NEXT:    ret i1 [[TMP1]]747;748  %1 = icmp eq ptr %x, null749  ret i1 %1750}751 752define i1 @captureDereferenceableOrNullICmp(ptr dereferenceable_or_null(4) %x) null_pointer_is_valid {753; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind null_pointer_is_valid willreturn memory(none)754; TUNIT-LABEL: define {{[^@]+}}@captureDereferenceableOrNullICmp755; TUNIT-SAME: (ptr nofree noundef readnone dereferenceable_or_null(4) [[X:%.*]]) #[[ATTR11:[0-9]+]] {756; TUNIT-NEXT:    [[TMP1:%.*]] = icmp eq ptr [[X]], null757; TUNIT-NEXT:    ret i1 [[TMP1]]758;759; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind null_pointer_is_valid willreturn memory(none)760; CGSCC-LABEL: define {{[^@]+}}@captureDereferenceableOrNullICmp761; CGSCC-SAME: (ptr nofree noundef readnone dereferenceable_or_null(4) [[X:%.*]]) #[[ATTR14:[0-9]+]] {762; CGSCC-NEXT:    [[TMP1:%.*]] = icmp eq ptr [[X]], null763; CGSCC-NEXT:    ret i1 [[TMP1]]764;765  %1 = icmp eq ptr %x, null766  ret i1 %1767}768 769declare void @unknown(ptr)770; We know that 'null' in AS 0 does not alias anything and cannot be captured. Though the latter is not qurried -> derived atm.771define void @test_callsite() {772; CHECK-LABEL: define {{[^@]+}}@test_callsite() {773; CHECK-NEXT:  entry:774; CHECK-NEXT:    call void @unknown(ptr noundef null)775; CHECK-NEXT:    ret void776;777entry:778  call void @unknown(ptr null)779  ret void780}781 782declare ptr @unknownpi8pi8(ptr,ptr returned)783define ptr @test_returned1(ptr %A, ptr returned %B) nounwind readonly {784; TUNIT: Function Attrs: nosync nounwind memory(read)785; TUNIT-LABEL: define {{[^@]+}}@test_returned1786; TUNIT-SAME: (ptr captures(none) [[A:%.*]], ptr returned [[B:%.*]]) #[[ATTR12:[0-9]+]] {787; TUNIT-NEXT:  entry:788; TUNIT-NEXT:    [[P:%.*]] = call ptr @unknownpi8pi8(ptr [[A]], ptr [[B]])789; TUNIT-NEXT:    ret ptr [[P]]790;791; CGSCC: Function Attrs: nosync nounwind memory(read)792; CGSCC-LABEL: define {{[^@]+}}@test_returned1793; CGSCC-SAME: (ptr captures(none) [[A:%.*]], ptr returned [[B:%.*]]) #[[ATTR15:[0-9]+]] {794; CGSCC-NEXT:  entry:795; CGSCC-NEXT:    [[P:%.*]] = call ptr @unknownpi8pi8(ptr [[A]], ptr [[B]])796; CGSCC-NEXT:    ret ptr [[P]]797;798entry:799  %p = call ptr @unknownpi8pi8(ptr %A, ptr %B)800  ret ptr %p801}802 803define ptr @test_returned2(ptr %A, ptr %B) {804; TUNIT: Function Attrs: nosync nounwind memory(read)805; TUNIT-LABEL: define {{[^@]+}}@test_returned2806; TUNIT-SAME: (ptr readonly [[A:%.*]], ptr readonly [[B:%.*]]) #[[ATTR12]] {807; TUNIT-NEXT:  entry:808; TUNIT-NEXT:    [[P:%.*]] = call ptr @unknownpi8pi8(ptr readonly [[A]], ptr readonly [[B]]) #[[ATTR12]]809; TUNIT-NEXT:    ret ptr [[P]]810;811; CGSCC: Function Attrs: nosync nounwind memory(read)812; CGSCC-LABEL: define {{[^@]+}}@test_returned2813; CGSCC-SAME: (ptr readonly [[A:%.*]], ptr readonly [[B:%.*]]) #[[ATTR15]] {814; CGSCC-NEXT:  entry:815; CGSCC-NEXT:    [[P:%.*]] = call ptr @unknownpi8pi8(ptr readonly [[A]], ptr readonly [[B]]) #[[ATTR15]]816; CGSCC-NEXT:    ret ptr [[P]]817;818entry:819  %p = call ptr @unknownpi8pi8(ptr %A, ptr %B) nounwind readonly820  ret ptr %p821}822 823declare ptr @maybe_returned_ptr(ptr readonly %ptr) readonly nounwind willreturn824declare i8 @maybe_returned_val(ptr %ptr) readonly nounwind willreturn825declare void @val_use(i8 %ptr) readonly nounwind willreturn826 827; FIXME: Both pointers should be nocapture828define void @ptr_uses(ptr %ptr, ptr %wptr) {829; TUNIT: Function Attrs: mustprogress nosync nounwind willreturn830; TUNIT-LABEL: define {{[^@]+}}@ptr_uses831; TUNIT-SAME: (ptr nofree [[PTR:%.*]], ptr nofree noundef nonnull writeonly captures(none) dereferenceable(1) [[WPTR:%.*]]) #[[ATTR14:[0-9]+]] {832; TUNIT-NEXT:    store i8 0, ptr [[WPTR]], align 1833; TUNIT-NEXT:    ret void834;835; CGSCC: Function Attrs: mustprogress nosync nounwind willreturn836; CGSCC-LABEL: define {{[^@]+}}@ptr_uses837; CGSCC-SAME: (ptr nofree [[PTR:%.*]], ptr nofree noundef nonnull writeonly captures(none) dereferenceable(1) [[WPTR:%.*]]) #[[ATTR17:[0-9]+]] {838; CGSCC-NEXT:    store i8 0, ptr [[WPTR]], align 1839; CGSCC-NEXT:    ret void840;841  %call_ptr = call ptr @maybe_returned_ptr(ptr %ptr)842  %call_val = call i8 @maybe_returned_val(ptr %call_ptr)843  call void @val_use(i8 %call_val)844  store i8 0, ptr %wptr845  ret void846}847 848declare ptr @llvm.launder.invariant.group.p0(ptr)849declare ptr @llvm.strip.invariant.group.p0(ptr)850;.851; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }852; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }853; TUNIT: attributes #[[ATTR2]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(read) }854; TUNIT: attributes #[[ATTR3:[0-9]+]] = { memory(read) }855; TUNIT: attributes #[[ATTR4]] = { nosync memory(read) }856; TUNIT: attributes #[[ATTR5]] = { mustprogress nofree norecurse nosync nounwind willreturn }857; TUNIT: attributes #[[ATTR6]] = { nounwind memory(argmem: readwrite) }858; TUNIT: attributes #[[ATTR7]] = { nofree nosync nounwind memory(write) }859; TUNIT: attributes #[[ATTR8]] = { mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite) }860; TUNIT: attributes #[[ATTR9]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) }861; TUNIT: attributes #[[ATTR10]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }862; TUNIT: attributes #[[ATTR11]] = { mustprogress nofree norecurse nosync nounwind null_pointer_is_valid willreturn memory(none) }863; TUNIT: attributes #[[ATTR12]] = { nosync nounwind memory(read) }864; TUNIT: attributes #[[ATTR13:[0-9]+]] = { nounwind willreturn memory(read) }865; TUNIT: attributes #[[ATTR14]] = { mustprogress nosync nounwind willreturn }866; TUNIT: attributes #[[ATTR15:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(inaccessiblemem: readwrite) }867; TUNIT: attributes #[[ATTR16:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }868; TUNIT: attributes #[[ATTR17]] = { nofree nosync nounwind willreturn memory(write) }869; TUNIT: attributes #[[ATTR18]] = { nofree nosync nounwind willreturn memory(none) }870; TUNIT: attributes #[[ATTR19]] = { nofree nosync nounwind willreturn }871; TUNIT: attributes #[[ATTR20]] = { nounwind }872; TUNIT: attributes #[[ATTR21]] = { nofree willreturn }873; TUNIT: attributes #[[ATTR22]] = { nofree nosync willreturn }874;.875; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }876; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }877; CGSCC: attributes #[[ATTR2]] = { mustprogress nofree nosync nounwind willreturn memory(write) }878; CGSCC: attributes #[[ATTR3]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(read) }879; CGSCC: attributes #[[ATTR4:[0-9]+]] = { memory(read) }880; CGSCC: attributes #[[ATTR5]] = { nosync memory(read) }881; CGSCC: attributes #[[ATTR6]] = { mustprogress nofree nosync nounwind willreturn memory(read) }882; CGSCC: attributes #[[ATTR7]] = { mustprogress nofree norecurse nosync nounwind willreturn }883; CGSCC: attributes #[[ATTR8]] = { mustprogress nofree nosync nounwind willreturn }884; CGSCC: attributes #[[ATTR9]] = { nounwind memory(argmem: readwrite) }885; CGSCC: attributes #[[ATTR10]] = { nofree nosync nounwind memory(write) }886; CGSCC: attributes #[[ATTR11]] = { mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite) }887; CGSCC: attributes #[[ATTR12]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) }888; CGSCC: attributes #[[ATTR13]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }889; CGSCC: attributes #[[ATTR14]] = { mustprogress nofree norecurse nosync nounwind null_pointer_is_valid willreturn memory(none) }890; CGSCC: attributes #[[ATTR15]] = { nosync nounwind memory(read) }891; CGSCC: attributes #[[ATTR16:[0-9]+]] = { nounwind willreturn memory(read) }892; CGSCC: attributes #[[ATTR17]] = { mustprogress nosync nounwind willreturn }893; CGSCC: attributes #[[ATTR18:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(inaccessiblemem: readwrite) }894; CGSCC: attributes #[[ATTR19:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }895; CGSCC: attributes #[[ATTR20]] = { nofree nounwind willreturn memory(write) }896; CGSCC: attributes #[[ATTR21]] = { nofree nosync willreturn }897; CGSCC: attributes #[[ATTR22]] = { nofree nounwind willreturn }898; CGSCC: attributes #[[ATTR23]] = { nounwind }899; CGSCC: attributes #[[ATTR24]] = { nofree willreturn }900;.901