-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[AST] Assert that FoldingSetNodeID used for hint is correct upon insertion #157692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Sharing this early to showcase the approach and see if folks are on board with that. I have seen some failures (~150) with |
I think having to call a separate thing at every use site is a bit prone to error. Can't we just check this at |
I fully agree. "requires discipline" in my previous comment alludes to that exactly.
I initially thought it's not possible because we don't have the ID there, but I think you're right and we could just try to recompute |
Right, though just checking we have the same InsertPos would weaken the assertion. What about doing it in |
Err, that doesn't actually buys us much. Yeah I don't have a better idea right now. |
Best I can come up, is that we start accepting the ID in InsertNode, but not do anything with it in release builds. If we discard this ID in an inline function, that shouldn't cause performance regressions. Then we can check the InsertPos is correct as well, which would improve things. |
What if we replace the calls to
Which is then: Sensible? Or presumably we can have an always-inline function wrapper for that, and the inliner will just take care of it. |
Yeah, I think the inline helper is cleaner, we can just discard ID before calling anything not inline. |
Sounds good to me, an |
+1 for the inline helper. But if we go down that path, maybe we could add an optional parameter to [[always_inline]] Ret InsertNode(<args>, llvm::FoldingSetNodeID* IDForAssert = nullptr) {
assert(!IDForAssert || IDForAssert == ...);
return InsertNodeImpl(<args>);
} |
That would be acceptable as well to me. |
Yeah, I did include that possibility implicitly in my suggestion, thanks. |
No description provided.