llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[flang] Inline hlfir.assign loops can make source breakpoints hit once per array element

Open Saieiei opened this issue 5 months ago • 2 comments

When InlineHLFIRAssign expands an hlfir.assign into an inline fir.do_loop, the generated loop operations can inherit the assignment source location. With debug info enabled, this can make a line breakpoint on a statement like arr = 11 stop once per array element instead of once.

Reproducer:

program p
  integer :: arr(4)
  arr = 11
  print *, arr
end

Before #201774, this was visible for plain host flang -g -O0: the scalar-to-array assignment was inlined, and the generated loop/store operations carried the assignment location.

PR #201774 restores the plain host -O0 behavior by restricting that -O0 inlining path to OpenMP target-device compilation. However, the underlying debug-location issue may still apply to other paths that intentionally inline assignment loops, such as target-device -O0 or optimized host lowering.

A proper fix likely needs the inline assignment-loop generation path, for example hlfir::genNoAliasArrayAssignment, to use debug locations that do not cause per-element source breakpoint stops.

Saieiei avatar Jun 06 '26 17:06 Saieiei

@llvm/issue-subscribers-debuginfo

Author: Sairudra More (Saieiei)

When `InlineHLFIRAssign` expands an `hlfir.assign` into an inline `fir.do_loop`, the generated loop operations can inherit the assignment source location. With debug info enabled, this can make a line breakpoint on a statement like `arr = 11` stop once per array element instead of once.

Reproducer:

program p
  integer :: arr(4)
  arr = 11
  print *, arr
end

Before #201774, this was visible for plain host flang -g -O0: the scalar-to-array assignment was inlined, and the generated loop/store operations carried the assignment location.

PR #201774 restores the plain host -O0 behavior by restricting that -O0 inlining path to OpenMP target-device compilation. However, the underlying debug-location issue may still apply to other paths that intentionally inline assignment loops, such as target-device -O0 or optimized host lowering.

A proper fix likely needs the inline assignment-loop generation path, for example hlfir::genNoAliasArrayAssignment, to use debug locations that do not cause per-element source breakpoint stops.

I opened #202065 to track the broader debug-location issue separately. I’m leaving it open because #201774 only restores the plain host -O0 behavior. It does not fix debug locations for all generated inline assignment loops.

Saieiei avatar Jun 08 '26 16:06 Saieiei