From de8738f3beb0346251eaed241f10f22b202ca734 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 4 Sep 2019 16:36:54 +0000 Subject: [PATCH] [Attributor][NFC] Add assertion to guard against accidental misuse git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370925 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/IPO/Attributor.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/llvm/Transforms/IPO/Attributor.h b/include/llvm/Transforms/IPO/Attributor.h index 518f618ff70..88299cd7d5d 100644 --- a/include/llvm/Transforms/IPO/Attributor.h +++ b/include/llvm/Transforms/IPO/Attributor.h @@ -674,7 +674,10 @@ struct Attributor { // Put the attribute in the lookup map structure and the container we use to // keep track of all attributes. IRPosition &IRP = AA.getIRPosition(); - AAMap[IRP][&AAType::ID] = &AA; + auto &KindToAbstractAttributeMap = AAMap[IRP]; + assert(!KindToAbstractAttributeMap.count(&AAType::ID) && + "Attribute already in map!"); + KindToAbstractAttributeMap[&AAType::ID] = &AA; AllAbstractAttributes.push_back(&AA); return AA; } @@ -821,8 +824,7 @@ private: // Lookup the abstract attribute of type AAType. If found, return it after // registering a dependence of QueryingAA on the one returned attribute. - const auto &KindToAbstractAttributeMap = - AAMap.lookup(const_cast(IRP)); + const auto &KindToAbstractAttributeMap = AAMap.lookup(IRP); if (AAType *AA = static_cast( KindToAbstractAttributeMap.lookup(&AAType::ID))) { // Do not register a dependence on an attribute with an invalid state. -- 2.50.1