Issue 153564
Summary [Offload][Flang] Compilation hangs for minutes and then fails when not using optimization flag
Labels flang
Assignees
Reporter jfuchs-kmt
    When compiling the snippet below with the latest flang compiler from the master branch using `flang -fopenmp -fopenmp-targets=nvptx64 main.F90` will hang the compiler for minutes and then output the following error message:
```
>flang -fopenmp -fopenmp-targets=nvptx64 main.F90
nvlink warning : Stack size for entry function '__omp_offloading_10304_8e3c9d__QQmain_l14' cannot be statically determined
nvlink error   : Entry function 'optimizer.__omp_offloading_10304_8e3c9d__QQmain_l14' uses too much data for compiler-generated constants; please recompile with -Xptxas --disable-optimizer-constants
nvlink error   : Undefined reference to 'abort' in '/tmp/a.out.nvptx64.sm_120-0928e2-8dd2ec.cubin'
nvlink error   : Undefined reference to 'strlen' in '/tmp/a.out.nvptx64.sm_120-0928e2-8dd2ec.cubin'
nvlink error   : Undefined reference to 'memchr' in '/tmp/a.out.nvptx64.sm_120-0928e2-8dd2ec.cubin'
nvlink error   : Undefined reference to 'strcmp' in '/tmp/a.out.nvptx64.sm_120-0928e2-8dd2ec.cubin'
nvlink error   : Undefined reference to 'toupper' in '/tmp/a.out.nvptx64.sm_120-0928e2-8dd2ec.cubin'
nvlink error   : Undefined reference to 'strcpy' in '/tmp/a.out.nvptx64.sm_120-0928e2-8dd2ec.cubin'
/opt/llvm/llvm-project/install/bin/clang-nvlink-wrapper: error: 'nvlink' failed
clang: error: nvlink command failed with exit code 1 (use -v to see invocation)
/opt/llvm/llvm-project/install/bin/clang-linker-wrapper: error: 'clang' failed
flang-22: error: linker command failed with exit code 1 (use -v to see invocation)`
```

```fortran
PROGRAM reproducer
    IMPLICIT NONE

    INTEGER, PARAMETER :: param(4) = [5, 6, 7, 8]
    INTEGER :: non_param(4) = [0, 0, 0, 0]

    !$omp target map(tofrom: non_param)
 non_param(:) = param(:)
    !$omp end target

    PRINT*, non_param
END PROGRAM reproducer
```

But when compiling the snippet with any optimization flag O1, O2 or O3, the program compiles quickly as expected and runs correctly it with `OMP_TARGET_OFFLOAD=mandatory ./a.out`. Then the output is as expected: `5 6 7 8`.

I checked this issue with nvfortran and gfortran - both of them compile and run correctly without and with optimization flags.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to