https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118168

--- Comment #18 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andi Kleen <a...@gcc.gnu.org>:

https://gcc.gnu.org/g:66af77cbed6c5bf15c19573ad21ebfd0552cc4b2

commit r15-7431-g66af77cbed6c5bf15c19573ad21ebfd0552cc4b2
Author: Andi Kleen <a...@gcc.gnu.org>
Date:   Thu Dec 26 12:36:04 2024 -0800

    Add a cache of recent lines

    For larger files the file_cache line index will be spread out to make
    the index fit into the fixed buffer, so any access to the non latest line
    will need some skipping of lines.

    Most accesses for line are near the latest line because
    a diagnostic is likely near where the scanner is currently lexing.

    Add a second cache for recent lines. It is organized as a ring buffer
    and maintains the last 256 lines relative to the last input line.

    With that, enabling -Wmisleading-indentation for the test case in
    PR preprocessor/118168, is within the run-to-run variation.

    gcc/ChangeLog:

            PR preprocessor/118168
            * input.cc (file_cache::m_line_recent,
            m_line_recent_first, m_line_recent_last): Add.
            (file_cache_slot::evict): Clear new fields.
            (file_cache_slot::create): Clear new fields.
            (file_cache_slot::file_cache_slot): Initialize new fields.
            (file_cache_slot::~file_cache_slot): Release m_line_recent.
            (file_cache_slot::get_next_line): Maintain ring buffer of lines
            in m_line_recent.
            (file_cache_slot::read_line_num): Use m_line_recent to look up
            recent lines quickly.

Reply via email to