This patch memorizes compatible LLVM types in LLVM::isCompatibleType in order to avoid redundant works.
This is especially useful when the size of program is big and there are multiple occurrences of some deeply nested LLVM struct types, in which case we can gain quite some speedups with this patch.
Existing tests should be sufficient to cover the changes here.
I think this should speed up the case of a type already being verified.
I wonder if it would not be possible to remove callstack. I remember you had a comment about it but I don't know where it went. Perhaps something like: optimistically insert the type being verified into compatibleTypes to break cycles but then remove the type if it turns out to be incompatible. I don't think a SetVector is necessary.
And if a cached compatibleTypes set can't be retrieved from the LLVMDialect, just use a local one.