Issue |
91526
|
Summary |
[Flang][OpenMP][OpenACC] Another unstructured code interaction issue
|
Labels |
flang
|
Assignees |
|
Reporter |
kiranchandramohan
|
In a special case where there is an OpenMP construct in the `if` case and unstructured code in the `else` case, an incorrect branch is generated from the `if` code to the `else` code.
```
subroutine simple(y)
implicit none
logical, intent(in) :: y
integer :: i
if (y) then
!$omp parallel
i = 1
!$omp end parallel
else
stop 1
end if
end subroutine simple
```
In the following HLFIR code that is generated, there is an incorrect branch `cf.br ^bb2`.
```
cf.cond_br %4, ^bb1, ^bb2
^bb1: // pred: ^bb0
omp.parallel {
%c1_i32_1 = arith.constant 1 : i32
hlfir.assign %c1_i32_1 to %1#0 : i32, !fir.ref<i32>
omp.terminator
}
cf.br ^bb2
^bb2: // 2 preds: ^bb0, ^bb1
%c1_i32 = arith.constant 1 : i32
%false = arith.constant false
%false_0 = arith.constant false
%5 = fir.call @_FortranAStopStatement(%c1_i32, %false, %false_0) fastmath<contract> : (i32, i1, i1) -> none
fir.unreachable
```
The correct branch should be generated for this case in https://github.com/llvm/llvm-project/blob/e3938f4d71493673033f6190454e7e19d5411ea7/flang/lib/Lower/Bridge.cpp#L4547. But this code is not entered since the lexical successor of the OpenMP construct evaluation is the first evaluation inside the OpenMP construct. Comparing with similar code like the `block` construct, there is an `end Block` evaluation that has the successor marked correctly.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs