Fix a bad bug in memoization cache where buffer memory was not freed
properly. (Wrong pointer was passed to halide_free, which was almost
always ok as it turned into a free of NULL.)

Improve cache debugging printfs to write key as one printf and add a
bit more information. (halide_printf on mobile devices often results
in a log line per call. It only makes sense to call it with an entire
line.)

Move locking scopes to cover cache validation as otherwise it will
fail due to race conditions in parallel filters. (Only applies when
CACHE_DEBUGGING is turned on.)
Fix formatting, remove tabs.
Fix a bug in dynamic stage skipping where predicates that depend on an
allocation can be moved outside the allocation. Causes compilation
failures via looking up an undefined chace_key symbol in some cases
with Memoization and dynamically skippable realizations.