[PATCH] D99362: Verify the LLVMContext for Attributes.

Nick Lewycky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 18 21:15:15 PDT 2021


nickwasmer added inline comments.


================
Comment at: llvm/lib/IR/Verifier.cpp:1885-1888
+    for (const auto &A : AttrSet) {
+      Assert(A.hasParentContext(Context),
+             "Attribute does not match Module context!", &A);
+    }
----------------
dexonsmith wrote:
> Can the verifier remember in a DenseSet if it has already checked this AttrSet / Attr / etc.?
Sorta. Note that these types are wrapper types that are passed by copy so we can't just address-compare them. Both AttributeList and Attribute have a way to get a void pointer that uniquely identifies the underlying object, but AttributeSet does not (though we can cheat and ask an AttributeSet to Profile itself in which case we get the hash of the pointer).

I think that we can just cache the AttributeList in a SmallPtrSet. The number of unique attribute lists is a little more than the number of "attributes #? = { ..." at the end of the ll file which is usually pretty small.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99362/new/

https://reviews.llvm.org/D99362



More information about the llvm-commits mailing list