[flang-commits] [flang] [flang][Parser][NFC] Don't build a discarded list while scanning identifiers (PR #219330)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Fri Aug 28 06:25:43 PDT 2026
https://github.com/eugeneepshteyn approved this pull request.
LGTM.
Two non-blocking notes:
- Description nit: the list costs one node per identifier character *after the first* (the leading `nonDigitIdChar` is outside `many()`).
- The same discarded-list pattern exists in a few sibling spots — e.g. `some(definedOpNameChar)` in `DefinedOpName` (`expr-parsers.cpp`), the `!(some(letter) >> "."_ch)` REAL-literal lookahead, the directive-sentinel `some(letter)`, and the `many(...)` in `progUnitEndStmtErrorRecovery` — those would need `x >> skipMany(x)` (or a new `skipSome`) since `some()` has no skip variant. Fine as separate follow-ups; no need to grow this PR.
AI agent verified the performance claim:
**The allocation claim reproduces.** On a generated identifier-heavy file:
```sh
python3 -c '
n = 3000
print("program p10"); print(" implicit none")
for i in range(n): print(f" integer :: some_quite_long_variable_name_number_{i:04d}")
print(" some_quite_long_variable_name_number_0000 = 1")
for i in range(1, n):
print(f" some_quite_long_variable_name_number_{i:04d} = some_quite_long_variable_name_number_{i-1:04d} + {i}")
print(f" print *, some_quite_long_variable_name_number_{n-1:04d}"); print("end program p10")
' > p10.f90
valgrind flang -fc1 -fsyntax-only p10.f90
```
```console
before: total heap usage: 2,140,700 allocs, 93,564,066 bytes allocated
after: total heap usage: 700,308 allocs, 58,994,632 bytes allocated
```
— this one-liner removes 67% of *all* heap allocations for that compile (−18.9% instructions:u with `-fc1 -fsyntax-only`), consistent in direction with your whole-compile −0.88%.
https://github.com/llvm/llvm-project/pull/219330
More information about the flang-commits
mailing list