[PATCH] D15289: Avoid inlining CallSites leading to unreachable

Gerolf Hoflehner via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 9 15:03:00 PST 2015


Gerolf added a comment.

LGTM assuming you address the check for 'main'.


================
Comment at: lib/Transforms/IPO/Inliner.cpp:558
@@ +557,3 @@
+    // with exit().
+    if (HasCallSites && HasUnreachableTerminatedBlock && F->hasName() &&
+        F->getName() != "main")
----------------
That is a bit too hacky. :-) There could be exception paths even in main where you want your optimization to fire. There needs to be a way to distinguish between "hot" and "cold" unreachable blocks, eg. if it is cold if is part of EH handling or if it is an exit returning an error code etc. And that heuristic should be applicable eg. for BranchProbabilityInfo::calcUnreachableHeuristics also eventually. I suggest a FIXME for now instead of checking for a specific function name.


http://reviews.llvm.org/D15289





More information about the llvm-commits mailing list