[Windows SEH]: Fix -O2 crash for Windows -EHa

This patch fixes a Windows -EHa crash induced by previous commit 797ad70152.
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
This commit is contained in:
Ten Tzen 2021-06-04 14:04:46 -07:00
parent 8ec9aa236e
commit 33ba8bd2c9
2 changed files with 1 additions and 3 deletions

View File

@ -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();

View File

@ -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");