Index: llvm/lib/Analysis/InlineCost.cpp =================================================================== --- llvm/lib/Analysis/InlineCost.cpp +++ llvm/lib/Analysis/InlineCost.cpp @@ -1580,6 +1580,8 @@ InlineResult CallAnalyzer::analyzeBlock(BasicBlock *BB, SmallPtrSetImpl &EphValues) { + bool Result = true; + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { // FIXME: Currently, the number of instructions in a function regardless of // our ability to simplify them during inline to constants or dead code, @@ -1654,11 +1656,14 @@ // Check if we've passed the maximum possible threshold so we don't spin in // huge basic blocks that will never inline. - if (Cost >= Threshold && !ComputeFullInlineCost) - return false; + if (Cost >= Threshold) { + Result = false; + if (!ComputeFullInlineCost) + break; + } } - return true; + return Result; } /// Compute the base pointer and cumulative constant offsets for V. Index: llvm/test/Transforms/Inline/inline_negative_result.ll =================================================================== --- llvm/test/Transforms/Inline/inline_negative_result.ll +++ llvm/test/Transforms/Inline/inline_negative_result.ll @@ -1,14 +1,17 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -inline -S | FileCheck %s +; RUN: opt < %s -inline -S -inline-remark-attribute | FileCheck %s +; RUN: opt < %s -inline -S -inline-remark-attribute --pass-remarks-missed=inline --pass-remarks-analysis=inline --pass-remarks=inline | FileCheck %s +; RUN: opt < %s -inline -S -inline-remark-attribute -inline-cost-full=true | FileCheck %s +; RUN: opt < %s -inline -S -inline-remark-attribute -inline-cost-full=false | FileCheck %s ; PR42084 +; The test checks that inline remarks do not change inline decisions. define internal fastcc void @func4() { ; CHECK-LABEL: @func4( ; CHECK-NEXT: entry: ; CHECK-NEXT: br label [[FOR_COND:%.*]] ; CHECK: for.cond: -; CHECK-NEXT: tail call void (...) @g() +; CHECK-NEXT: tail call void (...) @g() [[INLINE_REMARK0:#[0-9]+]] ; CHECK-NEXT: br label [[FOR_COND]] ; entry: @@ -22,7 +25,7 @@ define internal fastcc void @func3() { ; CHECK-LABEL: @func3( ; CHECK-NEXT: entry: -; CHECK-NEXT: tail call fastcc void @func4() +; CHECK-NEXT: tail call fastcc void @func4() [[INLINE_REMARK1:#[0-9]+]] ; CHECK-NEXT: unreachable ; entry: @@ -33,7 +36,7 @@ define internal fastcc void @func2() { ; CHECK-LABEL: @func2( ; CHECK-NEXT: entry: -; CHECK-NEXT: tail call fastcc void @func3() +; CHECK-NEXT: tail call fastcc void @func3() [[INLINE_REMARK1:#[0-9]+]] ; CHECK-NEXT: unreachable ; entry: @@ -44,7 +47,7 @@ define internal fastcc void @func1() { ; CHECK-LABEL: @func1( ; CHECK-NEXT: entry: -; CHECK-NEXT: tail call fastcc void @func2() +; CHECK-NEXT: tail call fastcc void @func2() [[INLINE_REMARK1:#[0-9]+]] ; CHECK-NEXT: unreachable ; entry: @@ -55,7 +58,7 @@ define i32 @main() { ; CHECK-LABEL: @main( ; CHECK-NEXT: entry: -; CHECK-NEXT: tail call fastcc void @func1() +; CHECK-NEXT: tail call fastcc void @func1() [[INLINE_REMARK1:#[0-9]+]] ; CHECK-NEXT: unreachable ; entry: @@ -64,3 +67,6 @@ } declare void @g(...) + +; CHECK: attributes [[INLINE_REMARK0]] = { "inline-remark"="unavailable definition" } +; CHECK: attributes [[INLINE_REMARK1]] = { "inline-remark"="(cost=0, threshold=0)" }