[llvm] [DebugInfo][RemoveDIs] Have getInsertionPtAfterDef return an iterator (PR #73149)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 13:45:31 PST 2023


nikic wrote:

> I've pushed up an equivalent patch using `end()`, although there are some downsides: it's possible for users to ignore the "invalid" return-value of end() and insert at end(), although I suppose that'll eventually be caught by the verifier. It's also not always clear what block's end() one should compare the return with code -- hence I've left `getFreezeInsertPt` returning an optional. Thoughts on whether this is better?

Ah yes, that's a very good point. What I had in mind when making the suggestion is the getFirstInsertPt() API, but of course that one is called on a BB and always returns an iterator into that BB. In this case, we might actually return an iterator to a different BB (following the invoke success edge), so that comparing `I->getInsertionPtAfterDef() == I->getParent()->end()` would actually be incorrect. So returning end() doesn't really work in this case, and you should go back to your original patch using `std::optional`. Sorry for the bogus suggestion.

https://github.com/llvm/llvm-project/pull/73149


More information about the llvm-commits mailing list