[Mlir-commits] [llvm] [mlir] [OpenMP] Fix truncation/extension bug when calling __kmpc_push_num_teams (PR #173067)
Tom Eccles
llvmlistbot at llvm.org
Sun Dec 21 10:22:31 PST 2025
tblah wrote:
Changes look good to me.
This is testable by a lit test. The following fortran example crashes the compiler without your changes. With your changes the truncates and sign-extends are visible:
```
subroutine i8_num_teams
integer(1) :: num = 4
!$omp teams num_teams(num)
call something()
!$omp end teams
end subroutine
subroutine i32_num_teams
integer(4) :: num = 4
!$omp teams num_teams(num)
call something()
!$omp end teams
end subroutine
subroutine i64_num_teams
integer(8) :: num = 4
!$omp teams num_teams(num)
call something()
!$omp end teams
end subroutine
```
You can get some mlir which is pretty close to being suitable to be a unit test in mlir/test/Target/LLVMIR/ with `flang -fc1 -fopenmp -emit-hlfir -o - test.f90 | tco -emit-final-mlir`.
The unit test should be similar to others in that directory. You will want to run `./bin/mlir-translate -mlir-to-llvmir` on the generated code and use FileCheck to see what is passed to `__kmpc_push_num_teams`.
https://github.com/llvm/llvm-project/pull/173067
More information about the Mlir-commits
mailing list