[llvm] [MemProf] Optionally update hints on existing hot/cold new calls (PR #91047)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 13:21:29 PDT 2024


================
@@ -1722,45 +1730,118 @@ Value *LibCallSimplifier::optimizeNew(CallInst *CI, IRBuilderBase &B,
   uint8_t HotCold;
   if (CI->getAttributes().getFnAttr("memprof").getValueAsString() == "cold")
     HotCold = ColdNewHintValue;
+  else if (CI->getAttributes().getFnAttr("memprof").getValueAsString() ==
+           "notcold")
+    HotCold = NotColdNewHintValue;
   else if (CI->getAttributes().getFnAttr("memprof").getValueAsString() == "hot")
     HotCold = HotNewHintValue;
   else
     return nullptr;
 
+  // For calls that already pass a hot/cold hint, only update the hint if
+  // directed by OptimizeExistingHotColdNew. For other calls to new, add a hint
+  // if cold or hot, and leave as-is for default handling if "notcold" aka warm.
   switch (Func) {
+  case LibFunc_Znwm12__hot_cold_t:
+    if (OptimizeExistingHotColdNew)
----------------
snehasish wrote:

That's true, I assumed that we would be able to inspect the operand as a constant value. Feel free to ignore the comment if that is not the case.

https://github.com/llvm/llvm-project/pull/91047


More information about the llvm-commits mailing list