Fix segmentation fault.

This commit is contained in:
Danila Fedorin 2020-12-06 17:40:52 -08:00
parent 358121de55
commit 6994ea0046

View File

@ -966,7 +966,9 @@ bpred_update(struct bpred_t *pred, /* branch predictor instance */
/* update state (but not for jumps) */ /* update state (but not for jumps) */
if (dir_update_ptr->pdir1) if (dir_update_ptr->pdir1)
{ {
char pred_cutoff = (pred->dirpred.bimod->class == BPred3bit) ? 7 : 3; struct bpred_dir_t* p1 =
pred->dirpred.bimod ? pred->dirpred.bimod : pred->dirpred.twolev;
char pred_cutoff = (p1->class == BPred3bit) ? 7 : 3;
if (taken) if (taken)
{ {
if (*dir_update_ptr->pdir1 < pred_cutoff) if (*dir_update_ptr->pdir1 < pred_cutoff)
@ -983,6 +985,7 @@ bpred_update(struct bpred_t *pred, /* branch predictor instance */
/* second direction predictor */ /* second direction predictor */
if (dir_update_ptr->pdir2) if (dir_update_ptr->pdir2)
{ {
/* Assumption: second predictor is always two-level. */
char pred_cutoff = (pred->dirpred.twolev->class == BPred3bit) ? 7 : 3; char pred_cutoff = (pred->dirpred.twolev->class == BPred3bit) ? 7 : 3;
if (taken) if (taken)
{ {