Attributes don't know their parent Context. Instead of using extra memory to store that, we have the verifier query the Attribute with a prospective parent LLVMContext and the Attribute checks whether its contents exists in that context's FoldingSet.
There's an oddity I noticed while working on this patch. There are methods to create attributes with types which also take a context. If I check for nullptr Type* in attributes in the verifier, there are none in a run of the llvm testsuite. However, the C API does create these things in LLVMCreateEnumAttribute. I'm not sure what the intended state is here, but I'm thinking that the Attribute::get* functions that take Context+Type should either remove the Context or assert that the Type's Context matches the supplied Context when the Type is not null.
Can the verifier remember in a DenseSet if it has already checked this AttrSet / Attr / etc.?