For context, please see "cleaning up ‘br i1 false’ cases in CodeGenPrepare"
I don't know if InstCombine is a great place for this, or if we'd prefer to have some kind of LowerBestEffortPostOptimizationIntrinsics pass, or ...
Suggestions for how to better test this are appreciated.
Summarizing my appearing-soon response on said email thread, I ran this on a large project that has a clang-tailored FORTIFY implementation. With this change, we fail to lower (e.g. we return failure values for) 1.9% more calls to objectsize, but we also end up lowering quite a few more objectsize intrinsics in total. The most likely explanation for this seems to be that we're able to DCE most of those "new" failures before hitting CGP. So, I think a 1.9% degradation is likely to be an overstatement.
During that test, I added an llvm_unreachable to CGP's objectsize lowering logic. It wasn't hit.