diff options
| author | Antoni Boucher <bouanto@zoho.com> | 2024-12-22 12:28:01 -0500 |
|---|---|---|
| committer | Antoni Boucher <bouanto@zoho.com> | 2024-12-22 12:28:56 -0500 |
| commit | 02198d8458b9894c2450d5ea0a4e2e979dc56b84 (patch) | |
| tree | 0450d7e1f99a1c18303591e2e8f382ec7292550d | |
| parent | 530cdb4b3a0c1f6d7aee291b6ecebf6a769c7c57 (diff) | |
| download | rust-02198d8458b9894c2450d5ea0a4e2e979dc56b84.tar.gz rust-02198d8458b9894c2450d5ea0a4e2e979dc56b84.zip | |
Fix a stack overflow caused by GCC creating too many local variables
| -rw-r--r-- | src/builder.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/builder.rs b/src/builder.rs index 30e13ddce91..89e5cf1b8c6 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1907,6 +1907,15 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { v2: RValue<'gcc>, mask: RValue<'gcc>, ) -> RValue<'gcc> { + // NOTE: if the `mask` is a constant value, the following code will copy it in many places, + // which will make GCC create a lot (+4000) local variables in some cases. + // So we assign it to an explicit local variable once to avoid this. + let func = self.current_func(); + let mask_var = func.new_local(self.location, mask.get_type(), "mask"); + let block = self.block; + block.add_assignment(self.location, mask_var, mask); + let mask = mask_var.to_rvalue(); + // TODO(antoyo): use a recursive unqualified() here. let vector_type = v1.get_type().unqualified().dyncast_vector().expect("vector type"); let element_type = vector_type.get_element_type(); |
