1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals 2; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=8 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM 3; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=8 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM 4; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM 5; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM 6target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 7target triple = "x86_64-unknown-linux-gnu" 8 9define void @fn2(i32* %P, i1 %C) { 10; 11; IS__TUNIT____: Function Attrs: argmemonly nofree norecurse nosync nounwind 12; IS__TUNIT____-LABEL: define {{[^@]+}}@fn2 13; IS__TUNIT____-SAME: (i32* nocapture nofree [[P:%.*]], i1 [[C:%.*]]) #[[ATTR0:[0-9]+]] { 14; IS__TUNIT____-NEXT: entry: 15; IS__TUNIT____-NEXT: br label [[IF_END:%.*]] 16; IS__TUNIT____: for.cond1: 17; IS__TUNIT____-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]] 18; IS__TUNIT____: if.end: 19; IS__TUNIT____-NEXT: [[E_2:%.*]] = phi i32* [ [[P]], [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ] 20; IS__TUNIT____-NEXT: [[TMP0:%.*]] = load i32, i32* [[E_2]], align 4 21; IS__TUNIT____-NEXT: store i32 [[TMP0]], i32* [[P]], align 4 22; IS__TUNIT____-NEXT: br label [[FOR_COND1]] 23; IS__TUNIT____: exit: 24; IS__TUNIT____-NEXT: ret void 25; 26; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind 27; IS__CGSCC____-LABEL: define {{[^@]+}}@fn2 28; IS__CGSCC____-SAME: (i32* nocapture nofree nonnull align 4 dereferenceable(4) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR0:[0-9]+]] { 29; IS__CGSCC____-NEXT: entry: 30; IS__CGSCC____-NEXT: br label [[IF_END:%.*]] 31; IS__CGSCC____: for.cond1: 32; IS__CGSCC____-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]] 33; IS__CGSCC____: if.end: 34; IS__CGSCC____-NEXT: [[E_2:%.*]] = phi i32* [ [[P]], [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ] 35; IS__CGSCC____-NEXT: [[TMP0:%.*]] = load i32, i32* [[E_2]], align 4 36; IS__CGSCC____-NEXT: store i32 [[TMP0]], i32* [[P]], align 4 37; IS__CGSCC____-NEXT: br label [[FOR_COND1]] 38; IS__CGSCC____: exit: 39; IS__CGSCC____-NEXT: ret void 40; 41entry: 42 br label %if.end 43 44for.cond1: ; preds = %if.end 45 br i1 %C, label %if.end, label %exit 46 47if.end: ; preds = %entry, %for.cond1 48 %e.2 = phi i32* [ %P, %entry ], [ null, %for.cond1 ] 49 %0 = load i32, i32* %e.2, align 4 50 %call = call i32 @fn1(i32 %0) 51 store i32 %call, i32* %P 52 br label %for.cond1 53exit: 54 ret void 55} 56 57define internal i32 @fn1(i32 %p1) { 58; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn 59; IS__CGSCC____-LABEL: define {{[^@]+}}@fn1 60; IS__CGSCC____-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1:[0-9]+]] { 61; IS__CGSCC____-NEXT: entry: 62; IS__CGSCC____-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[P1]], 0 63; IS__CGSCC____-NEXT: [[COND:%.*]] = select i1 [[TOBOOL]], i32 [[P1]], i32 [[P1]] 64; IS__CGSCC____-NEXT: ret i32 [[COND]] 65; 66entry: 67 %tobool = icmp ne i32 %p1, 0 68 %cond = select i1 %tobool, i32 %p1, i32 %p1 69 ret i32 %cond 70} 71 72define void @fn_no_null_opt(i32* %P, i1 %C) null_pointer_is_valid { 73; 74; IS__TUNIT____: Function Attrs: nofree norecurse nosync nounwind null_pointer_is_valid 75; IS__TUNIT____-LABEL: define {{[^@]+}}@fn_no_null_opt 76; IS__TUNIT____-SAME: (i32* nocapture nofree writeonly [[P:%.*]], i1 [[C:%.*]]) #[[ATTR1:[0-9]+]] { 77; IS__TUNIT____-NEXT: entry: 78; IS__TUNIT____-NEXT: br label [[IF_END:%.*]] 79; IS__TUNIT____: for.cond1: 80; IS__TUNIT____-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]] 81; IS__TUNIT____: if.end: 82; IS__TUNIT____-NEXT: [[E_2:%.*]] = phi i32* [ undef, [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ] 83; IS__TUNIT____-NEXT: [[TMP0:%.*]] = load i32, i32* null, align 4294967296 84; IS__TUNIT____-NEXT: store i32 [[TMP0]], i32* [[P]], align 4 85; IS__TUNIT____-NEXT: br label [[FOR_COND1]] 86; IS__TUNIT____: exit: 87; IS__TUNIT____-NEXT: ret void 88; 89; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind null_pointer_is_valid 90; IS__CGSCC____-LABEL: define {{[^@]+}}@fn_no_null_opt 91; IS__CGSCC____-SAME: (i32* nocapture nofree writeonly align 4 dereferenceable_or_null(4) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR2:[0-9]+]] { 92; IS__CGSCC____-NEXT: entry: 93; IS__CGSCC____-NEXT: br label [[IF_END:%.*]] 94; IS__CGSCC____: for.cond1: 95; IS__CGSCC____-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]] 96; IS__CGSCC____: if.end: 97; IS__CGSCC____-NEXT: [[E_2:%.*]] = phi i32* [ undef, [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ] 98; IS__CGSCC____-NEXT: store i32 undef, i32* [[P]], align 4 99; IS__CGSCC____-NEXT: br label [[FOR_COND1]] 100; IS__CGSCC____: exit: 101; IS__CGSCC____-NEXT: ret void 102; 103entry: 104 br label %if.end 105 106for.cond1: ; preds = %if.end 107 br i1 %C, label %if.end, label %exit 108 109if.end: ; preds = %entry, %for.cond1 110 %e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ] 111 %0 = load i32, i32* %e.2, align 4 112 %call = call i32 @fn0(i32 %0) 113 store i32 %call, i32* %P 114 br label %for.cond1 115exit: 116 ret void 117} 118 119define internal i32 @fn0(i32 %p1) { 120; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn 121; IS__CGSCC____-LABEL: define {{[^@]+}}@fn0 122; IS__CGSCC____-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1]] { 123; IS__CGSCC____-NEXT: entry: 124; IS__CGSCC____-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[P1]], 0 125; IS__CGSCC____-NEXT: [[COND:%.*]] = select i1 [[TOBOOL]], i32 [[P1]], i32 [[P1]] 126; IS__CGSCC____-NEXT: ret i32 [[COND]] 127; 128entry: 129 %tobool = icmp ne i32 %p1, 0 130 %cond = select i1 %tobool, i32 %p1, i32 %p1 131 ret i32 %cond 132} 133;. 134; IS__TUNIT____: attributes #[[ATTR0]] = { argmemonly nofree norecurse nosync nounwind } 135; IS__TUNIT____: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind null_pointer_is_valid } 136;. 137; IS__CGSCC____: attributes #[[ATTR0]] = { argmemonly nofree norecurse nosync nounwind } 138; IS__CGSCC____: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind readnone willreturn } 139; IS__CGSCC____: attributes #[[ATTR2]] = { nofree norecurse nosync nounwind null_pointer_is_valid } 140;. 141