This relands commit 16a62d4f. Relanded after fixing CHECK-LINES for opt pipeline output to be more general (based on failures seen in buildbot).