[flang-commits] [flang] [flang][PFT] Mark ASSIGN'd labels as assigned GO TO targets (PR #218674)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Wed Aug 26 06:08:34 PDT 2026
================
@@ -1065,24 +1069,16 @@ class PFTBuilder {
if (semanticsContext.IsRecordedBranchTarget(target->position))
markBranchTarget(eval, *target);
};
- const auto &labelList = std::get<std::list<parser::Label>>(s.t);
- if (!labelList.empty()) {
- // Explicit target list: `go to v, (l1, l2, ...)`.
- for (const auto &label : labelList)
- markIfBranchTarget(label);
- } else {
- // No explicit list (`go to v`): fall back to the set of labels
- // that have been previously ASSIGN'd to v.
- // TODO: This may miss assignments that appear later in program
- // order, but it matches the information available at this point
- // in the walk.
- const auto *sym = std::get<parser::Name>(s.t).symbol;
- if (sym) {
- auto iter = assignSymbolLabelMap->find(*sym);
- if (iter != assignSymbolLabelMap->end())
- for (auto label : iter->second)
- markIfBranchTarget(label);
- }
+ for (const auto &label : std::get<std::list<parser::Label>>(s.t))
+ markIfBranchTarget(label);
+ // TODO: This may miss assignments that appear later in program
----------------
eugeneepshteyn wrote:
Right, so what about
```
subroutine later_assign_earlier_target(a, n)
integer :: n, i, k
real :: a(n)
go to 100
do i = 1, n
20 a(i) = a(i) + 1.0
end do
10 go to k, (30, 40)
30 a(1) = 0.0
40 return
100 assign 20 to k
go to 10
end subroutine
```
... and
```
subroutine later_assign_earlier_target_no_list(a, n, first)
integer :: n, i, k, first
real :: a(n)
if (first /= 0) go to 100
do i = 1, n
20 a(i) = a(i) + 1.0
end do
10 go to k
30 a(1) = 0.0
40 return
100 assign 20 to k
first = 0
go to 10
end subroutine
```
Do you plan to handle this in a future PR?
https://github.com/llvm/llvm-project/pull/218674
More information about the flang-commits
mailing list