From cedb6b6ec41f0924e5b4be2c47dc32359a0720f8 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 21 Dec 2011 20:26:03 +0000 Subject: [PATCH] Continue counting intrinsics as instructions (except when they aren't, such as debug info) and for being vector operations. Fixes regression from r147037. llvm-svn: 147093 --- lib/Analysis/InlineCost.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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();