[flang-commits] [flang] [llvm] [flang][cuda] Fix CUDA Fortran device-variable memory leaks, and allow `cudaDeviceReset()` before program end (PR #207843)
via flang-commits
flang-commits at lists.llvm.org
Wed Jul 15 11:54:46 PDT 2026
github-actions[bot] wrote:
<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results
* 4525 tests passed
* 250 tests skipped
* 1 test failed
## Failed Tests
(click on a test name to see its output)
### Flang
<details>
<summary>Flang.Lower/CUDA/cuda-return02.cuf</summary>
```
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 1
c:\_work\llvm-project\llvm-project\build\bin\bbc.exe -fintrinsic-modules-path=C:\_work\llvm-project\llvm-project\build\lib\clang\24\finclude\flang\x86_64-pc-windows-msvc -emit-hlfir -fcuda C:\_work\llvm-project\llvm-project\flang\test\Lower\CUDA\cuda-return02.cuf -o - | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\flang\test\Lower\CUDA\cuda-return02.cuf
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\bbc.exe' '-fintrinsic-modules-path=C:\_work\llvm-project\llvm-project\build\lib\clang\24\finclude\flang\x86_64-pc-windows-msvc' -emit-hlfir -fcuda 'C:\_work\llvm-project\llvm-project\flang\test\Lower\CUDA\cuda-return02.cuf' -o -
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\flang\test\Lower\CUDA\cuda-return02.cuf'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\flang\test\Lower\CUDA\cuda-return02.cuf:20:15: error: CHECK-NEXT: is not on the line after the previous match
# | ! CHECK-NEXT: cuf.free %[[DECL]]#0 : !fir.ref<!fir.array<10xi32>>
# | ^
# | <stdin>:16:2: note: 'next' match was here
# | cuf.free %3#0 : !fir.ref<!fir.array<10xi32>> {data_attr = #cuf.cuda<device>}
# | ^
# | <stdin>:13:7: note: previous match ended here
# | ^bb1: // pred: ^bb0
# | ^
# | <stdin>:14:1: note: non-matching line after previous match is here
# | %8 = fir.call @_FortranACUFDeviceIsActive() fastmath<contract> : () -> i1
# | ^
# |
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\flang\test\Lower\CUDA\cuda-return02.cuf
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# | .
# | .
# | .
# | 8: %4 = fir.alloca !fir.logical<4> {bindc_name = "l", uniq_name = "_QFEl"}
# | 9: %5:2 = hlfir.declare %4 {uniq_name = "_QFEl"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
# | 10: %6 = fir.load %5#0 : !fir.ref<!fir.logical<4>>
# | 11: %7 = fir.convert %6 : (!fir.logical<4>) -> i1
# | 12: cf.cond_br %7, ^bb1, ^bb2
# | 13: ^bb1: // pred: ^bb0
# | next:20'0 { search range start (exclusive)
# | 14: %8 = fir.call @_FortranACUFDeviceIsActive() fastmath<contract> : () -> i1
# | 15: fir.if %8 {
# | 16: cuf.free %3#0 : !fir.ref<!fir.array<10xi32>> {data_attr = #cuf.cuda<device>}
# | next:20'1 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: match on wrong line
# | 17: }
# | 18: return
# | 19: ^bb2: // pred: ^bb0
# | 20: %9 = fir.call @_FortranACUFDeviceIsActive() fastmath<contract> : () -> i1
# | 21: fir.if %9 {
# | .
# | .
# | .
# | 55: %c0_i32 = arith.constant 0 : i32
# | 56: fir.call @_FortranAProgramEndStatement() fastmath<contract> : () -> ()
# | 57: return %c0_i32 : i32
# | 58: }
# | 59: func.func private @_FortranACUFInit()
# | 60: }
# | next:20'2 } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1
--
```
</details>
If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.
https://github.com/llvm/llvm-project/pull/207843
More information about the flang-commits
mailing list