From: Ten Tzen Date: Fri, 4 Jun 2021 21:04:46 +0000 (-0700) Subject: [Windows SEH]: Fix -O2 crash for Windows -EHa X-Git-Tag: llvmorg-14-init~4812 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33ba8bd2c942062731a17e1b864b5953e3d79f1a;p=platform%2Fupstream%2Fllvm.git [Windows SEH]: Fix -O2 crash for Windows -EHa This patch fixes a Windows -EHa crash induced by previous commit 797ad701522988e212495285dade8efac41a24d4. The crash was caused by "LifetimeMarker" scope (with option -O2) that should not be considered as SEH Scope. This change also turns off -fasync-exceptions by default under -EHa option for now. Differential Revision: https://reviews.llvm.org/D103664#2799944 --- diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp index b439204..b9364fc 100644 --- a/clang/lib/CodeGen/CGCleanup.cpp +++ b/clang/lib/CodeGen/CGCleanup.cpp @@ -195,7 +195,7 @@ void *EHScopeStack::pushCleanup(CleanupKind Kind, size_t Size) { Scope->setLifetimeMarker(); // With Windows -EHa, Invoke llvm.seh.scope.begin() for EHCleanup - if (CGF->getLangOpts().EHAsynch && IsEHCleanup && + if (CGF->getLangOpts().EHAsynch && IsEHCleanup && !IsLifetimeMarker && CGF->getTarget().getCXXABI().isMicrosoft()) CGF->EmitSehCppScopeBegin(); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index ee40df3..a0e1208 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7151,8 +7151,6 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType, 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");