mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Check history earlier.
This commit is contained in:
parent
5999f34ff6
commit
114c9284b9
@ -263,6 +263,10 @@ impl<'tcx> Inliner<'tcx> {
|
||||
return None;
|
||||
}
|
||||
|
||||
if self.history.contains(&callee) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let fn_sig = self.tcx.bound_fn_sig(def_id).subst(self.tcx, substs);
|
||||
|
||||
return Some(CallSite {
|
||||
@ -407,22 +411,9 @@ impl<'tcx> Inliner<'tcx> {
|
||||
}
|
||||
|
||||
TerminatorKind::Call { func: Operand::Constant(ref f), cleanup, .. } => {
|
||||
if let ty::FnDef(def_id, substs) =
|
||||
if let ty::FnDef(def_id, _) =
|
||||
*callsite.callee.subst_mir(self.tcx, &f.literal.ty()).kind()
|
||||
{
|
||||
if let Ok(substs) =
|
||||
self.tcx.try_normalize_erasing_regions(self.param_env, substs)
|
||||
{
|
||||
if let Ok(Some(instance)) =
|
||||
Instance::resolve(self.tcx, self.param_env, def_id, substs)
|
||||
{
|
||||
if callsite.callee.def_id() == instance.def_id() {
|
||||
return Err("self-recursion");
|
||||
} else if self.history.contains(&instance) {
|
||||
return Err("already inlined");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Don't give intrinsics the extra penalty for calls
|
||||
if tcx.is_intrinsic(def_id) {
|
||||
cost += INSTR_COST;
|
||||
|
@ -5,17 +5,20 @@
|
||||
let mut _0: (); // return place in scope 0 at $DIR/inline-cycle.rs:13:10: 13:10
|
||||
let _1: (); // in scope 0 at $DIR/inline-cycle.rs:14:5: 14:24
|
||||
+ scope 1 (inlined <C as Call>::call) { // at $DIR/inline-cycle.rs:14:5: 14:24
|
||||
+ scope 2 (inlined <A<C> as Call>::call) { // at $DIR/inline-cycle.rs:43:9: 43:23
|
||||
+ scope 3 (inlined <B<C> as Call>::call) { // at $DIR/inline-cycle.rs:28:9: 28:31
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
bb0: {
|
||||
StorageLive(_1); // scope 0 at $DIR/inline-cycle.rs:14:5: 14:24
|
||||
- _1 = <C as Call>::call() -> bb1; // scope 0 at $DIR/inline-cycle.rs:14:5: 14:24
|
||||
+ _1 = <A<C> as Call>::call() -> bb1; // scope 1 at $DIR/inline-cycle.rs:43:9: 43:23
|
||||
+ _1 = <C as Call>::call() -> bb1; // scope 3 at $DIR/inline-cycle.rs:36:9: 36:28
|
||||
// mir::Constant
|
||||
- // + span: $DIR/inline-cycle.rs:14:5: 14:22
|
||||
- // + literal: Const { ty: fn() {<C as Call>::call}, val: Value(Scalar(<ZST>)) }
|
||||
+ // + span: $DIR/inline-cycle.rs:43:9: 43:21
|
||||
+ // + literal: Const { ty: fn() {<A<C> as Call>::call}, val: Value(Scalar(<ZST>)) }
|
||||
+ // + span: $DIR/inline-cycle.rs:36:9: 36:26
|
||||
// + literal: Const { ty: fn() {<C as Call>::call}, val: Value(Scalar(<ZST>)) }
|
||||
}
|
||||
|
||||
bb1: {
|
||||
|
@ -11,6 +11,9 @@
|
||||
+ let _3: (); // in scope 1 at $DIR/inline-cycle.rs:54:5: 54:8
|
||||
+ let mut _4: fn() {f}; // in scope 1 at $DIR/inline-cycle.rs:54:5: 54:6
|
||||
+ scope 2 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { // at $DIR/inline-cycle.rs:54:5: 54:8
|
||||
+ scope 3 (inlined f) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
+ let _6: (); // in scope 3 at $DIR/inline-cycle.rs:59:5: 59:12
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
@ -21,19 +24,26 @@
|
||||
+ _2 = f; // scope 0 at $DIR/inline-cycle.rs:49:5: 49:12
|
||||
// mir::Constant
|
||||
- // + span: $DIR/inline-cycle.rs:49:5: 49:9
|
||||
- // + literal: Const { ty: fn(fn() {f}) {call::<fn() {f}>}, val: Value(Scalar(<ZST>)) }
|
||||
- // mir::Constant
|
||||
// + span: $DIR/inline-cycle.rs:49:10: 49:11
|
||||
// + literal: Const { ty: fn() {f}, val: Value(Scalar(<ZST>)) }
|
||||
+ // + span: $DIR/inline-cycle.rs:49:10: 49:11
|
||||
+ // + literal: Const { ty: fn() {f}, val: Value(Scalar(<ZST>)) }
|
||||
+ StorageLive(_3); // scope 1 at $DIR/inline-cycle.rs:54:5: 54:8
|
||||
+ StorageLive(_4); // scope 1 at $DIR/inline-cycle.rs:54:5: 54:6
|
||||
+ _4 = move _2; // scope 1 at $DIR/inline-cycle.rs:54:5: 54:6
|
||||
+ StorageLive(_5); // scope 1 at $DIR/inline-cycle.rs:54:5: 54:8
|
||||
+ _5 = const (); // scope 1 at $DIR/inline-cycle.rs:54:5: 54:8
|
||||
+ _3 = move _4() -> bb1; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
+ StorageLive(_6); // scope 3 at $DIR/inline-cycle.rs:59:5: 59:12
|
||||
+ _6 = call::<fn() {f}>(f) -> bb1; // scope 3 at $DIR/inline-cycle.rs:59:5: 59:12
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/inline-cycle.rs:59:5: 59:9
|
||||
// + literal: Const { ty: fn(fn() {f}) {call::<fn() {f}>}, val: Value(Scalar(<ZST>)) }
|
||||
// mir::Constant
|
||||
- // + span: $DIR/inline-cycle.rs:49:10: 49:11
|
||||
+ // + span: $DIR/inline-cycle.rs:59:10: 59:11
|
||||
// + literal: Const { ty: fn() {f}, val: Value(Scalar(<ZST>)) }
|
||||
}
|
||||
|
||||
bb1: {
|
||||
+ StorageDead(_6); // scope 3 at $DIR/inline-cycle.rs:59:12: 59:13
|
||||
+ StorageDead(_5); // scope 1 at $DIR/inline-cycle.rs:54:5: 54:8
|
||||
+ StorageDead(_4); // scope 1 at $DIR/inline-cycle.rs:54:7: 54:8
|
||||
+ StorageDead(_3); // scope 1 at $DIR/inline-cycle.rs:54:8: 54:9
|
||||
|
@ -4,12 +4,22 @@
|
||||
fn main() -> () {
|
||||
let mut _0: (); // return place in scope 0 at $DIR/inline-cycle-generic.rs:8:11: 8:11
|
||||
let _1: (); // in scope 0 at $DIR/inline-cycle-generic.rs:9:5: 9:24
|
||||
+ scope 1 (inlined <C as Call>::call) { // at $DIR/inline-cycle-generic.rs:9:5: 9:24
|
||||
+ scope 2 (inlined <B<A> as Call>::call) { // at $DIR/inline-cycle-generic.rs:38:9: 38:31
|
||||
+ scope 3 (inlined <A as Call>::call) { // at $DIR/inline-cycle-generic.rs:31:9: 31:28
|
||||
+ scope 4 (inlined <B<C> as Call>::call) { // at $DIR/inline-cycle-generic.rs:23:9: 23:31
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
bb0: {
|
||||
StorageLive(_1); // scope 0 at $DIR/inline-cycle-generic.rs:9:5: 9:24
|
||||
_1 = <C as Call>::call() -> bb1; // scope 0 at $DIR/inline-cycle-generic.rs:9:5: 9:24
|
||||
- _1 = <C as Call>::call() -> bb1; // scope 0 at $DIR/inline-cycle-generic.rs:9:5: 9:24
|
||||
+ _1 = <C as Call>::call() -> bb1; // scope 4 at $DIR/inline-cycle-generic.rs:31:9: 31:28
|
||||
// mir::Constant
|
||||
// + span: $DIR/inline-cycle-generic.rs:9:5: 9:22
|
||||
- // + span: $DIR/inline-cycle-generic.rs:9:5: 9:22
|
||||
+ // + span: $DIR/inline-cycle-generic.rs:31:9: 31:26
|
||||
// + literal: Const { ty: fn() {<C as Call>::call}, val: Value(Scalar(<ZST>)) }
|
||||
}
|
||||
|
||||
@ -17,6 +27,10 @@
|
||||
StorageDead(_1); // scope 0 at $DIR/inline-cycle-generic.rs:9:24: 9:25
|
||||
_0 = const (); // scope 0 at $DIR/inline-cycle-generic.rs:8:11: 10:2
|
||||
return; // scope 0 at $DIR/inline-cycle-generic.rs:10:2: 10:2
|
||||
+ }
|
||||
+
|
||||
+ bb2 (cleanup): {
|
||||
+ resume; // scope 0 at $DIR/inline-cycle-generic.rs:8:1: 10:2
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user