Skip to content

bpu: split FTQ into independent class#743

Closed
Yakkhini wants to merge 3 commits intoxs-devfrom
ftq-refactor
Closed

bpu: split FTQ into independent class#743
Yakkhini wants to merge 3 commits intoxs-devfrom
ftq-refactor

Conversation

@Yakkhini
Copy link
Copy Markdown
Collaborator

@Yakkhini Yakkhini commented Jan 28, 2026

Change-Id: Id67cc053693383dad05fdab358ad90a69f74ee61

Summary by CodeRabbit

  • Refactor
    • Replaced the legacy fetch-stream mechanism with a new fetch-target queue used across prediction, fetch, commit, and tracing paths while preserving runtime behavior.
  • New Features / Chores
    • Added the fetch-target queue implementation to the build.
  • Misc
    • Disabled a legacy runtime trace related to fetch-stream tracing.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

Replaces FSQ/FetchStream usages with a new FetchTargetQueue/FetchTargetEntry abstraction across BTB, O3 fetch frontend, trace, stats, and build files; updates head/ID accessors and plumbing to use FTQ methods while preserving existing control flow.

Changes

Cohort / File(s) Summary
New FTQ Core Infrastructure
src/cpu/pred/btb/fetch_target_queue.hh, src/cpu/pred/btb/fetch_target_queue.cc
Adds FetchTargetEntry and FetchTargetQueue types, deque storage, monotonic IDs (ftqId/fetchHeadFtqId), accessors (hasTargetEntry/getTarget/getTargetEntry), ftq-head helpers (ftqHasHead/ftqHead/ftqHeadId/ftqHeadFtqId) and consumeFetchTarget().
Decoupled BPU FSQ → FTQ Migration
src/cpu/pred/btb/decoupled_bpred.hh, src/cpu/pred/btb/decoupled_bpred.cc, src/cpu/pred/btb/decoupled_bpred_stats.cc
Replaces FSQ members/helpers with fetchTargetQueue; FetchStreamFetchTargetEntry; createFetchStreamEntry()createFetchTargetEntry(); removes legacy FSQ helpers and updates queue, ID, trace, squash, and stats logic to FTQ APIs.
O3 Frontend & Trace Integration
src/cpu/o3/fetch.cc, src/cpu/o3/fetch.hh, src/cpu/o3/trace/TraceFetch.cc
Replaces fsqHead/fsqHeadId/fsqHeadFtqId checks/usages with fetchTargetQueue.ftqHead/ftqHeadId/ftqHasHead() across fetch flow, cache completion handling, NOP-size selection, and fsqEmpty() condition.
Build Configuration
src/cpu/pred/SConscript
Adds Source('btb/fetch_target_queue.cc') so the new FTQ implementation is compiled and linked.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Frontend as "Fetch Frontend\n(o3/fetch)"
    participant BPU as "DecoupledBPUWithBTB"
    participant FTQ as "FetchTargetQueue"
    participant FetchUnit as "Fetch / Cache"
    participant Commit as "Commit / Stats"

    Note over Frontend,BPU: Prediction creation & enqueue
    Frontend->>BPU: request prediction
    BPU->>FTQ: create & enqueue FetchTargetEntry (increment ftqId)
    BPU->>FetchUnit: issue fetch for PC from FTQ head
    FetchUnit-->>FTQ: cache completion (fetched_inst_num)
    FetchUnit->>FTQ: consumeFetchTarget(ftq_id, fsq_id, fetched_inst_num)
    FTQ-->>BPU: updated entry (fetchInstNum set)
    BPU->>Commit: notifyInstCommit / update stats using target entry
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jensen-yan
  • CJ362ff

Poem

🐇 I hopped through queues both old and new,

FTQ IDs marching, tidy and true,
Streams became targets, lined in a row,
Fetches now follow the FTQ flow,
A rabbit cheers this code-time brew!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 24.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'bpu: split FTQ into independent class' directly describes the primary change—extracting the Fetch Target Queue (FTQ) into a standalone, independent class rather than keeping it coupled within existing structures.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/cpu/o3/fetch.cc (3)

632-638: Update panic message to reflect FTQ terminology.

The code now uses fetchTargetQueue.ftqHead(), but the panic message on line 635 still refers to "FSQ startPC". Update for consistency.

