[PATCH] D53887: [HotColdSplitting] [WIP] Outline more than once per function

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 6 12:02:18 PST 2018


vsk added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/HotColdSplitting.cpp:282
     // that it's cold.
-    assert(!OutF->hasFnAttribute(Attribute::OptimizeNone) &&
-           "An outlined function should never be marked optnone");
-    OutF->addFnAttr(Attribute::MinSize);
+    markEntireFunctionCold(*OutF);
 
----------------
vsk wrote:
> junbuml wrote:
> > Considering the case below, I believed we should not mark the MinSize here as well. 
> > 
> > 
> > ```
> > void foo(bool c) {
> >   if(c) {
> >     ....
> >     return;
> >   }
> > 
> >    // hot code
> >    exit (0);
> > }
> > ```
> I think this is illustrative of a more general problem: I don't think we should treat NoReturn functions as cold at all. On Darwin, functions like longjmp are NoReturn but warm. Our kernel uses continuation functions (conceptually similar to longjmp) to reduce stack usage: these are also NoReturn but hot.
> 
> IMO, noreturn functions which are actually cold should be marked as such (abort, etc., but not exit). That's what we do on Darwin.
If the concern is that it's hard to add attributes to functions in libc, we could special-case them as needed. But I think treating all noreturn functions as cold when they might not be will cause problems, or at least prevent us from attaching MinSize, etc.


https://reviews.llvm.org/D53887





More information about the llvm-commits mailing list