summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCleanup.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-08-02 00:10:24 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-08-02 00:10:24 +0000
commitabab77603967c1284ffde3c37165a81dcd0cbea9 (patch)
tree028aed6a6537c9d8d723dadb372556419c5d0c01 /clang/lib/CodeGen/CGCleanup.cpp
parenta766b4746ddad780dbee9516ebb1fb908fd88041 (diff)
downloadbcm5719-llvm-abab77603967c1284ffde3c37165a81dcd0cbea9.tar.gz
bcm5719-llvm-abab77603967c1284ffde3c37165a81dcd0cbea9.zip
Make sure we don't emit IR for unused EH cleanups. PR13359.
llvm-svn: 161148
Diffstat (limited to 'clang/lib/CodeGen/CGCleanup.cpp')
-rw-r--r--clang/lib/CodeGen/CGCleanup.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index b00e2a21bf7..f9ea7e0a26a 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -831,8 +831,12 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
EmitBlock(EHEntry);
- cleanupFlags.setIsForEHCleanup();
- EmitCleanup(*this, Fn, cleanupFlags, EHActiveFlag);
+ // We only actually emit the cleanup code if the cleanup is either
+ // active or was used before it was deactivated.
+ if (EHActiveFlag || IsActive) {
+ cleanupFlags.setIsForEHCleanup();
+ EmitCleanup(*this, Fn, cleanupFlags, EHActiveFlag);
+ }
Builder.CreateBr(getEHDispatchBlock(EHParent));
OpenPOWER on IntegriCloud