[llvm] [WPD] Remove type test assumes through PHI and select nodes (PR #224155)
Michael Park via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 00:48:44 PDT 2026
mpark wrote:
> can we put this in `llvm::findDevirtualizableCallsForTypeTest()` instead? that function seems like the problematic function
So I tried this out, and I believe the current approach is cleaner. `findDevirtualizableCallsForTypeTest()` collects direct assumes because those are candidates for devirtualization. The merged assumes we're collecting in `findAssumesThroughMergesForTypeTest` are not candidates for devirtualization, but only for cleanup when type information is missing.
If we were to have `findDevirtualizableCallsForTypeTest` collect these unconditionally, in the cases where we **do** have type information, we'd be doing more work than necessary. In order to only do this work when type information is missing, we'd have to perform the conditions for which `RemoveTypeTestAssumes` is called first and pass in a conditional `MergedAssumes` vector into `findDevirtualizableCallsForTypeTest` so that it only conditionally does the collection. I think this only muddies the job of `findDevirtualizableCallsForTypeTest` and makes the API more confusing.
I think the current approach of having `findAssumesThroughMergesForTypeTest` which is only invoked inside `RemoveTypeTestAssumes` which makes it such that we only do this traversal for the type-info-missing scenarios is more accurate as to what we're trying to do.
That's to the best of my understanding. Please let me know if I'm off base here.
https://github.com/llvm/llvm-project/pull/224155
More information about the llvm-commits
mailing list