From da5263cb595ee0440b27a757f3293715c3e7371a Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 5 Nov 2012 16:00:18 -0800 Subject: [PATCH] model: refactor build_reads_from_past A couple of if-else conditions can be merged to a single if block. Also, I move the DBG prints for the may_read_from set into the correct part of the if, to avoid printing false messages about the may_read_from set. --- model.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/model.cc b/model.cc index 9dcc06c6..94620ea9 100644 --- a/model.cc +++ b/model.cc @@ -2022,17 +2022,14 @@ void ModelChecker::build_reads_from_past(ModelAction *curr) /* Don't consider more than one seq_cst write if we are a seq_cst read. */ if (!curr->is_seqcst() || (!act->is_seqcst() && (last_seq_cst == NULL || !act->happens_before(last_seq_cst))) || act == last_seq_cst) { - DEBUG("Adding action to may_read_from:\n"); - if (DBG_ENABLED()) { - act->print(); - curr->print(); - } - - if (curr->get_sleep_flag() && ! curr->is_seqcst()) { - if (sleep_can_read_from(curr, act)) - curr->get_node()->add_read_from(act); - } else + if (!curr->get_sleep_flag() || curr->is_seqcst() || sleep_can_read_from(curr, act)) { + DEBUG("Adding action to may_read_from:\n"); + if (DBG_ENABLED()) { + act->print(); + curr->print(); + } curr->get_node()->add_read_from(act); + } } /* Include at most one act per-thread that "happens before" curr */ -- 2.34.1