Skip to content

Commit 92fd6f9

Browse files
committed
Inline expand_node.
This requires restructuring things a little so that there is only one callsite, ensuring that inlinining doesn't cause unnecessary code bloat. This reduces instruction counts for the `unicode_normalization` benchmark by up to 4%.
1 parent 5576833 commit 92fd6f9

File tree

1 file changed

+14
-9
lines changed
  • src/librustc/infer/lexical_region_resolve

1 file changed

+14
-9
lines changed

src/librustc/infer/lexical_region_resolve/mod.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -188,32 +188,37 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
188188
fn expansion(&self, var_values: &mut LexicalRegionResolutions<'tcx>) {
189189
self.iterate_until_fixed_point("Expansion", |constraint| {
190190
debug!("expansion: constraint={:?}", constraint);
191-
match *constraint {
191+
let (a_region, b_vid, b_data, retain) = match *constraint {
192192
Constraint::RegSubVar(a_region, b_vid) => {
193193
let b_data = var_values.value_mut(b_vid);
194-
(self.expand_node(a_region, b_vid, b_data), false)
194+
(a_region, b_vid, b_data, false)
195195
}
196196
Constraint::VarSubVar(a_vid, b_vid) => match *var_values.value(a_vid) {
197-
VarValue::ErrorValue => (false, false),
197+
VarValue::ErrorValue => return (false, false),
198198
VarValue::Value(a_region) => {
199-
let b_node = var_values.value_mut(b_vid);
200-
let changed = self.expand_node(a_region, b_vid, b_node);
201-
let retain = match *b_node {
199+
let b_data = var_values.value_mut(b_vid);
200+
let retain = match *b_data {
202201
VarValue::Value(ReStatic) | VarValue::ErrorValue => false,
203202
_ => true
204203
};
205-
(changed, retain)
204+
(a_region, b_vid, b_data, retain)
206205
}
207206
},
208207
Constraint::RegSubReg(..) | Constraint::VarSubReg(..) => {
209208
// These constraints are checked after expansion
210209
// is done, in `collect_errors`.
211-
(false, false)
210+
return (false, false)
212211
}
213-
}
212+
};
213+
214+
let changed = self.expand_node(a_region, b_vid, b_data);
215+
(changed, retain)
214216
})
215217
}
216218

219+
// This function is very hot in some workloads. There's a single callsite
220+
// so always inlining is ok even though it's large.
221+
#[inline(always)]
217222
fn expand_node(
218223
&self,
219224
a_region: Region<'tcx>,

0 commit comments

Comments
 (0)