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

Mingming Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 21 21:12:06 PST 2022


luna added a comment.

> Is there a test triggering the zero-length code path?

The context is that, I try to set `sample-profile-icp-max-prom` to zero (with the goal of evaluating how much ICP helps), and the compilation hangs without completion (and triggers timeout in crosstool)

By bootstrapping compiler w/ this patch, the build completed (I didn't verify the generated binary though)

btw I cc'ed you in an internal email with pointers to artifacts.

> It's valid to allocate an array of length zero. The code just cannot dereference the pointer.

[1] said it's not ok for c / c++ to allocate a fixed size array of size 0 yet [2] mentions that allocating is ok but de-referencing is not..

It seems to me that the exact support differs from compiler to complier though. I'm not fluent in identifying to the relevant implementations, but maybe adding logs in the locally-boostrapped compiler helps (in the internal context)

[1] https://stackoverflow.com/questions/9722632/what-happens-if-i-define-a-0-size-array-in-c-c/9723093 
[2] https://stackoverflow.com/questions/1087042/c-new-int0-will-it-allocate-memory


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