1. Oct 06, 2019
    • Matthew Fernandez's avatar
      enable now-passing test · bf92e85b
      Matthew Fernandez authored
      bf92e85b
    • Matthew Fernandez's avatar
      fix: don't assume the step of a for-loop is a generation-time constant · 24588764
      Matthew Fernandez authored
      This is a bit of a happy accident here. I thought we were explicitly requiring
      the step of a for loop to be a generation-time constant, as CMurphi does.
      However, it turns out we were actually constant folding the step during
      validation, and as a side effect throwing an error during constant folding when
      we encountering something non-constant.
      
      This commit fixes validation to only attempt constant folding of the step when
      it is actually foldable. We still need some generated validation checks for
      loops that have dynamic bounds and/or steps.
      24588764
    • Matthew Fernandez's avatar
      catch for-loop steps that are 0 at runtime · 8b73384e
      Matthew Fernandez authored
      Note that it is not yet possible to construct such a thing because validation
      rejects for-loops with steps that are not generation-time constants.
      8b73384e
    • Matthew Fernandez's avatar
    • Matthew Fernandez's avatar
      add some further negative for-loop range tests · 350a79fd
      Matthew Fernandez authored
      Github: related to #164 "loop iteration code incorrect"
      350a79fd
    • Matthew Fernandez's avatar
      enable now-passing tests · cefe0e3f
      Matthew Fernandez authored
      Github: related to #164 "loop iteration code incorrect"
      cefe0e3f
    • Matthew Fernandez's avatar
      fix: account for quantified variables when calculating MAX_SIMPLE_WIDTH · 3e0ac51a
      Matthew Fernandez authored
      The synthesised types for quantified variables were not being considered when
      calculating MAX_SIMPLE_WIDTH. This was in turn used within some assertions in
      generated code about the maximum size of a handle read or write. A loop with
      non-constant bounds induces a type with range [INT64_MIN, INT64_MAX] which often
      exceeds the width of any other type in the model. As a result, such a model
      would cause the handle width assertions to fail. Because these assertions become
      assumptions in non-debug mode, they would cause incorrect execution when
      debugging was turned off.
      
      Github: closes #165 "MAX_SIMPLE_WIDTH considered harmful?"
      3e0ac51a
    • Matthew Fernandez's avatar
      e3ec2644
    • Matthew Fernandez's avatar
      make max-simple-width's traversal a ConstTraversal · 60f87e58
      Matthew Fernandez authored
      We're about to need to override more than just the type visitors.
      60f87e58
    • Matthew Fernandez's avatar
      add a for-stmt test · 8a3635a7
      Matthew Fernandez authored
      8a3635a7
    • Matthew Fernandez's avatar
      enable now-passing test · 83d67ee8
      Matthew Fernandez authored
      Github: related to #164 "loop iteration code incorrect"
      83d67ee8
    • Matthew Fernandez's avatar
      fix generated loop code to iterate correctly · 1186e622
      Matthew Fernandez authored
      The generated code for a loop (stemming from either a for statement, a forall
      expression, or an exists expression) was surprisingly completely broken. When
      not iterating over a type (`for x: mytype do ...`) but rather a range
      (`for x := 0 to 10 ...`), the generated code would not perform the correct
      number of iterations. With ranges not starting from 0, the problem would be
      compounded and the value of the loop counter would be incorrect.
      
      This bug was picked up while doing some unrelated work on quantifiers. The fact
      that it has never been reported by a user and does not seem to cause any issues
      in the test suite or production models leads me to think range-based for loops
      are not very common.
      
      Note: down-counting loops (e.g. `10 to 0 by -1`) still do not yet work.
      
      Github: closes #164 "loop iteration code incorrect"
      Github: related to #163 "reverse for ranges don't work"
      1186e622
    • Matthew Fernandez's avatar
      fix: account for Quantifier::decl when choosing a ValueType · e4746dc1
      Matthew Fernandez authored
      Consider a range-based for loop:
      
        for i := 0 to 10 do
          ...
        end;
      
      The variable used for i is constructed as an unbounded Range type. The bounds
      for this default to [INT64_MIN, INT64_MAX] currently. By not taking this into
      account, the logic that automatically selects a value_t was sometimes choosing a
      smaller type (e.g. uint8_t). This resulting in reading and writing a handle that
      exceed the width of value_t. This causes an assertion failure in debug mode and
      incorrect optimisation in non-debug mode.
      
      This is not yet a complete fix. We also need to more precisely bound the type of
      the loop variable itself, as its width will currently always exceed the width of
      value_t.
      e4746dc1
  2. Oct 05, 2019
  3. Oct 03, 2019
  4. Oct 02, 2019
  5. Sep 30, 2019
  6. Sep 29, 2019
  7. Sep 27, 2019
    • Matthew Fernandez's avatar
      fix initial arena size · 381f0897
      Matthew Fernandez authored
      The initial allocation of each thread-local allocator pool was intended to be
      close to 8MB. However, the calculation was using the sizeof a pointer rather
      than the state structure itself. As a result, the initial allocator pool was
      typically much larger than 8MB.
      
      Github: closes #157 "initial arena size incorrect?"
      381f0897
  8. Sep 22, 2019
  9. Sep 19, 2019
    • Matthew Fernandez's avatar
      switch default SMT logic to QF_AUFLIA · e31ffc4c
      Matthew Fernandez authored
      We really should have been using a UF logic already, given we generate
      declare-fun commands. However, seems most solvers are happy to accept these in
      non-UF logics as well.
      e31ffc4c
  10. Sep 18, 2019