From bd0aae92dc76d9336cf09c097ac5a49fd619da44 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Sun, 11 Jun 2023 00:04:53 -0400 Subject: cg_llvm: use index-based loop in write_operand_repeatedly This is easier for LLVM to analyze. --- tests/codegen/issues/issue-111603.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/codegen') diff --git a/tests/codegen/issues/issue-111603.rs b/tests/codegen/issues/issue-111603.rs index 90b3c314d2f..06429ed3fa9 100644 --- a/tests/codegen/issues/issue-111603.rs +++ b/tests/codegen/issues/issue-111603.rs @@ -5,6 +5,18 @@ use std::sync::Arc; +// CHECK-LABEL: @new_from_array +#[no_mangle] +pub fn new_from_array(x: u64) -> Arc<[u64]> { + // Ensure that we only generate one alloca for the array. + + // CHECK: alloca + // CHECK-SAME: [1000 x i64] + // CHECK-NOT: alloca + let array = [x; 1000]; + Arc::new(array) +} + // CHECK-LABEL: @new_uninit #[no_mangle] pub fn new_uninit(x: u64) -> Arc<[u64; 1000]> { -- cgit 1.4.1-3-g733a5