[PATCH] D13304: Avoid inlining in throw statement

Jun Bum Lim via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 7 15:10:47 PDT 2015


junbuml added a comment.

Thanks Richard for the comment.

Initially, I intended to implement this in inliner by checking if a callsite is in exception handling regions. However, I decided not to implement this in inliner because this kind of check should be performed for all callsites if we implement it in inliner.

Instead of directly adding complexity in inliner, I implemented this in PruneEH.cpp (http://reviews.llvm.org/D12979) because this is very specific to exception handling regions. In this patch, I tried to mark all callsites invoked from throw statements as cold (noinline) by looking up users of __cxa_throw() and __cxa_allocate_exception(). We had many discussions and finally ended up to implement the same thing in clang to be more general and simpler as Hal suggested in http://reviews.llvm.org/D12979.

As you point out, it should be done by influencing inline cost heurisic, so I believe Attribute::Cold is the right attribute to be added here. However, as I FIXMEed, the current ColdThreshold is not tuned yet (r200898). So for now, I add both cold and noinline.

Regarding code size, I believe not inlining contractor calls in throw statements could be potentially more helpful for code size in many cases. If inlining very small callsites in throw statements could be issue, then we may be able to  check if callee is smaller than some threshold to avoid adding the attributes (cold and noinline).


http://reviews.llvm.org/D13304





More information about the cfe-commits mailing list