From 79edefdc37e3e018d233368dbf38234250d47002 Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Tue, 19 Jul 2011 22:22:49 +0400 Subject: [PATCH] Fixed compilation of functions that does not have return statement but contain inline asm --- dmd2/func.c | 1 - gen/asmstmt.cpp | 9 ++++----- gen/functions.cpp | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/dmd2/func.c b/dmd2/func.c index 557d504b..2f8bccd5 100644 --- a/dmd2/func.c +++ b/dmd2/func.c @@ -93,7 +93,6 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla isArrayOp = false; allowInlining = false; availableExternally = true; // assume this unless proven otherwise - inlineAsm = true; // function types in ldc don't merge if the context parameter differs // so we actually don't care about the function declaration, but only diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 0dc9716e..2355ca4f 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -162,10 +162,8 @@ Statement *AsmStatement::semantic(Scope *sc) //puts(toChars()); - sc->func->inlineAsm = true; + sc->func->hasReturnExp |= 8; sc->func->inlineStatus = ILSno; // %% not sure - // %% need to set DECL_UNINLINABLE too? - sc->func->hasReturnExp = 1; // %% DMD does this, apparently... // empty statement -- still do the above things because they might be expected? if (! tokens) @@ -193,7 +191,8 @@ int AsmStatement::blockExit() if (mustNotThrow) error("asm statements are assumed to throw", toChars()); #endif - return BEfallthru | BEreturn | BEgoto | BEhalt; + // Assume the worst + return BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt; } void @@ -203,7 +202,7 @@ AsmStatement::toIR(IRState * irs) LOG_SCOPE; // sanity check - assert(irs->func()->decl->inlineAsm); + assert(irs->func()->decl->hasReturnExp & 8); // get asm block IRAsmBlock* asmblock = irs->asmBlock; diff --git a/gen/functions.cpp b/gen/functions.cpp index 668b540b..b3c7459f 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -689,7 +689,7 @@ void DtoDefineFunction(FuncDeclaration* fd) // this hack makes sure the frame pointer elimination optimization is disabled. // this this eliminates a bunch of inline asm related issues. - if (fd->inlineAsm) + if (fd->hasReturnExp & 8) // has inline asm { // emit a call to llvm_eh_unwind_init LLFunction* hack = GET_INTRINSIC_DECL(eh_unwind_init);