[PATCH] D92493: [IR] Add hot to function attributes and use hot/cold attribute in function section prefix/suffix

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 16 10:14:53 PST 2020


davidxl added inline comments.


================
Comment at: llvm/docs/LangRef.rst:1506
+    When profile feedback is enabled, this attribute has the precedence over
+    the profile inforatmion. By marking a function ``hot``, users can work
+    around the cases where the training input does not have good coverage
----------------
typo: information. 


================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:476
+    // The hot attribute overwrites profile count based hotness while profile
+    // counts based hotness overwrite the cold attribute.
+    if (F.hasFnAttribute(Attribute::Hot) ||
----------------
document that this is a conservative behavior.


================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:480
       F.setSectionPrefix("hot");
-    else if (PSI->isFunctionColdInCallGraph(&F, *BFI))
+    else if (PSI->isFunctionColdInCallGraph(&F, *BFI) ||
+             F.hasFnAttribute(Attribute::Cold))
----------------
For conservative behavior, this should be &&


================
Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:1758
+    // attribute, user's annotation has the precedence over the profile.
+    if (F->hasFnAttribute(Attribute::Hot))
+      continue;
----------------
Perhaps emit a warning here?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92493/new/

https://reviews.llvm.org/D92493



More information about the llvm-commits mailing list