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

Split PlaceContext::Store into Store & AsmOutput #46852

Merged
merged 1 commit into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ macro_rules! make_mir_visitor {
ref $($mutability)* inputs,
asm: _ } => {
for output in & $($mutability)* outputs[..] {
self.visit_place(output, PlaceContext::Store, location);
self.visit_place(output, PlaceContext::AsmOutput, location);
}
for input in & $($mutability)* inputs[..] {
self.visit_operand(input, location);
Expand Down Expand Up @@ -835,6 +835,11 @@ pub enum PlaceContext<'tcx> {
// Appears as LHS of an assignment
Store,

// Can often be treated as a Store, but needs to be separate because
// ASM is allowed to read outputs as well, so a Store-AsmOutput sequence
// cannot be simplified the way a Store-Store can be.
AsmOutput,

// Dest of a call
Call,

Expand Down Expand Up @@ -910,7 +915,7 @@ impl<'tcx> PlaceContext<'tcx> {
/// Returns true if this place context represents a use that potentially changes the value.
pub fn is_mutating_use(&self) -> bool {
match *self {
PlaceContext::Store | PlaceContext::Call |
PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call |
PlaceContext::Borrow { kind: BorrowKind::Mut, .. } |
PlaceContext::Projection(Mutability::Mut) |
PlaceContext::Drop => true,
Expand All @@ -932,6 +937,7 @@ impl<'tcx> PlaceContext<'tcx> {
PlaceContext::Projection(Mutability::Not) |
PlaceContext::Copy | PlaceContext::Move => true,
PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Call | PlaceContext::Projection(Mutability::Mut) |
PlaceContext::Drop | PlaceContext::StorageLive | PlaceContext::StorageDead |
PlaceContext::Validate => false,
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_mir/dataflow/impls/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ impl<'a, 'b, 'tcx> FindPlaceUses<'a, 'b, 'tcx> {
// "deep" does validation go?
PlaceContext::Validate => false,

// FIXME: This is here to not change behaviour from before
// AsmOutput existed, but it's not necessarily a pure overwrite.
// so it's possible this should activate the place.
PlaceContext::AsmOutput |
// pure overwrites of an place do not activate it. (note
// PlaceContext::Call is solely about dest place)
PlaceContext::Store | PlaceContext::Call => false,
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/transform/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
ty::TyAdt(adt, _) => {
if adt.is_union() {
if context == PlaceContext::Store ||
context == PlaceContext::AsmOutput ||
context == PlaceContext::Drop
{
let elem_ty = match elem {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> {
if *temp == TempState::Undefined {
match context {
PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Call => {
*temp = TempState::Defined {
location,
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_mir/util/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ impl<'tcx> Visitor<'tcx> for DefsUsesVisitor {

PlaceContext::Store |

// This is potentially both a def and a use...
PlaceContext::AsmOutput |

// We let Call define the result in both the success and
// unwind cases. This is not really correct, however it
// does not seem to be observable due to the way that we
Expand Down
1 change: 1 addition & 0 deletions src/librustc_trans/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {

PlaceContext::Inspect |
PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Borrow { .. } |
PlaceContext::Projection(..) => {
self.mark_as_memory(index);
Expand Down