141 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,CGSCC4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"5target triple = "x86_64-unknown-linux-gnu"6 7define void @fn2(ptr %P, i1 %C) {8;9; TUNIT: Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite)10; TUNIT-LABEL: define {{[^@]+}}@fn211; TUNIT-SAME: (ptr nofree captures(none) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR0:[0-9]+]] {12; TUNIT-NEXT: entry:13; TUNIT-NEXT: br label [[IF_END:%.*]]14; TUNIT: for.cond1:15; TUNIT-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]16; TUNIT: if.end:17; TUNIT-NEXT: [[E_2:%.*]] = phi ptr [ [[P]], [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]18; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[E_2]], align 419; TUNIT-NEXT: store i32 [[TMP0]], ptr [[P]], align 420; TUNIT-NEXT: br label [[FOR_COND1]]21; TUNIT: exit:22; TUNIT-NEXT: ret void23;24; CGSCC: Function Attrs: nofree nosync nounwind memory(argmem: readwrite)25; CGSCC-LABEL: define {{[^@]+}}@fn226; CGSCC-SAME: (ptr nofree nonnull align 4 captures(none) dereferenceable(4) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR0:[0-9]+]] {27; CGSCC-NEXT: entry:28; CGSCC-NEXT: br label [[IF_END:%.*]]29; CGSCC: for.cond1:30; CGSCC-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]31; CGSCC: if.end:32; CGSCC-NEXT: [[E_2:%.*]] = phi ptr [ [[P]], [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]33; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr [[E_2]], align 434; CGSCC-NEXT: [[CALL:%.*]] = call i32 @fn1(i32 [[TMP0]]) #[[ATTR3:[0-9]+]]35; CGSCC-NEXT: store i32 [[CALL]], ptr [[P]], align 436; CGSCC-NEXT: br label [[FOR_COND1]]37; CGSCC: exit:38; CGSCC-NEXT: ret void39;40entry:41 br label %if.end42 43for.cond1: ; preds = %if.end44 br i1 %C, label %if.end, label %exit45 46if.end: ; preds = %entry, %for.cond147 %e.2 = phi ptr [ %P, %entry ], [ null, %for.cond1 ]48 %0 = load i32, ptr %e.2, align 449 %call = call i32 @fn1(i32 %0)50 store i32 %call, ptr %P51 br label %for.cond152exit:53 ret void54}55 56define internal i32 @fn1(i32 %p1) {57; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)58; CGSCC-LABEL: define {{[^@]+}}@fn159; CGSCC-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1:[0-9]+]] {60; CGSCC-NEXT: entry:61; CGSCC-NEXT: ret i32 [[P1]]62;63entry:64 %tobool = icmp ne i32 %p1, 065 %cond = select i1 %tobool, i32 %p1, i32 %p166 ret i32 %cond67}68 69define void @fn_no_null_opt(ptr %P, i1 %C) null_pointer_is_valid {70;71; TUNIT: Function Attrs: nofree norecurse nosync nounwind null_pointer_is_valid72; TUNIT-LABEL: define {{[^@]+}}@fn_no_null_opt73; TUNIT-SAME: (ptr nofree writeonly captures(none) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR1:[0-9]+]] {74; TUNIT-NEXT: entry:75; TUNIT-NEXT: br label [[IF_END:%.*]]76; TUNIT: for.cond1:77; TUNIT-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]78; TUNIT: if.end:79; TUNIT-NEXT: [[E_2:%.*]] = phi ptr [ undef, [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]80; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 429496729681; TUNIT-NEXT: store i32 [[TMP0]], ptr [[P]], align 482; TUNIT-NEXT: br label [[FOR_COND1]]83; TUNIT: exit:84; TUNIT-NEXT: ret void85;86; CGSCC: Function Attrs: nofree nosync nounwind null_pointer_is_valid87; CGSCC-LABEL: define {{[^@]+}}@fn_no_null_opt88; CGSCC-SAME: (ptr nofree writeonly align 4 captures(none) dereferenceable_or_null(4) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR2:[0-9]+]] {89; CGSCC-NEXT: entry:90; CGSCC-NEXT: br label [[IF_END:%.*]]91; CGSCC: for.cond1:92; CGSCC-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]93; CGSCC: if.end:94; CGSCC-NEXT: [[E_2:%.*]] = phi ptr [ undef, [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]95; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 429496729696; CGSCC-NEXT: [[CALL:%.*]] = call i32 @fn0(i32 [[TMP0]]) #[[ATTR3]]97; CGSCC-NEXT: store i32 [[CALL]], ptr [[P]], align 498; CGSCC-NEXT: br label [[FOR_COND1]]99; CGSCC: exit:100; CGSCC-NEXT: ret void101;102entry:103 br label %if.end104 105for.cond1: ; preds = %if.end106 br i1 %C, label %if.end, label %exit107 108if.end: ; preds = %entry, %for.cond1109 %e.2 = phi ptr [ undef, %entry ], [ null, %for.cond1 ]110 %0 = load i32, ptr %e.2, align 4111 %call = call i32 @fn0(i32 %0)112 store i32 %call, ptr %P113 br label %for.cond1114exit:115 ret void116}117 118define internal i32 @fn0(i32 %p1) {119; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)120; CGSCC-LABEL: define {{[^@]+}}@fn0121; CGSCC-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1]] {122; CGSCC-NEXT: entry:123; CGSCC-NEXT: ret i32 [[P1]]124;125entry:126 %tobool = icmp ne i32 %p1, 0127 %cond = select i1 %tobool, i32 %p1, i32 %p1128 ret i32 %cond129}130;.131; TUNIT: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind memory(argmem: readwrite) }132; TUNIT: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind null_pointer_is_valid }133;.134; CGSCC: attributes #[[ATTR0]] = { nofree nosync nounwind memory(argmem: readwrite) }135; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }136; CGSCC: attributes #[[ATTR2]] = { nofree nosync nounwind null_pointer_is_valid }137; CGSCC: attributes #[[ATTR3]] = { nofree nosync }138;.139;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:140; CHECK: {{.*}}141