[PATCH] D147165: [Windows SEH] Fix catch+return crash for Windows -EHa
This revision was automatically updated to reflect the committed changes. Closed by commit rG0cc66f3c779b: [Windows SEH] Fix catch+return crash for Windows -EHa (authored by pengfei). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147165/new/ https://reviews.llvm.org/D147165 Files: clang/lib/CodeGen/CGCleanup.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp Index: clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp === --- /dev/null +++ clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple x86_64-windows -fasync-exceptions -fcxx-exceptions -fexceptions -fms-extensions -x c++ -Wno-implicit-function-declaration -S -emit-llvm %s -o - | FileCheck %s + +// CHECK: define dso_local void @"?foo@@YAXXZ +// CHECK: invoke void @llvm.seh.try.begin() +// CHECK-NOT: llvm.seh.scope.begin +// CHECK-NOT: llvm.seh.scope.end + +// FIXME: Do we actually need llvm.seh.scope*? +void foo() { + try {} + catch (...) { + return; + } +} Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -7666,6 +7666,8 @@ if (types::isCXX(InputType)) CmdArgs.push_back("-fcxx-exceptions"); CmdArgs.push_back("-fexceptions"); +if (EH.Asynch) + CmdArgs.push_back("-fasync-exceptions"); } if (types::isCXX(InputType) && EH.Synch && EH.NoUnwindC) CmdArgs.push_back("-fexternc-nounwind"); Index: clang/lib/CodeGen/CGCleanup.cpp === --- clang/lib/CodeGen/CGCleanup.cpp +++ clang/lib/CodeGen/CGCleanup.cpp @@ -836,7 +836,7 @@ EmitBlock(NormalEntry); // intercept normal cleanup to mark SEH scope end - if (IsEHa) { + if (IsEHa && getInvokeDest()) { if (Personality.isMSVCXXPersonality()) EmitSehCppScopeEnd(); else Index: clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp === --- /dev/null +++ clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple x86_64-windows -fasync-exceptions -fcxx-exceptions -fexceptions -fms-extensions -x c++ -Wno-implicit-function-declaration -S -emit-llvm %s -o - | FileCheck %s + +// CHECK: define dso_local void @"?foo@@YAXXZ +// CHECK: invoke void @llvm.seh.try.begin() +// CHECK-NOT: llvm.seh.scope.begin +// CHECK-NOT: llvm.seh.scope.end + +// FIXME: Do we actually need llvm.seh.scope*? +void foo() { + try {} + catch (...) { + return; + } +} Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -7666,6 +7666,8 @@ if (types::isCXX(InputType)) CmdArgs.push_back("-fcxx-exceptions"); CmdArgs.push_back("-fexceptions"); +if (EH.Asynch) + CmdArgs.push_back("-fasync-exceptions"); } if (types::isCXX(InputType) && EH.Synch && EH.NoUnwindC) CmdArgs.push_back("-fexternc-nounwind"); Index: clang/lib/CodeGen/CGCleanup.cpp === --- clang/lib/CodeGen/CGCleanup.cpp +++ clang/lib/CodeGen/CGCleanup.cpp @@ -836,7 +836,7 @@ EmitBlock(NormalEntry); // intercept normal cleanup to mark SEH scope end - if (IsEHa) { + if (IsEHa && getInvokeDest()) { if (Personality.isMSVCXXPersonality()) EmitSehCppScopeEnd(); else ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D147165: [Windows SEH] Fix catch+return crash for Windows -EHa
LuoYuanke accepted this revision. LuoYuanke added a comment. This revision is now accepted and ready to land. LGTM, pls wait for 1 or 2 days in case there are comments from others Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147165/new/ https://reviews.llvm.org/D147165 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D147165: [Windows SEH] Fix catch+return crash for Windows -EHa
pengfei added a comment. I checked no difference in codegen between `/EHa` and `/EHsc` in MSVC. So it should be correct for clang as well. We should land it ASAP since it fixes a crash case. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147165/new/ https://reviews.llvm.org/D147165 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D147165: [Windows SEH] Fix catch+return crash for Windows -EHa
pengfei created this revision. pengfei added reviewers: tentzen, efriedma, victork1996. Herald added subscribers: kbarton, nemanjai. Herald added a project: All. pengfei requested review of this revision. Herald added subscribers: cfe-commits, MaskRay. Herald added a project: clang. This change also turns on -fasync-exceptions by default under -EHa option due to the backend patch merged. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D147165 Files: clang/lib/CodeGen/CGCleanup.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp Index: clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp === --- /dev/null +++ clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple x86_64-windows -fasync-exceptions -fcxx-exceptions -fexceptions -fms-extensions -x c++ -Wno-implicit-function-declaration -S -emit-llvm %s -o - | FileCheck %s + +// CHECK: define dso_local void @"?foo@@YAXXZ +// CHECK: invoke void @llvm.seh.try.begin() +// CHECK-NOT: llvm.seh.scope.begin +// CHECK-NOT: llvm.seh.scope.end + +// FIXME: Do we actually need llvm.seh.scope*? +void foo() { + try {} + catch (...) { + return; + } +} Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -7700,6 +7700,8 @@ if (types::isCXX(InputType)) CmdArgs.push_back("-fcxx-exceptions"); CmdArgs.push_back("-fexceptions"); +if (EH.Asynch) + CmdArgs.push_back("-fasync-exceptions"); } if (types::isCXX(InputType) && EH.Synch && EH.NoUnwindC) CmdArgs.push_back("-fexternc-nounwind"); Index: clang/lib/CodeGen/CGCleanup.cpp === --- clang/lib/CodeGen/CGCleanup.cpp +++ clang/lib/CodeGen/CGCleanup.cpp @@ -836,7 +836,7 @@ EmitBlock(NormalEntry); // intercept normal cleanup to mark SEH scope end - if (IsEHa) { + if (IsEHa && getInvokeDest()) { if (Personality.isMSVCXXPersonality()) EmitSehCppScopeEnd(); else Index: clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp === --- /dev/null +++ clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple x86_64-windows -fasync-exceptions -fcxx-exceptions -fexceptions -fms-extensions -x c++ -Wno-implicit-function-declaration -S -emit-llvm %s -o - | FileCheck %s + +// CHECK: define dso_local void @"?foo@@YAXXZ +// CHECK: invoke void @llvm.seh.try.begin() +// CHECK-NOT: llvm.seh.scope.begin +// CHECK-NOT: llvm.seh.scope.end + +// FIXME: Do we actually need llvm.seh.scope*? +void foo() { + try {} + catch (...) { + return; + } +} Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -7700,6 +7700,8 @@ if (types::isCXX(InputType)) CmdArgs.push_back("-fcxx-exceptions"); CmdArgs.push_back("-fexceptions"); +if (EH.Asynch) + CmdArgs.push_back("-fasync-exceptions"); } if (types::isCXX(InputType) && EH.Synch && EH.NoUnwindC) CmdArgs.push_back("-fexternc-nounwind"); Index: clang/lib/CodeGen/CGCleanup.cpp === --- clang/lib/CodeGen/CGCleanup.cpp +++ clang/lib/CodeGen/CGCleanup.cpp @@ -836,7 +836,7 @@ EmitBlock(NormalEntry); // intercept normal cleanup to mark SEH scope end - if (IsEHa) { + if (IsEHa && getInvokeDest()) { if (Personality.isMSVCXXPersonality()) EmitSehCppScopeEnd(); else ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits