[llvm] r319481 - [InlineCost] Prefer getFunction() to two calls to getParent().

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 14:10:35 PST 2017


Author: davide
Date: Thu Nov 30 14:10:35 2017
New Revision: 319481

URL: http://llvm.org/viewvc/llvm-project?rev=319481&view=rev
Log:
[InlineCost] Prefer getFunction() to two calls to getParent().

Improves clarity, also slightly cheaper. NFCI.

Modified:
    llvm/trunk/lib/Analysis/InlineCost.cpp

Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=319481&r1=319480&r2=319481&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
+++ llvm/trunk/lib/Analysis/InlineCost.cpp Thu Nov 30 14:10:35 2017
@@ -1103,7 +1103,7 @@ bool CallAnalyzer::visitCallSite(CallSit
       }
     }
 
-    if (F == CS.getInstruction()->getParent()->getParent()) {
+    if (F == CS.getInstruction()->getFunction()) {
       // This flag will fully abort the analysis, so don't bother with anything
       // else.
       IsRecursiveCall = true;
@@ -1559,14 +1559,14 @@ bool CallAnalyzer::analyzeCall(CallSite
   if (F.empty())
     return true;
 
-  Function *Caller = CS.getInstruction()->getParent()->getParent();
+  Function *Caller = CS.getInstruction()->getFunction();
   // Check if the caller function is recursive itself.
   for (User *U : Caller->users()) {
     CallSite Site(U);
     if (!Site)
       continue;
     Instruction *I = Site.getInstruction();
-    if (I->getParent()->getParent() == Caller) {
+    if (I->getFunction() == Caller) {
       IsCallerRecursive = true;
       break;
     }




More information about the llvm-commits mailing list