File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -538,6 +538,14 @@ fn validate_and_turn_into_const<'a, 'tcx>(
538
538
) ?;
539
539
}
540
540
// Now that we validated, turn this into a proper constant.
541
+
542
+ // We also store a simpler version of certain constants in the `val` field of `ty::Const`
543
+ // This helps us reduce the effort required to access e.g. the `usize` constant value for
544
+ // array lengths. Since array lengths make up a non-insignificant amount of all of the
545
+ // constants in the compiler, this caching has a very noticeable effect.
546
+
547
+ // FIXME(oli-obk): see if creating a query to go from an `Allocation` + offset to a
548
+ // `ConstValue` is just as effective as proactively generating the `ConstValue`.
541
549
let val = match op. layout . abi {
542
550
layout:: Abi :: Scalar ( ..) => ConstValue :: Scalar ( ecx. read_immediate ( op) ?. to_scalar ( ) ?) ,
543
551
layout:: Abi :: ScalarPair ( ..) if op. layout . ty . is_slice ( ) => {
You can’t perform that action at this time.
0 commit comments