[llvm] 11138e5 - [TBAA] Avoid duplicate set lookup (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 9 05:30:11 PST 2022


Author: Nikita Popov
Date: 2022-12-09T14:30:03+01:00
New Revision: 11138e5c448261445ed0924bbaf7961c27ee778e

URL: https://github.com/llvm/llvm-project/commit/11138e5c448261445ed0924bbaf7961c27ee778e
DIFF: https://github.com/llvm/llvm-project/commit/11138e5c448261445ed0924bbaf7961c27ee778e.diff

LOG: [TBAA] Avoid duplicate set lookup (NFC)

Added: 
    

Modified: 
    llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
index b7121ea8326b..5a50e0afae2c 100644
--- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -490,18 +490,16 @@ static const MDNode *getLeastCommonType(const MDNode *A, const MDNode *B) {
   SmallSetVector<const MDNode *, 4> PathA;
   TBAANode TA(A);
   while (TA.getNode()) {
-    if (PathA.count(TA.getNode()))
+    if (!PathA.insert(TA.getNode()))
       report_fatal_error("Cycle found in TBAA metadata.");
-    PathA.insert(TA.getNode());
     TA = TA.getParent();
   }
 
   SmallSetVector<const MDNode *, 4> PathB;
   TBAANode TB(B);
   while (TB.getNode()) {
-    if (PathB.count(TB.getNode()))
+    if (!PathB.insert(TB.getNode()))
       report_fatal_error("Cycle found in TBAA metadata.");
-    PathB.insert(TB.getNode());
     TB = TB.getParent();
   }
 


        


More information about the llvm-commits mailing list