Don't access dangling reference to reallocated IR.
Merge branch 'master' into v2.1