🔧 Proposed fix
         if (fetchBuffer[tid].startPC != stream.startPC) {
-            panic("fetchBufferPC %#x should be aligned with FSQ startPC %#x",
+            panic("fetchBufferPC %#x should be aligned with FTQ startPC %#x",
                   fetchBuffer[tid].startPC, stream.startPC);
         }

1766-1771: Stale debug message references "FSQ head".

Line 1768 logs "Skip fetch when FSQ head is not available" but the condition now checks the FTQ head. Update for consistency.

🔧 Proposed fix
     if (!isTraceMode() && !dbpbtb->fetchTargetQueue.ftqHasHead()) {
         dbpbtb->addFtqNotValid();
-        DPRINTF(Fetch, "Skip fetch when FSQ head is not available\n");
+        DPRINTF(Fetch, "Skip fetch when FTQ head is not available\n");
         setAllFetchStalls(StallReason::FTQBubble);
         return false;
     }

2054-2067: Stale debug/comment references "FSQ entry".

Lines 2054-2066 contain references to "FSQ" in comments and debug messages, but the code now uses the FTQ. Update for consistency.

🔧 Proposed fix
     if (fsqEmpty()) {
-        DPRINTF(Fetch, "[tid:%i] No FSQ entry available for next fetch\n", tid);
+        DPRINTF(Fetch, "[tid:%i] No FTQ entry available for next fetch\n", tid);
         return;
     }
 
     assert(dbpbtb);
     const auto &stream = dbpbtb->fetchTargetQueue.ftqHead();
     const Addr start_pc = stream.startPC;
     fetchBuffer[tid].startPC = start_pc;
 
-    DPRINTF(Fetch, "[tid:%i] Issuing a pipelined I-cache access for new FSQ entry, "
+    DPRINTF(Fetch, "[tid:%i] Issuing a pipelined I-cache access for new FTQ entry, "
                   "starting at PC %#x (endPC %#x; original PC %s)\n",
             tid, start_pc, stream.predEndPC, pc_state);
🤖 Fix all issues with AI agents
In `@src/cpu/pred/btb/decoupled_bpred_stats.cc`:
- Around line 940-949: The code copies the target entry returned by
fetchTargetQueue.getTargetEntry(inst->fsqId) so commitInstNum++ mutates the copy
and is dropped; change to obtain a mutable reference to the real entry (use the
non-const accessor or a mutable getTargetEntry variant) — e.g., get a reference
to the target entry for inst->fsqId, increment its commitInstNum, update
numInstCommitted, and reuse that same referenced entry for the DPRINTF call
(referencing commitInstNum on the referenced entry rather than calling the const
getter again).

In `@src/cpu/pred/btb/fetch_target_queue.cc`:
- Line 21: The function definition for consumeFetchTarget ends with an
extraneous semicolon after its closing brace; remove the trailing semicolon
following the closing '}' of the consumeFetchTarget function definition so the
function ends with just the brace (i.e., locate the consumeFetchTarget
definition and delete the semicolon immediately after its closing brace).
- Around line 1-3: The file has a duplicate header include: both `#include`
"cpu/pred/btb/fetch_target_queue.hh" and `#include` "fetch_target_queue.hh" are
present; remove the redundant relative include ("fetch_target_queue.hh") and
keep the canonical include ("cpu/pred/btb/fetch_target_queue.hh") so symbols
defined for the FetchTargetQueue class/struct resolve from the single header
reference.
🧹 Nitpick comments (5)
src/cpu/pred/btb/fetch_target_queue.hh (2)

23-28: Consider encapsulating public data members.

The queue exposes internal state (fetchTargetQueue, fetchTargetBaseId, size, ftqId, fetchHeadFtqId) as public members. While this may be intentional for the current design, it breaks encapsulation and makes future refactoring difficult.


17-19: Empty struct FetchTargetEntry inheriting from FetchStream.

The struct is currently empty. If additional members specific to FTQ entries are planned, this is fine. Otherwise, consider using a type alias (using FetchTargetEntry = FetchStream;) for clarity until extension is needed.

src/cpu/o3/fetch.hh (1)

969-971: Function name fsqEmpty() is misleading after FTQ refactor.

The function now checks fetchTargetQueue.ftqHasHead() but is still named fsqEmpty(). Consider renaming to ftqEmpty() for consistency with the new FTQ-based design.

♻️ Proposed fix
     // Decoupled+BTB-only: fetch consumes the supplying FSQ entry directly.
     // If no head is available, fetch stalls (no extra "supply" state machine).
-    bool fsqEmpty() const { return !dbpbtb || !dbpbtb->fetchTargetQueue.ftqHasHead(); }
+    bool ftqEmpty() const { return !dbpbtb || !dbpbtb->fetchTargetQueue.ftqHasHead(); }

Note: This would require updating all call sites (e.g., in performInstructionFetch and sendNextCacheRequest).

src/cpu/pred/btb/decoupled_bpred_stats.cc (2)

43-60: Consider removing or gating the disabled prediction trace block.

If predfsq tracing is no longer supported, deleting the commented code or converting it to a feature flag will keep the DB init path cleaner and avoid dead code drift.


826-826: Avoid copying FetchTargetEntry on every commit.

getTargetEntry() returns a const reference; auto entry = ... makes a full copy of a potentially heavy struct. Prefer a const reference to reduce overhead in the commit hot path.

♻️ Proposed fix
-    auto entry = fetchTargetQueue.getTargetEntry(inst->fsqId);
+    const auto &entry = fetchTargetQueue.getTargetEntry(inst->fsqId);

Change-Id: Id67cc053693383dad05fdab358ad90a69f74ee61
Change-Id: I6c5857b60265b04b71ea47266f0ded966c2850a3
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/cpu/pred/btb/decoupled_bpred.cc (1)

608-608: Update helper function signatures to use FetchTargetEntry for consistency.

These functions accept FetchStream but work with FetchTargetEntry objects obtained from fetchTargetQueue.getTargetEntry(). The signatures should be updated to directly accept FetchTargetEntry:

  • Line 608: updatePredictorComponents(FetchTargetEntry &stream)
  • Line 767: fillAheadPipeline(FetchTargetEntry &entry)
  • Line 898: updateHistoryForPrediction(FetchTargetEntry &entry)
  • Line 970: recoverHistoryForSquash(FetchTargetEntry &stream, ...)

Currently, the implementations cast the result back to FetchTargetEntry, which is unnecessary and obscures the intended types. Since createFetchTargetEntry() returns FetchTargetEntry, these consumers should accept the specific type directly rather than the base class.

🤖 Fix all issues with AI agents
In `@src/cpu/pred/btb/decoupled_bpred.cc`:
- Line 576: The code is const-casting the fetch target entry via "auto &stream =
(FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);" which mirrors
the same const-cast problem as in handleSquash; replace this cast with the
proper mutable accessor by calling fetchTargetQueue.getTarget(stream_id) (or the
provided getTarget() method) to obtain a non-const FetchTargetEntry reference
instead of casting away constness, ensuring you use the exact symbol
fetchTargetQueue.getTarget(...) and update any subsequent uses of stream
accordingly.
- Line 365: The code unsafely casts away const from
fetchTargetQueue.getTargetEntry(stream_id) to assign to a mutable
FetchTargetEntry&; replace that C-style cast with the non-const accessor
fetchTargetQueue.getTarget(stream_id) so the mutable reference is obtained
correctly. Locate the line using FetchTargetEntry &stream and change the call
from getTargetEntry(...) to getTarget(...) while keeping stream_id as the
argument to avoid undefined behavior.
- Line 598: The code is using a const-cast by calling
fetchTargetQueue.getTargetEntry(stream_id) and casting to FetchTargetEntry&;
replace this with the mutable accessor fetchTargetQueue.getTarget(stream_id) (or
the appropriate getTarget method on FetchTargetQueue) to obtain a mutable
FetchTargetEntry without const-casting; update the usage in decoupled_bpred.cc
where the variable named stream (type FetchTargetEntry) is assigned so it calls
getTarget(stream_id) instead of getTargetEntry(stream_id).
🧹 Nitpick comments (5)
src/cpu/pred/btb/fetch_target_queue.hh (2)

45-55: Consider consistent naming for accessor methods.

The class has both getTarget(id) (non-const) and getTargetEntry(id) (const), which can be confusing. Consider using a consistent naming pattern, such as:

  • getTargetEntry() for const access
  • getTargetEntry() with non-const overload, or
  • Keep current names but add a comment explaining the distinction

26-31: Consider encapsulating public data members.

The queue, IDs, and size are all public data members. While this may be intentional for easy migration, consider making these private with appropriate accessors to maintain encapsulation, especially since fetchTargetQueue.queue is accessed directly in other files.

src/cpu/pred/btb/decoupled_bpred_stats.cc (1)

43-60: Consider removing commented-out code.

The predfsq trace block is entirely commented out. If this functionality is no longer needed as part of the FTQ refactor, consider removing it entirely rather than leaving commented code. If it's temporarily disabled pending future work, add a TODO comment explaining the plan.

src/cpu/pred/btb/decoupled_bpred.cc (2)

505-505: Debug message refers to old variable name.

The debug message still says "fetchStreamQueue" but the variable has been renamed to fetchTargetQueue.

Suggested fix
-    DPRINTF(DecoupleBP, "after commit stream, fetchStreamQueue size: %lu\n", fetchTargetQueue.queue.size());
+    DPRINTF(DecoupleBP, "after commit stream, fetchTargetQueue size: %lu\n", fetchTargetQueue.queue.size());

812-814: Dead commented-out code should be removed or addressed.

This tracing code references the old fsqId variable and is disabled. Consider either removing it or updating it to use the new FTQ API and re-enabling if tracing is still needed.

Suggestion: Remove if tracing not needed, or update if needed
-    // if (enablePredFSQTrace) {
-    //     predTraceManager->write_record(PredictionTrace(fsqId, entry));
-    // }

Or if tracing is still needed:

    if (enablePredFSQTrace) {
        predTraceManager->write_record(PredictionTrace(fetchTargetQueue.ftqId, entry));
    }


// Get reference to the stream
auto &stream = getStream(stream_id);
FetchTargetEntry &stream = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Casting away const from getTargetEntry() is unsafe.

Per the interface, getTargetEntry() returns const FetchTargetEntry& while getTarget() returns FetchTargetEntry&. Use the non-const accessor for mutable access instead of C-style casting away const, which can lead to undefined behavior.

Proposed fix
-    FetchTargetEntry &stream = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);
+    FetchTargetEntry &stream = fetchTargetQueue.getTarget(stream_id);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FetchTargetEntry &stream = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);
FetchTargetEntry &stream = fetchTargetQueue.getTarget(stream_id);
🤖 Prompt for AI Agents
In `@src/cpu/pred/btb/decoupled_bpred.cc` at line 365, The code unsafely casts
away const from fetchTargetQueue.getTargetEntry(stream_id) to assign to a
mutable FetchTargetEntry&; replace that C-style cast with the non-const accessor
fetchTargetQueue.getTarget(stream_id) so the mutable reference is obtained
correctly. Locate the line using FetchTargetEntry &stream and change the call
from getTargetEntry(...) to getTarget(...) while keeping stream_id as the
argument to avoid undefined behavior.

