-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Commits on Apr 28, 2016
-
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.
Configuration menu - View commit details
-
Copy full SHA for f242fe3 - Browse repository at this point
Copy the full SHA f242fe3View commit details -
Configuration menu - View commit details
-
Copy full SHA for c2de80f - Browse repository at this point
Copy the full SHA c2de80fView commit details -
The drop glue for `i8` is no longer generated as a trans item
Configuration menu - View commit details
-
Copy full SHA for 8691723 - Browse repository at this point
Copy the full SHA 8691723View commit details -
Fix translation of
Assign
/AssignOp
as rvaluesIn 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.
Configuration menu - View commit details
-
Copy full SHA for 89edd96 - Browse repository at this point
Copy the full SHA 89edd96View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for c55d9e5 - Browse repository at this point
Copy the full SHA c55d9e5View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 0e3b37a - Browse repository at this point
Copy the full SHA 0e3b37aView commit details -
Handle immediate tuples in
trans_arguments_untupled
Use either getelementptr or extractvalue depending on whether or not the tuple is immediate or not.
Configuration menu - View commit details
-
Copy full SHA for 3bcee26 - Browse repository at this point
Copy the full SHA 3bcee26View commit details -
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`.
Configuration menu - View commit details
-
Copy full SHA for b5d7783 - Browse repository at this point
Copy the full SHA b5d7783View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 5bda576 - Browse repository at this point
Copy the full SHA 5bda576View commit details