[backport] SI-7470 implements fundep materialization

Backports 21a8c6c from the 2.11.x branch under -Xfundep-materialization
as per Miles Sabin's request. Thanks Miles!
pull request feedback
-Xfundep-materialization => -Yfundep-materialization

To quote gkossakowski:

  Thinking about it more, could we hide this behind 'Y' flag instead?
  We have lesser obligation to keep around Y flags and this is something
  we should remove from 2.11/2.12.
Merge pull request #3859 from xeno-by/topic/fundep-materialization-210x

[backport] SI-7470 implements fundep materialization