[llvm] r235328 - [WinEH] Fix memory leak with catch-all mapping.
Andrew Kaylor
andrew.kaylor at intel.com
Mon Apr 20 11:48:45 PDT 2015
Author: akaylor
Date: Mon Apr 20 13:48:45 2015
New Revision: 235328
URL: http://llvm.org/viewvc/llvm-project?rev=235328&view=rev
Log:
[WinEH] Fix memory leak with catch-all mapping.
Modified:
llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
Modified: llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/WinEHPrepare.cpp?rev=235328&r1=235327&r2=235328&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/WinEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/WinEHPrepare.cpp Mon Apr 20 13:48:45 2015
@@ -1425,11 +1425,18 @@ void WinEHPrepare::mapLandingPadBlocks(L
findCleanupHandlers(Actions, BB, BB);
// Add the catch handler to the action list.
- // Since this is a catch-all handler, the selector won't actually appear
- // in the code anywhere. ExpectedSelector here is the constant null ptr
- // that we got from the landing pad instruction.
- CatchHandler *Action = new CatchHandler(BB, ExpectedSelector, nullptr);
- CatchHandlerMap[BB] = Action;
+ CatchHandler *Action = nullptr;
+ if (CatchHandlerMap.count(BB) && CatchHandlerMap[BB] != nullptr) {
+ // If the CatchHandlerMap already has an entry for this BB, re-use it.
+ Action = CatchHandlerMap[BB];
+ assert(Action->getSelector() == ExpectedSelector);
+ } else {
+ // Since this is a catch-all handler, the selector won't actually appear
+ // in the code anywhere. ExpectedSelector here is the constant null ptr
+ // that we got from the landing pad instruction.
+ Action = new CatchHandler(BB, ExpectedSelector, nullptr);
+ CatchHandlerMap[BB] = Action;
+ }
Actions.insertCatchHandler(Action);
DEBUG(dbgs() << " Catch all handler at block " << BB->getName() << "\n");
++HandlersFound;
More information about the llvm-commits
mailing list