Files
TheRock/compiler/amd-llvm/flang/test/Transforms/stack-arrays-nested-scope.fir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

42 lines
1.6 KiB
Plaintext

// RUN: fir-opt --stack-arrays %s | FileCheck %s
// Test that an allocmem inside a fir.if is not hoisted past a
// stackrestore when the size operand is shared across scopes.
func.func @nested_if_scope(%arg0: index, %arg1: i1) {
%c0 = arith.constant 0 : index
%c0_i32 = arith.constant 0 : i32
%size = arith.addi %arg0, %arg0 : index
%sp1 = llvm.intr.stacksave : !llvm.ptr
%mem1 = fir.allocmem !fir.array<?xi32>, %size
%ref1 = fir.convert %mem1 : (!fir.heap<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
%elt1 = fir.coordinate_of %ref1, %c0 : (!fir.ref<!fir.array<?xi32>>, index) -> !fir.ref<i32>
fir.store %c0_i32 to %elt1 : !fir.ref<i32>
fir.freemem %mem1 : !fir.heap<!fir.array<?xi32>>
llvm.intr.stackrestore %sp1 : !llvm.ptr
fir.if %arg1 {
%sp2 = llvm.intr.stacksave : !llvm.ptr
%mem2 = fir.allocmem !fir.array<?xi32>, %size
%ref2 = fir.convert %mem2 : (!fir.heap<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
%elt2 = fir.coordinate_of %ref2, %c0 : (!fir.ref<!fir.array<?xi32>>, index) -> !fir.ref<i32>
fir.store %c0_i32 to %elt2 : !fir.ref<i32>
fir.freemem %mem2 : !fir.heap<!fir.array<?xi32>>
llvm.intr.stackrestore %sp2 : !llvm.ptr
}
return
}
// Second alloca must stay inside the fir.if.
// CHECK-LABEL: func.func @nested_if_scope(
// CHECK: %[[SIZE:.*]] = arith.addi
// CHECK: fir.alloca !fir.array<?xi32>, %[[SIZE]]
// CHECK: llvm.intr.stacksave
// CHECK: llvm.intr.stackrestore
// CHECK: fir.if
// CHECK: llvm.intr.stacksave
// CHECK: fir.alloca !fir.array<?xi32>, %[[SIZE]]
// CHECK: llvm.intr.stackrestore