diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-08-02 00:10:24 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-08-02 00:10:24 +0000 |
commit | ea66f9f9e17d619d617885e26adc1530cec7c0fd (patch) | |
tree | d1695f086f9eaf90aa355b928036422a710a6fd0 /lib/CodeGen/CGCleanup.cpp | |
parent | d076e013b1d9afa26d9bf2fdc8ba579941037f8e (diff) |
Make sure we don't emit IR for unused EH cleanups. PR13359.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161148 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCleanup.cpp')
-rw-r--r-- | lib/CodeGen/CGCleanup.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/CodeGen/CGCleanup.cpp b/lib/CodeGen/CGCleanup.cpp index b00e2a21bf..f9ea7e0a26 100644 --- a/lib/CodeGen/CGCleanup.cpp +++ b/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)); |