diff options
author | Mitch Hayenga <mitch.hayenga@arm.com> | 2014-09-03 07:42:36 -0400 |
---|---|---|
committer | Mitch Hayenga <mitch.hayenga@arm.com> | 2014-09-03 07:42:36 -0400 |
commit | daedc5a49127eb91036291af1619bbc98016aff0 (patch) | |
tree | 6bf2ac8d871cd9b4c49c3aa0dc48096f76dfe427 /src/cpu/pred/bpred_unit.hh | |
parent | ecd53009712da59a98ad3c13ed20aaa8e8cd7e29 (diff) | |
download | gem5-daedc5a49127eb91036291af1619bbc98016aff0.tar.xz |
cpu: Fix incorrect speculative branch predictor behavior
When a branch mispredicted gem5 would squash all history after and including
the mispredicted branch. However, the mispredicted branch is still speculative
and its history is required to rollback state if another, older, branch
mispredicts. This leads to things like RAS corruption.
Diffstat (limited to 'src/cpu/pred/bpred_unit.hh')
-rw-r--r-- | src/cpu/pred/bpred_unit.hh | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cpu/pred/bpred_unit.hh b/src/cpu/pred/bpred_unit.hh index 61b375f9b..f75ab79d5 100644 --- a/src/cpu/pred/bpred_unit.hh +++ b/src/cpu/pred/bpred_unit.hh @@ -178,6 +178,13 @@ class BPredUnit : public SimObject */ virtual void update(Addr instPC, bool taken, void *bp_history, bool squashed) = 0; + /** + * Deletes the associated history with a branch, performs no predictor + * updates. Used for branches that mispredict and update tables but + * are still speculative and later retire. + * @param bp_history History to delete associated with this predictor + */ + virtual void retireSquashed(void *bp_history) = 0; /** * Updates the BTB with the target of a branch. @@ -200,7 +207,7 @@ class BPredUnit : public SimObject ThreadID _tid) : seqNum(seq_num), pc(instPC), bpHistory(bp_history), RASTarget(0), RASIndex(0), tid(_tid), predTaken(pred_taken), usedRAS(0), pushedRAS(0), - wasCall(0), wasReturn(0) + wasCall(0), wasReturn(0), wasSquashed(0) {} bool operator==(const PredictorHistory &entry) const { @@ -234,7 +241,7 @@ class BPredUnit : public SimObject /** Whether or not the RAS was used. */ bool usedRAS; - /* Wether or not the RAS was pushed */ + /* Whether or not the RAS was pushed */ bool pushedRAS; /** Whether or not the instruction was a call. */ @@ -242,6 +249,9 @@ class BPredUnit : public SimObject /** Whether or not the instruction was a return. */ bool wasReturn; + + /** Whether this instruction has already mispredicted/updated bp */ + bool wasSquashed; }; typedef std::deque<PredictorHistory> History; |