[PATCH] D120295: [SampleProfile] [ICP] Handle the case when the option `MaxNumPromotions` is zero.

Rong Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 22 15:14:35 PST 2022


xur added a comment.

I think the reason MaxNumPromotion==0 breaks is likely the 0 size array think (like MaskRay mentioned).

Explicitly checking of 0 is a good fix here.

LGTM except I'm not sure if the second check is needed.



================
Comment at: llvm/lib/Transforms/IPO/SampleProfile.cpp:851
+  // This prevents allocating an array of zero length below.
+  if (MaxNumPromotions == 0)
+    return;
----------------
Why this is needed? This is update the profile counter after we do the promotion. 
If the check works in doesHistoryAllowICP(), MaxNumPromptions here should not be 0, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120295



More information about the llvm-commits mailing list