[PATCH] D41719: [InlineCost] Prevent infinite recursion on function pointers

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 16:04:31 PST 2018


MatzeB accepted this revision.
MatzeB added a reviewer: chandlerc.
MatzeB added a comment.
This revision is now accepted and ready to land.

Makes sense to me from all I've seen. So tentative LGTM: Wait a few days and if noone else chimes in, it's fine :)



================
Comment at: lib/Analysis/InlineCost.cpp:92-94
+static cl::opt<int> InlineRecursionLimit(
+    "inline-recursion-limit", cl::Hidden, cl::init(2000), cl::ZeroOrMore,
+    cl::desc("Recursion limit for analyzing calls (default = 3000)"));
----------------
typo in the help text.


================
Comment at: lib/Analysis/InlineCost.cpp:1289
   }
 
   // If we have a constant that we are calling as a function, we can peer
----------------
I would recommend duplicating some code we had earlier for known call sites here:
```
    if (F == CS.getInstruction()->getFunction()) {
      // This flag will fully abort the analysis, so don't bother with anything
      // else.
      IsRecursiveCall = true;
      return false;
    }

```
as we won't inline recursively anyway after this.


https://reviews.llvm.org/D41719





More information about the llvm-commits mailing list