Mercurial > projects > ldc
diff gen/llvmhelpers.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 | 8f121883bce8 |
children |
line wrap: on
line diff
--- a/gen/llvmhelpers.cpp Fri Mar 19 09:31:25 2010 +0100 +++ b/gen/llvmhelpers.cpp Wed May 19 12:42:32 2010 +0200 @@ -160,9 +160,11 @@ // call gIR->CreateCallOrInvoke(fn, args.begin(), args.end()); + #ifndef DISABLE_DEBUG_INFO // end debug info if (global.params.symdebug) DtoDwarfFuncEnd(gIR->func()->decl); + #endif // after assert is always unreachable gIR->ir->CreateUnreachable(); @@ -268,7 +270,7 @@ { // labels are a special case: they are not required to enclose the current scope // for them we use the enclosing scope handler as a reference point - LabelStatement* lblstmt = dynamic_cast<LabelStatement*>(target); + LabelStatement* lblstmt = target ? target->isLabelStatement() : 0; if (lblstmt) target = lblstmt->enclosingScopeExit; @@ -485,7 +487,7 @@ } // unknown - llvm::cout << "unsupported: null value for " << type->toChars() << '\n'; + error("unsupported: null value for %s", type->toChars()); assert(0); return 0; @@ -854,6 +856,7 @@ gvar->setInitializer(initVal); + #ifndef DISABLE_DEBUG_INFO // do debug info if (global.params.symdebug) { @@ -861,6 +864,7 @@ // keep a reference so GDCE doesn't delete it ! gIR->usedArray.push_back(llvm::ConstantExpr::getBitCast(gv, getVoidPtrType())); } + #endif } } @@ -906,11 +910,11 @@ ExpInitializer* ex = vd->init->isExpInitializer(); assert(ex && "ref vars must have expression initializer"); assert(ex->exp); - AssignExp* as = dynamic_cast<AssignExp*>(ex->exp); + AssignExp* as = ex->exp->isAssignExp(); assert(as && "ref vars must be initialized by an assign exp"); vd->ir.irLocal->value = as->e2->toElem(gIR)->getLVal(); } - + // referenced by nested delegate? #if DMDV2 if (vd->nestedrefs.dim) { @@ -919,7 +923,7 @@ #endif Logger::println("has nestedref set"); assert(vd->ir.irLocal); - + DtoNestedInit(vd); } // normal stack variable, allocate storage on the stack if it has not already been done @@ -937,10 +941,10 @@ //allocainst->setAlignment(vd->type->alignsize()); // TODO vd->ir.irLocal->value = allocainst; + #ifndef DISABLE_DEBUG_INFO if (global.params.symdebug) - { DtoDwarfLocalVariable(allocainst, vd); - } + #endif } else { @@ -1046,18 +1050,20 @@ // we don't handle aliases either assert(!var->aliassym); - + // alloca if necessary LLValue* allocaval = NULL; if (!addr && (!var->ir.irLocal || !var->ir.irLocal->value)) { addr = DtoAlloca(var->type, var->toChars()); - + + #ifndef DISABLE_DEBUG_INFO // add debug info if (global.params.symdebug) DtoDwarfLocalVariable(addr, var); + #endif } - + // referenced by nested function? #if DMDV2 if (var->nestedrefs.dim) @@ -1294,7 +1300,7 @@ Logger::println("template instance: %s", ti->toChars()); Logger::println("template declaration: %s", td->toChars()); Logger::println("intrinsic name: %s", td->intrinsicName.c_str()); - + // for now use the size in bits of the first template param in the instance assert(ti->tdtypes.dim == 1); Type* T = (Type*)ti->tdtypes.data[0]; @@ -1307,7 +1313,7 @@ char tmp[21]; // probably excessive, but covers a uint64_t sprintf(tmp, "%lu", (unsigned long) gTargetData->getTypeSizeInBits(DtoType(T))); - + // replace # in name with bitsize name = td->intrinsicName; @@ -1330,7 +1336,7 @@ fatal(); // or LLVM asserts } } - + Logger::println("final intrinsic name: %s", name.c_str()); } @@ -1340,7 +1346,7 @@ { if (FuncDeclaration* fd = s->isFuncDeclaration()) { - // we can't (and probably shouldn't?) define functions + // we can't (and probably shouldn't?) define functions // that weren't semantic3'ed if (fd->semanticRun < 4) return false; @@ -1352,7 +1358,7 @@ // Emit extra functions if we're inlining. // These will get available_externally linkage, // so they shouldn't end up in object code. - + assert(fd->type->ty == Tfunction); TypeFunction* tf = (TypeFunction*) fd->type; // * If we define extra static constructors, static destructors @@ -1371,7 +1377,7 @@ { return true; } - + // This was only semantic'ed for inlining checks. // We won't be inlining this, so we only need to emit a declaration. return false; @@ -1396,7 +1402,7 @@ { if (!opts::singleObj) return true; - + if (!tinst->emittedInModule) { gIR->seenTemplateInstances.insert(tinst); @@ -1404,7 +1410,7 @@ } return tinst->emittedInModule == gIR->dmodule; } - + return s->getModule() == gIR->dmodule; }