Original changes from https://reviews.llvm.org/D53840 were reverted due to the following fails:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/8662
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/26263
This change-set fixes the access via invalidated reference.