[llvm] 519dbc6 - [WasmExceptionInfo] Use SmallPtrSet::remove_if() (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 05:48:42 PDT 2024


Author: Nikita Popov
Date: 2024-06-26T14:45:53+02:00
New Revision: 519dbc6b996d6121e95cc14865d7e0fa6496bb12

URL: https://github.com/llvm/llvm-project/commit/519dbc6b996d6121e95cc14865d7e0fa6496bb12
DIFF: https://github.com/llvm/llvm-project/commit/519dbc6b996d6121e95cc14865d7e0fa6496bb12.diff

LOG: [WasmExceptionInfo] Use SmallPtrSet::remove_if() (NFC)

Added: 
    

Modified: 
    llvm/lib/Target/WebAssembly/WebAssemblyExceptionInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyExceptionInfo.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyExceptionInfo.cpp
index f23f21c8f69fb..b312ca7f5346b 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyExceptionInfo.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyExceptionInfo.cpp
@@ -207,12 +207,12 @@ void WebAssemblyExceptionInfo::recalculate(
     auto *SrcWE = P.first;
     auto *DstWE = P.second;
 
-    for (auto *MBB : SrcWE->getBlocksSet()) {
+    SrcWE->getBlocksSet().remove_if([&](MachineBasicBlock *MBB){
       if (MBB->isEHPad()) {
         assert(!isReachableAmongDominated(DstWE->getEHPad(), MBB,
                                           SrcWE->getEHPad(), MDT) &&
                "We already handled EH pads above");
-        continue;
+        return false;
       }
       if (isReachableAmongDominated(DstWE->getEHPad(), MBB, SrcWE->getEHPad(),
                                     MDT)) {
@@ -227,15 +227,16 @@ void WebAssemblyExceptionInfo::recalculate(
           InnerWE->removeFromBlocksSet(MBB);
           InnerWE = InnerWE->getParentException();
         }
-        SrcWE->removeFromBlocksSet(MBB);
         LLVM_DEBUG(dbgs() << "  removed from " << SrcWE->getEHPad()->getNumber()
                           << "." << SrcWE->getEHPad()->getName()
                           << "'s exception\n");
         changeExceptionFor(MBB, SrcWE->getParentException());
         if (SrcWE->getParentException())
           SrcWE->getParentException()->addToBlocksSet(MBB);
+        return true;
       }
-    }
+      return false;
+    });
   }
 
   // Add BBs to exceptions' block vector


        


More information about the llvm-commits mailing list