<div dir="ltr">Hello,<div><br></div><div>I'm trying to understand why LLVM-12 is removing function which is marked inline despite the fact it was not inlined inside caller. Caller function still has a call to inline function and compilation is failing because of a lack of the symbol.</div><div><br></div><div>Looking at debug logs I see:</div><div><br></div><div>Inliner visiting SCC: sort: 1 call sites.<br>      Analyzing call of calculate... (caller:sort)<br>      .</div><div>      Cost: 960<br>      Threshold: 487<br>    NOT Inlining (cost=960, threshold=487), Call:   call void @calculate(i32* %a, i32* %b)<br></div><div><div><br></div><div>Code:</div><div>int global = 0;<br>void inline calculate(int a[100], int b[100]) {<br>    int i;<br>#pragma unroll<br>    for (i = 0; i < 50; i++) {<br>        a[i] = b[i] + a[i];<br>    }<br>}<br><br>int sort(int a[100], int b[100]) {<br>    calculate(a, b);<br>    return a[20] + b[30] + global;<br>}<br></div><div><br></div><div>cli: clang -O3 -c inline1.c -o inline1_clang.o</div><div><br></div><div>ll file:</div><div>; Function Attrs: nounwind uwtable<br> define dso_local i32 @sort(i32* %a, i32* %b) local_unnamed_addr #0 {<br>entry:<br>   tail call void @calculate(i32* %a, i32* %b)<br>   %arrayidx = getelementptr inbounds i32, i32* %a, i64 20<br>   %0 = load i32, i32* %arrayidx, align 4, !tbaa !2<br>   %arrayidx1 = getelementptr inbounds i32, i32* %b, i64 30<br>   %1 = load i32, i32* %arrayidx1, align 4, !tbaa !2<br>   %add = add nsw i32 %1, %0<br>   %2 = load i32, i32* @global, align 4, !tbaa !2<br>   %add2 = add nsw i32 %add, %2<br>   ret i32 %add2<br>}<br><br>; Function Attrs: inlinehint nounwind uwtable<br> declare dso_local void @calculate(i32*, i32*) local_unnamed_addr #1<br></div><div><br></div>Thanks<br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div>Mariusz Sikora</div></div></div></div>