1; MRE for SCC splitting causing MLInlineAdvisor to lose track of edges 2; foo and bar both call inlineme; inlineme calls only foo and bar 3; when the foo-bar-inlineme SCC reaches the inliner, foo-bar will be split out 4; leaving inlineme in the SCC. inlineme is dead, so it gets removed from the SCC 5; However, MLInlineAdvisor should still track the edges of foo and bar onPassExit 6; as the foo-bar SCC will be passed on to the next SCC pass in the pipeline 7; and as a result could gain/lose edges before the inliner sees it again 8 9; In this example if loop-unroll is ran after a mandatory inlining CGSCC pass, 10; edges would increase but wouldn't be tracked 11 12; REQUIRES: llvm_inliner_model_autogenerated 13 14; RUN: opt -enable-ml-inliner=release -passes=inliner-ml-advisor-release \ 15; RUN: -keep-inline-advisor-for-printing \ 16; RUN: -enable-scc-inline-advisor-printing -S < %s 2>&1 | FileCheck %s 17 18target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 19target triple = "x86_64-unknown-linux-gnu" 20 21define internal void @_Z8inlinemei() inlinehint alwaysinline { 22entry: 23 %call2 = call noundef i32 @_Z3bari(i32 noundef 12321) 24 %call3 = call noundef i32 @_Z3fooi(i32 noundef 12321) 25 ret void 26} 27 28define dso_local noundef i32 @_Z3bari(i32 noundef %y) { 29entry: 30 call void @_Z8inlinemei() 31 ret i32 %y 32} 33 34define dso_local noundef i32 @main(i32 noundef %argc, ptr noundef %argv) { 35entry: 36 %call = call noundef i32 @_Z3fooi(i32 noundef %argc) 37 ret i32 %call 38} 39 40define dso_local noundef i32 @_Z3fooi(i32 noundef %z) { 41entry: 42 %a = alloca i32, align 4 43 br label %for.body 44 45for.body: 46 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 47 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv 48 %0 = load i32, ptr %arrayidx, align 4 49 %inc = add nsw i32 %0, 1 50 store i32 %inc, ptr %arrayidx, align 4 51 call void @_Z8inlinemei() 52 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 53 %exitcond = icmp eq i64 %indvars.iv.next, 10 54 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !5 55 56for.end: 57 ret i32 %z 58} 59 60!llvm.module.flags = !{!0, !1, !2, !3, !4} 61 62!0 = !{i32 1, !"wchar_size", i32 4} 63!1 = !{i32 7, !"PIC Level", i32 2} 64!2 = !{i32 7, !"PIE Level", i32 2} 65!3 = !{i32 7, !"uwtable", i32 2} 66!4 = !{i32 7, !"frame-pointer", i32 2} 67!5 = !{!5, !{!"llvm.loop.disable_nonforced"}, !{!"llvm.loop.unroll.enable"}} 68 69; CHECK: [MLInlineAdvisor] Nodes: 3 Edges: 5 EdgesOfLastSeenNodes: 4 70; CHECK: [MLInlineAdvisor] Nodes: 3 Edges: 5 EdgesOfLastSeenNodes: 4 71; CHECK: [MLInlineAdvisor] Nodes: 3 Edges: 5 EdgesOfLastSeenNodes: 4 72; CHECK: [MLInlineAdvisor] Nodes: 3 Edges: 5 EdgesOfLastSeenNodes: 4 73; CHECK: [MLInlineAdvisor] Nodes: 3 Edges: 5 EdgesOfLastSeenNodes: 1 74