Mercurial > projects > ldc
diff gen/statements.cpp @ 1650:40bd4a0d4870
Update to work with LLVM 2.7.
Removed use of dyn_cast, llvm no compiles
without exceptions and rtti by
default. We do need exceptions for the libconfig stuff, but rtti isn't
necessary (anymore).
Debug info needs to be rewritten, as in LLVM 2.7 the format has
completely changed. To have something to look at while rewriting, the
old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means
that you have to define this to compile at the moment.
Updated tango 0.99.9 patch to include updated EH runtime code, which is
needed for LLVM 2.7 as well.
author | Tomas Lindquist Olsen |
---|---|
date | Wed, 19 May 2010 12:42:32 +0200 |
parents | 638a823ace45 |
children |
line wrap: on
line diff
--- a/gen/statements.cpp Fri Mar 19 09:31:25 2010 +0100 +++ b/gen/statements.cpp Wed May 19 12:42:32 2010 +0200 @@ -53,9 +53,11 @@ Logger::println("ReturnStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); - + #endif + // is there a return value expression? if (exp || (!exp && (p->topfunc() == p->mainFunc)) ) { @@ -78,8 +80,10 @@ // emit scopes DtoEnclosingHandlers(loc, NULL); + #ifndef DISABLE_DEBUG_INFO // emit dbg end function if (global.params.symdebug) DtoDwarfFuncEnd(f->decl); + #endif // emit ret llvm::ReturnInst::Create(gIR->context(), p->scopebb()); @@ -126,7 +130,9 @@ DtoEnclosingHandlers(loc, NULL); + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); + #endif llvm::ReturnInst::Create(gIR->context(), v, p->scopebb()); } } @@ -136,7 +142,9 @@ assert(p->topfunc()->getReturnType() == LLType::getVoidTy(gIR->context())); DtoEnclosingHandlers(loc, NULL); + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); + #endif llvm::ReturnInst::Create(gIR->context(), p->scopebb()); } @@ -153,8 +161,10 @@ Logger::println("ExpStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif if (exp) { if (global.params.llvmAnnotate) @@ -182,8 +192,10 @@ Logger::println("IfStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif if (match) DtoRawVarDeclaration(match); @@ -270,8 +282,10 @@ Logger::println("WhileStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif // create while blocks llvm::BasicBlock* oldend = gIR->scopeend(); @@ -318,8 +332,10 @@ Logger::println("DoStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif // create while blocks llvm::BasicBlock* oldend = gIR->scopeend(); @@ -363,8 +379,10 @@ Logger::println("ForStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif // create for blocks llvm::BasicBlock* oldend = gIR->scopeend(); @@ -443,8 +461,10 @@ if (p->scopereturned()) return; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif if (ident != 0) { Logger::println("ident = %s", ident->toChars()); @@ -498,8 +518,10 @@ Logger::println("ContinueStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif if (ident != 0) { Logger::println("ident = %s", ident->toChars()); @@ -564,8 +586,10 @@ Logger::println("TryFinallyStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif // if there's no finalbody or no body, things are simple if (!finalbody) { @@ -642,8 +666,10 @@ Logger::println("TryCatchStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif // create basic blocks llvm::BasicBlock* oldend = p->scopeend(); @@ -698,13 +724,17 @@ Logger::println("ThrowStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif assert(exp); DValue* e = exp->toElem(p); + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfFuncEnd(gIR->func()->decl); + #endif llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_throw_exception"); //Logger::cout() << "calling: " << *fn << '\n'; @@ -780,8 +810,10 @@ Logger::println("SwitchStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif llvm::BasicBlock* oldend = gIR->scopeend(); @@ -951,8 +983,10 @@ if (!statements || !statements->dim) return; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif // DMD doesn't fold stuff like continue/break, and since this isn't really a loop // we have to keep track of each statement and jump to the next/end on continue/break @@ -1017,8 +1051,10 @@ Logger::println("ForeachStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif //assert(arguments->dim == 1); assert(value != 0); @@ -1149,8 +1185,10 @@ Logger::println("ForeachRangeStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif // evaluate lwr/upr assert(lwr->type->isintegral()); @@ -1298,8 +1336,10 @@ Logger::println("GotoStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif llvm::BasicBlock* oldend = gIR->scopeend(); llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftergoto", p->topfunc(), oldend); @@ -1316,8 +1356,10 @@ Logger::println("GotoDefaultStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif llvm::BasicBlock* oldend = gIR->scopeend(); llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftergotodefault", p->topfunc(), oldend); @@ -1338,8 +1380,10 @@ Logger::println("GotoCaseStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif llvm::BasicBlock* oldend = gIR->scopeend(); llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftergotocase", p->topfunc(), oldend); @@ -1363,8 +1407,10 @@ Logger::println("WithStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif assert(exp); assert(body); @@ -1393,8 +1439,10 @@ Logger::println("SynchronizedStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif // enter lock if (exp) @@ -1430,8 +1478,10 @@ Logger::println("VolatileStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); + #endif // mark in-volatile // FIXME