return;
}
auto &stream = getStream(stream_id);
auto &stream = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Same const-cast issue as handleSquash.

Use getTarget() for mutable access instead of casting away const.

Proposed fix
-    auto &stream = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);
+    auto &stream = fetchTargetQueue.getTarget(stream_id);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
auto &stream = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);
auto &stream = fetchTargetQueue.getTarget(stream_id);
🤖 Prompt for AI Agents
In `@src/cpu/pred/btb/decoupled_bpred.cc` at line 576, The code is const-casting
the fetch target entry via "auto &stream = (FetchTargetEntry
&)fetchTargetQueue.getTargetEntry(stream_id);" which mirrors the same const-cast
problem as in handleSquash; replace this cast with the proper mutable accessor
by calling fetchTargetQueue.getTarget(stream_id) (or the provided getTarget()
method) to obtain a non-const FetchTargetEntry reference instead of casting away
constness, ensuring you use the exact symbol fetchTargetQueue.getTarget(...) and
update any subsequent uses of stream accordingly.

return;
}
auto &stream = getStream(stream_id);
auto &stream = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Same const-cast issue.

Use getTarget() for mutable access.

Proposed fix
-    auto &stream = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);
+    auto &stream = fetchTargetQueue.getTarget(stream_id);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
auto &stream = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(stream_id);
auto &stream = fetchTargetQueue.getTarget(stream_id);
🤖 Prompt for AI Agents
In `@src/cpu/pred/btb/decoupled_bpred.cc` at line 598, The code is using a
const-cast by calling fetchTargetQueue.getTargetEntry(stream_id) and casting to
FetchTargetEntry&; replace this with the mutable accessor
fetchTargetQueue.getTarget(stream_id) (or the appropriate getTarget method on
FetchTargetQueue) to obtain a mutable FetchTargetEntry without const-casting;
update the usage in decoupled_bpred.cc where the variable named stream (type
FetchTargetEntry) is assigned so it calls getTarget(stream_id) instead of
getTargetEntry(stream_id).

