diff --git a/lib/Analysis/InlineCost.cpp b/lib/Analysis/InlineCost.cpp index 225c3f4cbfc..226b4732a49 100644 --- a/lib/Analysis/InlineCost.cpp +++ b/lib/Analysis/InlineCost.cpp @@ -63,8 +63,22 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB, // Special handling for calls. if (isa(II) || isa(II)) { - if (isa(II)) - continue; // Intrinsics have no argument setup and can't be inlined. + if (const IntrinsicInst *IntrinsicI = dyn_cast(II)) { + switch (IntrinsicI->getIntrinsicID()) { + default: break; + case Intrinsic::dbg_declare: + case Intrinsic::dbg_value: + case Intrinsic::invariant_start: + case Intrinsic::invariant_end: + case Intrinsic::lifetime_start: + case Intrinsic::lifetime_end: + case Intrinsic::objectsize: + case Intrinsic::ptr_annotation: + case Intrinsic::var_annotation: + // These intrinsics don't count as size. + continue; + } + } ImmutableCallSite CS(cast(II)); @@ -83,7 +97,7 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB, isRecursive = true; } - if (!callIsSmall(CS.getCalledFunction())) { + if (!isa(II) && !callIsSmall(CS.getCalledFunction())) { // Each argument to a call takes on average one instruction to set up. NumInsts += CS.arg_size();