As I wrote in the description of this patch, I thought about that and actually tried implementing, and concluded that reference is not suitable for that. It was slow and unnecessarily complicated. http://reviews.llvm.org/D4028