diff options
author | Andrew Kaylor <andrew.kaylor@intel.com> | 2015-04-20 18:48:45 +0000 |
---|---|---|
committer | Andrew Kaylor <andrew.kaylor@intel.com> | 2015-04-20 18:48:45 +0000 |
commit | f18771bdfd8d34f72cae4a2571215e198c4ebef4 (patch) | |
tree | 9908c9da8bfff39df3d0f7eb418e8279f1b2c185 /llvm/lib/CodeGen/WinEHPrepare.cpp | |
parent | be9e4fe768faf92071960b99cb329dbbd7e4b355 (diff) | |
download | bcm5719-llvm-f18771bdfd8d34f72cae4a2571215e198c4ebef4.tar.gz bcm5719-llvm-f18771bdfd8d34f72cae4a2571215e198c4ebef4.zip |
[WinEH] Fix memory leak with catch-all mapping.
llvm-svn: 235328
Diffstat (limited to 'llvm/lib/CodeGen/WinEHPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/WinEHPrepare.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index 4923d46c106..c540a5d92e1 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -1425,11 +1425,18 @@ void WinEHPrepare::mapLandingPadBlocks(LandingPadInst *LPad, 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; |