[flang-commits] [flang] [flang] disable SimplifyPassThroughCondBranch pattern at O0 to preserve line location (PR #227215)

Abid Qadeer via flang-commits flang-commits at lists.llvm.org
Tue Sep 29 03:52:40 PDT 2026


abidh wrote:

During testing, I noticed that this breaks the following case.

```
subroutine t(a, l)
  integer :: a(4)
  logical :: l
  integer :: x
  if (l) x = 1
  a = 11
end subroutine
```

The entry block of `a = 11`'s loop has two predecessors: the `if`'s `cf.cond_br` (false edge) and the then-arm's `cf.br`. This patch keeps the first edge, but `simplifyPassThroughBr` (part of `BranchOp::canonicalize`) still folds the second.
gdb then places `break file.f90:6` on the entry block, so it stops once when `l` is false but never when `l` is true. Without the patch it stopped on every iteration on both paths.

The following test also fails on main where breakpoint on `a = 11` is only taken if `l` is TRUE
```
subroutine s(a, b, l)
  integer :: a(4), b(4)
  logical :: l
  integer :: x
  if (l) then
    x = 1
  else
    x = 2
  end if
  a = 11
  b = a + x
end subroutine
```


https://github.com/llvm/llvm-project/pull/227215


More information about the flang-commits mailing list