Cache partitioning asserts that {min,max}_partition_size parameter
cannot be 0 to prevent later divisions by zero. This is needlessly
strict, we can clamp the value to 1 to get reasonable/expected behavior.
PR lto/125257
gcc/lto/ChangeLog:
* lto-partition.cc: Handle min/max_partition_size = 0 for
cache partitioning.
gcc/testsuite/ChangeLog:
* gcc.dg/lto/pr125257_0.c: New test.
---
gcc/lto/lto-partition.cc | 6 ++----
gcc/testsuite/gcc.dg/lto/pr125257_0.c | 6 ++++++
2 files changed, 8 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/lto/pr125257_0.c
diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc
index 076cb002a11..5033ae3f97d 100644
--- a/gcc/lto/lto-partition.cc
+++ b/gcc/lto/lto-partition.cc
@@ -987,11 +987,9 @@ public:
protected:
partitioner_base (int64_t min_partition_size, int64_t max_partition_size):
- min_partition_size (min_partition_size),
- max_partition_size (max_partition_size)
+ min_partition_size (std::max<int64_t>(min_partition_size, 1)),
+ max_partition_size (std::max<int64_t>(max_partition_size, 1))
{
- gcc_assert (min_partition_size != 0);
- gcc_assert (max_partition_size != 0);
}
virtual ~partitioner_base ()
{}
diff --git a/gcc/testsuite/gcc.dg/lto/pr125257_0.c
b/gcc/testsuite/gcc.dg/lto/pr125257_0.c
new file mode 100644
index 00000000000..e3821150a18
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr125257_0.c
@@ -0,0 +1,6 @@
+/* PR lto/125257 */
+/* { dg-lto-do link } */
+/* { dg-lto-options { "-O0 -flto --param=lto-min-partition=0
--param=lto-max-partition=0" } } */
+
+int main() {}
+__attribute__((used)) void foo() {}
--
2.54.0