Skip to content

Commit cc09cb5

Browse files
committed
Record whether a Call in MIR corresponds to a call in HIR
1 parent 6ddab3e commit cc09cb5

File tree

17 files changed

+58
-17
lines changed

17 files changed

+58
-17
lines changed

src/librustc/ich/impls_mir.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,13 @@ for mir::TerminatorKind<'gcx> {
194194
mir::TerminatorKind::Call { ref func,
195195
ref args,
196196
ref destination,
197-
cleanup } => {
197+
cleanup,
198+
from_hir_call, } => {
198199
func.hash_stable(hcx, hasher);
199200
args.hash_stable(hcx, hasher);
200201
destination.hash_stable(hcx, hasher);
201202
cleanup.hash_stable(hcx, hasher);
203+
from_hir_call.hash_stable(hcx, hasher);
202204
}
203205
mir::TerminatorKind::Assert { ref cond,
204206
expected,

src/librustc/mir/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,9 @@ pub enum TerminatorKind<'tcx> {
10491049
destination: Option<(Place<'tcx>, BasicBlock)>,
10501050
/// Cleanups to be done if the call unwinds.
10511051
cleanup: Option<BasicBlock>,
1052+
/// Whether this is from a call in HIR, rather than from an overloaded
1053+
/// operator. True for overloaded function call.
1054+
from_hir_call: bool,
10521055
},
10531056

10541057
/// Jump to the target if the condition has the expected value,
@@ -2810,6 +2813,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
28102813
ref args,
28112814
ref destination,
28122815
cleanup,
2816+
from_hir_call,
28132817
} => {
28142818
let dest = destination
28152819
.as_ref()
@@ -2820,6 +2824,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
28202824
args: args.fold_with(folder),
28212825
destination: dest,
28222826
cleanup,
2827+
from_hir_call,
28232828
}
28242829
}
28252830
Assert {

src/librustc/mir/visit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ macro_rules! make_mir_visitor {
468468
TerminatorKind::Call { ref $($mutability)* func,
469469
ref $($mutability)* args,
470470
ref $($mutability)* destination,
471-
cleanup } => {
471+
cleanup,
472+
from_hir_call: _, } => {
472473
self.visit_operand(func, source_location);
473474
for arg in args {
474475
self.visit_operand(arg, source_location);

src/librustc_codegen_llvm/mir/block.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,13 @@ impl FunctionCx<'a, 'll, 'tcx> {
412412
bug!("undesugared DropAndReplace in codegen: {:?}", terminator);
413413
}
414414

415-
mir::TerminatorKind::Call { ref func, ref args, ref destination, cleanup } => {
415+
mir::TerminatorKind::Call {
416+
ref func,
417+
ref args,
418+
ref destination,
419+
cleanup,
420+
from_hir_call: _
421+
} => {
416422
// Create the callee. This is a fn ptr or zero-sized and hence a kind of scalar.
417423
let callee = self.codegen_operand(&bx, func);
418424

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
667667
ref args,
668668
ref destination,
669669
cleanup: _,
670+
from_hir_call: _,
670671
} => {
671672
self.consume_operand(ContextKind::CallOperator.new(loc), (func, span), flow_state);
672673
for arg in args {

src/librustc_mir/borrow_check/nll/invalidation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
203203
ref args,
204204
ref destination,
205205
cleanup: _,
206+
from_hir_call: _,
206207
} => {
207208
self.consume_operand(ContextKind::CallOperator.new(location), func);
208209
for arg in args {

src/librustc_mir/build/expr/into.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
264264
);
265265
exit_block.unit()
266266
}
267-
ExprKind::Call { ty, fun, args } => {
267+
ExprKind::Call { ty, fun, args, from_hir_call } => {
268268
// FIXME(canndrew): This is_never should probably be an is_uninhabited
269269
let diverges = expr.ty.is_never();
270270
let intrinsic = match ty.sty {
@@ -326,6 +326,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
326326
} else {
327327
Some((destination.clone(), success))
328328
},
329+
from_hir_call,
329330
},
330331
);
331332
success.unit()

src/librustc_mir/build/matches/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
361361
args: vec![val, expect],
362362
destination: Some((eq_result.clone(), eq_block)),
363363
cleanup: Some(cleanup),
364+
from_hir_call: false,
364365
});
365366

366367
// check the result

src/librustc_mir/dataflow/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
795795
self.propagate_bits_into_entry_set_for(in_out, *target, dirty_list);
796796
}
797797
}
798-
mir::TerminatorKind::Call { cleanup, ref destination, func: _, args: _ } => {
798+
mir::TerminatorKind::Call { cleanup, ref destination, .. } => {
799799
if let Some(unwind) = cleanup {
800800
if !self.dead_unwinds.contains(bb) {
801801
self.propagate_bits_into_entry_set_for(in_out, unwind, dirty_list);

src/librustc_mir/dataflow/move_paths/builder.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,13 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
380380
self.gather_operand(value);
381381
self.gather_init(location, InitKind::Deep);
382382
}
383-
TerminatorKind::Call { ref func, ref args, ref destination, cleanup: _ } => {
383+
TerminatorKind::Call {
384+
ref func,
385+
ref args,
386+
ref destination,
387+
cleanup: _,
388+
from_hir_call: _,
389+
} => {
384390
self.gather_operand(func);
385391
for arg in args {
386392
self.gather_operand(arg);

0 commit comments

Comments
 (0)