1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals 2; RUN: opt -passes=attributor-cgscc -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK 3; RUN: opt -passes=attributor-cgscc -disable-output -attributor-print-dep < %s 2>&1 | FileCheck %s --check-prefixes=GRAPH 4; RUN: opt -passes=attributor-cgscc -disable-output -attributor-dump-dep-graph -attributor-depgraph-dot-filename-prefix=%t < %s 2>/dev/null 5; RUN: FileCheck %s -input-file=%t_0.dot --check-prefix=DOT 6 7; Test 0 8; 9; test copied from the attributor introduction video: checkAndAdvance(), and the C code is: 10; int *checkAndAdvance(int * __attribute__((aligned(16))) p) { 11; if (*p == 0) 12; return checkAndAdvance(p + 4); 13; return p; 14; } 15; 16define ptr @checkAndAdvance(ptr align 16 %0) { 17; CHECK: Function Attrs: nofree nosync nounwind memory(argmem: read) 18; CHECK-LABEL: define {{[^@]+}}@checkAndAdvance 19; CHECK-SAME: (ptr nofree noundef nonnull readonly align 16 dereferenceable(4) [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] { 20; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[TMP0]], align 16 21; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP2]], 0 22; CHECK-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP7:%.*]] 23; CHECK: 4: 24; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 4 25; CHECK-NEXT: [[TMP6:%.*]] = call ptr @checkAndAdvance(ptr nofree noundef nonnull readonly align 16 [[TMP5]]) #[[ATTR1:[0-9]+]] 26; CHECK-NEXT: br label [[TMP8:%.*]] 27; CHECK: 7: 28; CHECK-NEXT: br label [[TMP8]] 29; CHECK: 8: 30; CHECK-NEXT: [[DOT0:%.*]] = phi ptr [ [[TMP5]], [[TMP4]] ], [ [[TMP0]], [[TMP7]] ] 31; CHECK-NEXT: ret ptr [[DOT0]] 32; 33 %2 = load i32, ptr %0, align 4 34 %3 = icmp eq i32 %2, 0 35 br i1 %3, label %4, label %7 36 374: ; preds = %1 38 %5 = getelementptr inbounds i32, ptr %0, i64 4 39 %6 = call ptr @checkAndAdvance(ptr %5) 40 br label %8 41 427: ; preds = %1 43 br label %8 44 458: ; preds = %7, %4 46 %.0 = phi ptr [ %6, %4 ], [ %0, %7 ] 47 ret ptr %.0 48} 49 50; 51; Check for graph 52; 53 54 55; GRAPH-NOT: update 56 57; 58; Check for .dot file 59; 60; DOT-DAG: Node[[Node0:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 61; DOT-DAG: Node[[Node1:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 62; DOT-DAG: Node[[Node2:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 63; DOT-DAG: Node[[Node3:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 64; DOT-DAG: Node[[Node4:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 65; DOT-DAG: Node[[Node5:0x[a-z0-9]+]] [shape=record,label="{[AANoReturn] 66; DOT-DAG: Node[[Node6:0x[a-z0-9]+]] [shape=record,label="{[AANoReturn] 67; DOT-DAG: Node[[Node7:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 68; DOT-DAG: Node[[Node8:0x[a-z0-9]+]] [shape=record,label="{[AAWillReturn] 69; DOT-DAG: Node[[Node9:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 70; DOT-DAG: Node[[Node10:0x[a-z0-9]+]] [shape=record,label="{[AANoUnwind] 71; DOT-DAG: Node[[Node11:0x[a-z0-9]+]] [shape=record,label="{[AANoUnwind] 72; DOT-DAG: Node[[Node12:0x[a-z0-9]+]] [shape=record,label="{[AAMemoryLocation] 73; DOT-DAG: Node[[Node13:0x[a-z0-9]+]] [shape=record,label="{[AAMemoryLocation] 74; DOT-DAG: Node[[Node14:0x[a-z0-9]+]] [shape=record,label="{[AAMemoryBehavior] 75; DOT-DAG: Node[[Node15:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 76; DOT-DAG: Node[[Node16:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 77; DOT-DAG: Node[[Node17:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 78; DOT-DAG: Node[[Node18:0x[a-z0-9]+]] [shape=record,label="{[AAMemoryBehavior] 79; DOT-DAG: Node[[Node19:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 80; DOT-DAG: Node[[Node20:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 81; DOT-DAG: Node[[Node22:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 82; DOT-DAG: Node[[Node23:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 83; DOT-DAG: Node[[Node24:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 84; DOT-DAG: Node[[Node25:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 85; DOT-DAG: Node[[Node26:0x[a-z0-9]+]] [shape=record,label="{[AAPotentialValues] 86; DOT-DAG: Node[[Node27:0x[a-z0-9]+]] [shape=record,label="{[AAInstanceInfo] 87; DOT-DAG: Node[[Node28:0x[a-z0-9]+]] [shape=record,label="{[AANoRecurse] 88; DOT-DAG: Node[[Node29:0x[a-z0-9]+]] [shape=record,label="{[AAInterFnReachability] 89; DOT-DAG: Node[[Node30:0x[a-z0-9]+]] [shape=record,label="{[AAIntraFnReachability] 90; DOT-DAG: Node[[Node31:0x[a-z0-9]+]] [shape=record,label="{[AACallEdges] 91; DOT-DAG: Node[[Node32:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 92; DOT-DAG: Node[[Node33:0x[a-z0-9]+]] [shape=record,label="{[AAWillReturn] 93; DOT-DAG: Node[[Node34:0x[a-z0-9]+]] [shape=record,label="{[AANoRecurse] 94; DOT-DAG: Node[[Node35:0x[a-z0-9]+]] [shape=record,label="{[AAUndefinedBehavior] 95; DOT-DAG: Node[[Node36:0x[a-z0-9]+]] [shape=record,label="{[AANoUndef] 96; DOT-DAG: Node[[Node37:0x[a-z0-9]+]] [shape=record,label="{[AANoUndef] 97; DOT-DAG: Node[[Node38:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 98; DOT-DAG: Node[[Node39:0x[a-z0-9]+]] [shape=record,label="{[AANoUndef] 99; DOT-DAG: Node[[Node41:0x[a-z0-9]+]] [shape=record,label="{[AANoSync] 100; DOT-DAG: Node[[Node42:0x[a-z0-9]+]] [shape=record,label="{[AANoSync] 101; DOT-DAG: Node[[Node43:0x[a-z0-9]+]] [shape=record,label="{[AANoFree] 102; DOT-DAG: Node[[Node44:0x[a-z0-9]+]] [shape=record,label="{[AANoFree] 103; DOT-DAG: Node[[Node45:0x[a-z0-9]+]] [shape=record,label="{[AAAssumptionInfo] 104; DOT-DAG: Node[[Node46:0x[a-z0-9]+]] [shape=record,label="{[AAHeapToStack] 105; DOT-DAG: Node[[Node47:0x[a-z0-9]+]] [shape=record,label="{[AAAlign] 106; DOT-DAG: Node[[Node48:0x[a-z0-9]+]] [shape=record,label="{[AAAlign] 107; DOT-DAG: Node[[Node49:0x[a-z0-9]+]] [shape=record,label="{[AAAlign] 108; DOT-DAG: Node[[Node50:0x[a-z0-9]+]] [shape=record,label="{[AAAlign] 109; DOT-DAG: Node[[Node51:0x[a-z0-9]+]] [shape=record,label="{[AANonNull] 110; DOT-DAG: Node[[Node52:0x[a-z0-9]+]] [shape=record,label="{[AANonNull] 111; DOT-DAG: Node[[Node53:0x[a-z0-9]+]] [shape=record,label="{[AANoAlias] 112; DOT-DAG: Node[[Node54:0x[a-z0-9]+]] [shape=record,label="{[AADereferenceable] 113; DOT-DAG: Node[[Node55:0x[a-z0-9]+]] [shape=record,label="{[AADereferenceable] 114; DOT-DAG: Node[[Node56:0x[a-z0-9]+]] [shape=record,label="{[AADereferenceable] 115; DOT-DAG: Node[[Node59:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 116; DOT-DAG: Node[[Node60:0x[a-z0-9]+]] [shape=record,label="{[AANoAlias] 117; DOT-DAG: Node[[Node61:0x[a-z0-9]+]] [shape=record,label="{[AANoCapture] 118; DOT-DAG: Node[[Node62:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 119; DOT-DAG: Node[[Node63:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 120; DOT-DAG: Node[[Node64:0x[a-z0-9]+]] [shape=record,label="{[AANoCapture] 121; DOT-DAG: Node[[Node65:0x[a-z0-9]+]] [shape=record,label="{[AAIsDead] 122; DOT-DAG: Node[[Node66:0x[a-z0-9]+]] [shape=record,label="{[AAMemoryBehavior] 123; DOT-DAG: Node[[Node67:0x[a-z0-9]+]] [shape=record,label="{[AAMemoryBehavior] 124; DOT-DAG: Node[[Node68:0x[a-z0-9]+]] [shape=record,label="{[AANoFree] 125; DOT-DAG: Node[[Node69:0x[a-z0-9]+]] [shape=record,label="{[AAPrivatizablePtr] 126; DOT-DAG: Node[[Node70:0x[a-z0-9]+]] [shape=record,label="{[AAAssumptionInfo] 127; DOT-DAG: Node[[Node71:0x[a-z0-9]+]] [shape=record,label="{[AANoAlias] 128; DOT-DAG: Node[[Node73:0x[a-z0-9]+]] [shape=record,label="{[AANoFree] 129; DOT-DAG: Node[[Node75:0x[a-z0-9]+]] [shape=record,label="{[AAAddressSpace] 130; DOT-DAG: Node[[Node74:0x[a-z0-9]+]] [shape=record,label="{[AADereferenceable] 131 132; DOT-DAG: Node[[Node20]] -> Node[[Node19]]; 133; DOT-DAG: Node[[Node13]] -> Node[[Node12]]; 134; DOT-DAG: Node[[Node55]] -> Node[[Node56]]; 135; DOT-DAG: Node[[Node68]] -> Node[[Node73]]; 136; DOT-DAG: Node[[Node64]] -> Node[[Node61]]; 137; DOT-DAG: Node[[Node61]] -> Node[[Node64]]; 138; DOT-DAG: Node[[Node12]] -> Node[[Node13]]; 139; DOT-DAG: Node[[Node11]] -> Node[[Node61]]; 140; DOT-DAG: Node[[Node14]] -> Node[[Node18]]; 141; DOT-DAG: Node[[Node43]] -> Node[[Node68]]; 142; DOT-DAG: Node[[Node19]] -> Node[[Node22]]; 143; DOT-DAG: Node[[Node10]] -> Node[[Node11]]; 144; DOT-DAG: Node[[Node41]] -> Node[[Node42]]; 145; DOT-DAG: Node[[Node42]] -> Node[[Node41]]; 146; DOT-DAG: Node[[Node11]] -> Node[[Node10]]; 147; DOT-DAG: Node[[Node67]] -> Node[[Node66]]; 148; DOT-DAG: Node[[Node18]] -> Node[[Node14]]; 149; DOT-DAG: Node[[Node66]] -> Node[[Node67]]; 150; DOT-DAG: Node[[Node44]] -> Node[[Node43]]; 151; DOT-DAG: Node[[Node43]] -> Node[[Node44]]; 152;. 153; CHECK: attributes #[[ATTR0]] = { nofree nosync nounwind memory(argmem: read) } 154; CHECK: attributes #[[ATTR1]] = { nofree nosync nounwind memory(read) } 155;. 156;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: 157; GRAPH: {{.*}} 158