Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements to MIR and LLVM IR Construction #32980

Merged
merged 9 commits into from
Apr 28, 2016

Commits on Apr 28, 2016

  1. Various improvements to MIR and LLVM IR Construction

    Primarily affects the MIR construction, which indirectly improves LLVM
    IR generation, but some LLVM IR changes have been made too.
    
    * Handle "statement expressions" more intelligently. These are
      expressions that always evaluate to `()`. Previously a temporary would
      be generated as a destination to translate into, which is unnecessary.
    
      This affects assignment, augmented assignment, `return`, `break` and
      `continue`.
    * Avoid inserting drops for non-drop types in more places. Scheduled
      drops were already skipped for types that we knew wouldn't need
      dropping at construction time. However manually-inserted drops like
      those for `x` in `x = y;` were still generated. `build_drop` now takes
      a type parameter like its `schedule_drop` counterpart and checks to
      see if the type needs dropping.
    * Avoid generating an extra temporary for an assignment where the types
      involved don't need dropping. Previously an expression like
      `a = b + 1;` would result in a temporary for `b + 1`. This is so the
      RHS can be evaluated, then the LHS evaluated and dropped and have
      everything work correctly. However, this isn't necessary if the `LHS`
      doesn't need a drop, as we can just overwrite the existing value.
    * Improves lvalue analysis to allow treating an `Rvalue::Use` as an
      operand in certain conditions. The reason for it never being an
      operand is so it can be zeroed/drop-filled, but this is only true for
      types that need dropping.
    
    The first two changes result in significantly fewer MIR blocks being
    generated, as previously almost every statement would end up generating
    a new block due to the drop of the `()` temporary being generated.
    Aatch committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    f242fe3 View commit details
    Browse the repository at this point in the history
  2. Address comments

    Moves `stmt_expr` into its own module, `expr::stmt`.
    Aatch committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    c2de80f View commit details
    Browse the repository at this point in the history
  3. Fixup tests

    The drop glue for `i8` is no longer generated as a trans item
    Aatch committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    8691723 View commit details
    Browse the repository at this point in the history
  4. Fix translation of Assign/AssignOp as rvalues

    In code like `let x = y = z;`, `y = z` goes through `as_rvalue`, which
    didn't handle it. Now it translates the assignment and produces `()`
    directly.
    Aatch committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    89edd96 View commit details
    Browse the repository at this point in the history
  5. Move zero-sized type handling logic to new_operand

    `new_operand` now checks the type it's given and either creates the nil
    value itself, or produces an empty operand.
    Aatch committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    c55d9e5 View commit details
    Browse the repository at this point in the history
  6. Fix codegen-units tests

    I'm not sure what the signficance of `drop-glue i8` is, nor why one of
    the tests had it appear while the others had it disappear. Either way it
    doesn't seem like the presence or absense of it is the focus of the
    tests.
    Aatch committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    0e3b37a View commit details
    Browse the repository at this point in the history
  7. Handle immediate tuples in trans_arguments_untupled

    Use either getelementptr or extractvalue depending on whether or not the
    tuple is immediate or not.
    Aatch committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    3bcee26 View commit details
    Browse the repository at this point in the history
  8. Check when building invoke as well as calls

    LLVM's assertion doesn't provide much insight as to what the problem
    was. We were already checking `call` instructions ourselves, so this
    brings the checks from there to `invoke`.
    
    Both the `invoke` and `call` checking is controlled by
    `debug_assertions`.
    Aatch committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    b5d7783 View commit details
    Browse the repository at this point in the history
  9. Factor out function call checking to a helper method

    The logic for checking `call` and `invoke` instructions was duplicated
    between them, so factor it out to a helper method.
    Aatch committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    5bda576 View commit details
    Browse the repository at this point in the history