Skip to content

Commit

Permalink
Merge pull request #7350 from WalterBright/win32eh
Browse files Browse the repository at this point in the history
fix Issue 17997 - autotester's d_do_test has strange failures with Win32
  • Loading branch information
WalterBright committed Nov 24, 2017
2 parents 9106109 + bcae082 commit 58f64bd
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/ddmd/backend/cgcod.c
Expand Up @@ -84,6 +84,7 @@ char needframe; // if TRUE, then we will need the frame
// pointer (BP for the 8088)
char gotref; // !=0 if the GOTsym was referenced
unsigned usednteh; // if !=0, then used NT exception handling
bool calledFinally; // true if called a BC_finally block

/* Register contents */
con_t regcon;
Expand Down Expand Up @@ -174,6 +175,7 @@ void codgen(Symbol *sfunc)
memset(_8087elems,0,sizeof(_8087elems));
#endif

calledFinally = false;
usednteh = 0;
#if (MARS) && TARGET_WINDOS
if (sfunc->Sfunc->Fflags3 & Fjmonitor)
Expand Down
1 change: 1 addition & 0 deletions src/ddmd/backend/cod1.c
Expand Up @@ -2960,6 +2960,7 @@ void cdfunc(CodeBuilder& cdb,elem *e,regm_t *pretregs)
* A better solution is turn this off only inside the cleanup code.
*/
!usednteh &&
!calledFinally &&
(numpara || config.exe == EX_WIN64) &&
stackpush == 0 && // cgstate.funcarg needs to be at top of stack
(cgstate.funcargtos == ~0 || numpara < cgstate.funcargtos) &&
Expand Down
4 changes: 3 additions & 1 deletion src/ddmd/backend/cod3.c
Expand Up @@ -754,6 +754,7 @@ static code *callFinallyBlock(block *bf, regm_t retregs)
CodeBuilder cdbr;
int nalign = 0;

calledFinally = true;
unsigned npush = gensaverestore(retregs,cdbs,cdbr);

if (STACKALIGN == 16)
Expand Down Expand Up @@ -949,7 +950,7 @@ void outblkexitcode(CodeBuilder& cdb, block *bl, int& anyspill, const char* sfls
/* Need to use frame pointer to access locals, not the stack pointer,
* because we'll be calling the BC_finally blocks and the stack will be off.
*/
usednteh |= EHtry;
needframe = 1;
}
else if (config.ehmethod == EH_SEH || config.ehmethod == EH_WIN32)
{
Expand Down Expand Up @@ -2210,6 +2211,7 @@ regm_t cod3_useBP()
config.flags & CFGstack ||
localsize >= 0x100 || // arbitrary value < 0x1000
(usednteh & (NTEH_try | NTEH_except | NTEHcpp | EHcleanup | EHtry | NTEHpassthru)) ||
calledFinally ||
Alloca.size
)
goto Lcant;
Expand Down
1 change: 1 addition & 0 deletions src/ddmd/backend/cod5.c
Expand Up @@ -51,6 +51,7 @@ void cod5_prol_epi()
anyiasm ||
Alloca.size ||
usednteh ||
calledFinally ||
tyf & (mTYnaked | mTYloadds) ||
tym == TYifunc ||
tym == TYmfunc || // can't yet handle ECX passed as parameter
Expand Down
1 change: 1 addition & 0 deletions src/ddmd/backend/code.h
Expand Up @@ -239,6 +239,7 @@ extern int reflocal;
extern bool anyiasm;
extern char calledafunc;
extern void(*cdxxx[])(CodeBuilder&,elem *,regm_t *);
extern bool calledFinally;

void stackoffsets(int);
void codgen(Symbol *);
Expand Down
2 changes: 1 addition & 1 deletion src/ddmd/dsymbolsem.d
Expand Up @@ -1202,7 +1202,7 @@ extern(C++) final class Semantic3Visitor : Visitor
/* Disable optimization on Win32 due to
* https://issues.dlang.org/show_bug.cgi?id=17997
*/
if (!global.params.isWindows || global.params.is64bit)
// if (!global.params.isWindows || global.params.is64bit)
funcdecl.eh_none = true; // don't generate unwind tables for this function
}

Expand Down

0 comments on commit 58f64bd

Please sign in to comment.