OSDN Git Service

[InlineCost] Prefer getFunction() to two calls to getParent().
authorDavide Italiano <davide@freebsd.org>
Thu, 30 Nov 2017 22:10:35 +0000 (22:10 +0000)
committerDavide Italiano <davide@freebsd.org>
Thu, 30 Nov 2017 22:10:35 +0000 (22:10 +0000)
Improves clarity, also slightly cheaper. NFCI.

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

lib/Analysis/InlineCost.cpp

index b7fe884..8fd74cc 100644 (file)
@@ -1103,7 +1103,7 @@ bool CallAnalyzer::visitCallSite(CallSite CS) {
       }
     }
 
-    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 CS) {
   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;
     }