@github-actions
Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.1727 -
This PR 2.1727 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

Change-Id: I6567f43265eaae5003f8ffb3d4411fed0025a94c
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/cpu/pred/btb/decoupled_bpred_stats.cc`:
- Around line 915-923: The code is mutating a const reference returned by
fetchTargetQueue.getTargetEntry (via C-style cast) which breaks the API; replace
that with the mutable accessor fetchTargetQueue.getTarget(inst->fsqId) (or
getTarget) to obtain a non-const FetchTargetEntry& (targetEntry), increment
commitInstNum on that reference, and reuse the same targetEntry reference in the
DPRINTF call instead of calling getTargetEntry again so no const-cast or double
lookup is performed.

Comment on lines +915 to +923
auto &targetEntry = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(inst->fsqId);
targetEntry.commitInstNum++;

// Update global committed instruction count
numInstCommitted++;

DPRINTF(Profiling, "notifyInstCommit, inst=%s, commitInstNum=%d\n",
inst->staticInst->disassemble(inst->pcState().instAddr()),
getStream(inst->fsqId).commitInstNum);
fetchTargetQueue.getTargetEntry(inst->fsqId).commitInstNum);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for the const-cast usage and getTargetEntry calls in the file
rg -n "\(\s*FetchTargetEntry\s*&\s*\)\s*fetchTargetQueue\.getTargetEntry|getTargetEntry\(\s*inst->fsqId\s*\)" src/cpu/pred/btb/decoupled_bpred_stats.cc

Repository: OpenXiangShan/GEM5

Length of output: 299


🏁 Script executed:

#!/bin/bash
# Find the FetchTargetQueue header to inspect API
fd -e hh -e h "fetch_target_queue" src/

Repository: OpenXiangShan/GEM5

Length of output: 181


🏁 Script executed:

#!/bin/bash
# Read the relevant section of decoupled_bpred_stats.cc around lines 915-923
sed -n '910,930p' src/cpu/pred/btb/decoupled_bpred_stats.cc

Repository: OpenXiangShan/GEM5

Length of output: 912


🏁 Script executed:

#!/bin/bash
# Inspect the FTQ header file in btb directory to see API signatures
cat -n src/cpu/pred/btb/fetch_target_queue.hh | grep -A 3 "getTargetEntry\|getTarget"

Repository: OpenXiangShan/GEM5

Length of output: 542


🏁 Script executed:

#!/bin/bash
# Get more context around those method signatures
sed -n '1,300p' src/cpu/pred/btb/fetch_target_queue.hh | tail -100

Repository: OpenXiangShan/GEM5

Length of output: 2186


Use the mutable accessor to avoid const-cast.
getTargetEntry() returns a const reference; casting it away to mutate the entry violates the API contract and introduces undefined behavior. Use getTarget() instead, which provides mutable access, and reuse the same reference in the logging call.

🔧 Proposed fix
-    auto &targetEntry = (FetchTargetEntry &)fetchTargetQueue.getTargetEntry(inst->fsqId);
+    auto &targetEntry = fetchTargetQueue.getTarget(inst->fsqId);
     targetEntry.commitInstNum++;

     // Update global committed instruction count
     numInstCommitted++;

     DPRINTF(Profiling, "notifyInstCommit, inst=%s, commitInstNum=%d\n",
             inst->staticInst->disassemble(inst->pcState().instAddr()),
-            fetchTargetQueue.getTargetEntry(inst->fsqId).commitInstNum);
+            targetEntry.commitInstNum);
🤖 Prompt for AI Agents
In `@src/cpu/pred/btb/decoupled_bpred_stats.cc` around lines 915 - 923, The code
is mutating a const reference returned by fetchTargetQueue.getTargetEntry (via
C-style cast) which breaks the API; replace that with the mutable accessor
fetchTargetQueue.getTarget(inst->fsqId) (or getTarget) to obtain a non-const
FetchTargetEntry& (targetEntry), increment commitInstNum on that reference, and
reuse the same targetEntry reference in the DPRINTF call instead of calling
getTargetEntry again so no const-cast or double lookup is performed.

@github-actions
Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.1727 -
This PR 2.1727 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

@github-actions
Copy link
Copy Markdown

🚀 Performance test triggered: spec06-0.8c

@XiangShanRobot
Copy link
Copy Markdown

[Generated by GEM5 Performance Robot]
commit: 2c72cd9
workflow: On-Demand SPEC Test (Tier 1.5)

Ideal BTB Performance

Overall Score

PR Master Diff(%)
Score 20.27 20.27 +0.01 🟢

@jensen-yan
Copy link
Copy Markdown
Collaborator

There will be a lot of conflicts with #744 , so splitting it now doesn't seem necessary. Let's leave it for now.

@jensen-yan jensen-yan closed this Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants