aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Lewycky <nick@wasmer.io>2021-04-18 20:51:43 -0700
committerNick Lewycky <nicholas@mxc.ca>2021-04-19 16:01:06 -0700
commitcf899a31aebf60e91a8732c6c5900398797230be (patch)
treead5e077e4acd114ea5451088671686b4902b4fc7
parent7ac461f6f7059c4e4ecbd99330a9a6bffef0133b (diff)
downloadllvm-cf899a31aebf60e91a8732c6c5900398797230be.zip
llvm-cf899a31aebf60e91a8732c6c5900398797230be.tar.gz
llvm-cf899a31aebf60e91a8732c6c5900398797230be.tar.bz2
Add a cache of checked AttributeLists.
Differential Revision: https://reviews.llvm.org/D100738
-rw-r--r--llvm/lib/IR/Verifier.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 9d3c791..83a48c4 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -328,6 +328,9 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
/// Cache of declarations of the llvm.experimental.deoptimize.<ty> intrinsic.
SmallVector<const Function *, 4> DeoptimizeDeclarations;
+ /// Cache of attribute lists verified.
+ SmallPtrSet<const void *, 32> AttributeListsVisited;
+
// Verify that this GlobalValue is only used in this module.
// This map is used to avoid visiting uses twice. We can arrive at a user
// twice, if they have multiple operands. In particular for very large
@@ -1890,14 +1893,16 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
if (Attrs.isEmpty())
return;
- Assert(Attrs.hasParentContext(Context),
- "Attribute list does not match Module context!", &Attrs);
- for (const auto &AttrSet : Attrs) {
- Assert(!AttrSet.hasAttributes() || AttrSet.hasParentContext(Context),
- "Attribute set does not match Module context!", &AttrSet);
- for (const auto &A : AttrSet) {
- Assert(A.hasParentContext(Context),
- "Attribute does not match Module context!", &A);
+ if (AttributeListsVisited.insert(Attrs.getRawPointer()).second) {
+ Assert(Attrs.hasParentContext(Context),
+ "Attribute list does not match Module context!", &Attrs);
+ for (const auto &AttrSet : Attrs) {
+ Assert(!AttrSet.hasAttributes() || AttrSet.hasParentContext(Context),
+ "Attribute set does not match Module context!", &AttrSet);
+ for (const auto &A : AttrSet) {
+ Assert(A.hasParentContext(Context),
+ "Attribute does not match Module context!", &A);
+ }
}
}