Avoid counting InlineAsm as a call - it prevents loop unrolling.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 26 May 2010 22:40:28 +0000 (22:40 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 26 May 2010 22:40:28 +0000 (22:40 +0000)
PR7026
Patch by Pekka Jääskeläinen!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104780 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/InlineCost.cpp

index 10c2d79bef3d4dd7d5651757af7459cf7b0d4006..98dbb69fe6a56e89b7e346fce879861ab2545c35 100644 (file)
@@ -175,7 +175,11 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB) {
       if (!isa<IntrinsicInst>(II) && !callIsSmall(CS.getCalledFunction())) {
         // Each argument to a call takes on average one instruction to set up.
         NumInsts += CS.arg_size();
       if (!isa<IntrinsicInst>(II) && !callIsSmall(CS.getCalledFunction())) {
         // Each argument to a call takes on average one instruction to set up.
         NumInsts += CS.arg_size();
-        ++NumCalls;
+
+        // We don't want inline asm to count as a call - that would prevent loop
+        // unrolling. The argument setup cost is still real, though.
+        if (!isa<InlineAsm>(CS.getCalledValue()))
+          ++NumCalls;
       }
     }
     
       }
     }