This refactors RS4GC to cache results returned by findBaseDefiningValue. That function performs a recursive search for a base or at least a BDV for a given value.
Imagine we have the following IR:
%b = call i8* @foo() %d1 = getelementptr %b, 1 %d2 = getelementptr %d1, 1
and imagine we call findBaseDefiningValue on %d2. The function would make a recursive call on gep operand which is %d1 and then another one on %b, then it'll return %b as base value for %d2. If later we call it on %d1, we would do the same recursive call on %b to again infer that it is a base value.
With this change findBaseDefiningValue caches returned result on each recursive call, so in the example above when being called on %d1 we'd already know that it's base is %b from the cache and wouldn't make a recursive call.
This patch also gets rid of BaseDefiningValueResult by caching the IsKnownBase flags for BDVs and bases.
nit: ///, \p V.