Mercurial > projects > ldc
comparison gen/functions.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 | 207a8a438dea |
children |
comparison
equal
deleted
inserted
replaced
1649:36da40ecbbe0 | 1650:40bd4a0d4870 |
---|---|
597 { | 597 { |
598 DtoDefineNakedFunction(fd); | 598 DtoDefineNakedFunction(fd); |
599 return; | 599 return; |
600 } | 600 } |
601 | 601 |
602 #ifndef DISABLE_DEBUG_INFO | |
602 // debug info | 603 // debug info |
603 if (global.params.symdebug) { | 604 if (global.params.symdebug) |
604 fd->ir.irFunc->diSubprogram = DtoDwarfSubProgram(fd); | 605 fd->ir.irFunc->diSubprogram = DtoDwarfSubProgram(fd); |
605 } | 606 #endif |
606 | 607 |
607 Type* t = fd->type->toBasetype(); | 608 Type* t = fd->type->toBasetype(); |
608 TypeFunction* f = (TypeFunction*)t; | 609 TypeFunction* f = (TypeFunction*)t; |
609 assert(f->irtype); | 610 assert(f->irtype); |
610 | 611 |
640 // create alloca point | 641 // create alloca point |
641 // this gets erased when the function is complete, so alignment etc does not matter at all | 642 // this gets erased when the function is complete, so alignment etc does not matter at all |
642 llvm::Instruction* allocaPoint = new llvm::AllocaInst(LLType::getInt32Ty(gIR->context()), "alloca point", beginbb); | 643 llvm::Instruction* allocaPoint = new llvm::AllocaInst(LLType::getInt32Ty(gIR->context()), "alloca point", beginbb); |
643 irfunction->allocapoint = allocaPoint; | 644 irfunction->allocapoint = allocaPoint; |
644 | 645 |
646 #ifndef DISABLE_DEBUG_INFO | |
645 // debug info - after all allocas, but before any llvm.dbg.declare etc | 647 // debug info - after all allocas, but before any llvm.dbg.declare etc |
646 if (global.params.symdebug) DtoDwarfFuncStart(fd); | 648 if (global.params.symdebug) DtoDwarfFuncStart(fd); |
649 #endif | |
647 | 650 |
648 // this hack makes sure the frame pointer elimination optimization is disabled. | 651 // this hack makes sure the frame pointer elimination optimization is disabled. |
649 // this this eliminates a bunch of inline asm related issues. | 652 // this this eliminates a bunch of inline asm related issues. |
650 if (fd->inlineAsm) | 653 if (fd->inlineAsm) |
651 { | 654 { |
666 | 669 |
667 assert(!fd->vthis->ir.irLocal); | 670 assert(!fd->vthis->ir.irLocal); |
668 fd->vthis->ir.irLocal = new IrLocal(fd->vthis); | 671 fd->vthis->ir.irLocal = new IrLocal(fd->vthis); |
669 fd->vthis->ir.irLocal->value = thismem; | 672 fd->vthis->ir.irLocal->value = thismem; |
670 | 673 |
674 #ifndef DISABLE_DEBUG_INFO | |
671 if (global.params.symdebug) | 675 if (global.params.symdebug) |
672 DtoDwarfLocalVariable(thismem, fd->vthis); | 676 DtoDwarfLocalVariable(thismem, fd->vthis); |
677 #endif | |
673 | 678 |
674 #if DMDV1 | 679 #if DMDV1 |
675 if (fd->vthis->nestedref) | 680 if (fd->vthis->nestedref) |
676 { | 681 { |
677 fd->nestedVars.insert(fd->vthis); | 682 fd->nestedVars.insert(fd->vthis); |
720 | 725 |
721 // set the arg var value to the alloca | 726 // set the arg var value to the alloca |
722 irloc->value = mem; | 727 irloc->value = mem; |
723 } | 728 } |
724 | 729 |
730 #ifndef DISABLE_DEBUG_INFO | |
725 if (global.params.symdebug && !(isaArgument(irloc->value) && !isaArgument(irloc->value)->hasByValAttr()) && !refout) | 731 if (global.params.symdebug && !(isaArgument(irloc->value) && !isaArgument(irloc->value)->hasByValAttr()) && !refout) |
726 DtoDwarfLocalVariable(irloc->value, vd); | 732 DtoDwarfLocalVariable(irloc->value, vd); |
733 #endif | |
727 } | 734 } |
728 } | 735 } |
729 | 736 |
730 // need result variable? (nested) | 737 // need result variable? (nested) |
731 #if DMDV1 | 738 #if DMDV1 |
756 DtoNestedInit(fd->vresult); | 763 DtoNestedInit(fd->vresult); |
757 } else if (fd->vresult) { | 764 } else if (fd->vresult) { |
758 fd->vresult->ir.irLocal = new IrLocal(fd->vresult); | 765 fd->vresult->ir.irLocal = new IrLocal(fd->vresult); |
759 fd->vresult->ir.irLocal->value = DtoAlloca(fd->vresult->type, fd->vresult->toChars()); | 766 fd->vresult->ir.irLocal->value = DtoAlloca(fd->vresult->type, fd->vresult->toChars()); |
760 } | 767 } |
761 | 768 |
762 // copy _argptr and _arguments to a memory location | 769 // copy _argptr and _arguments to a memory location |
763 if (f->linkage == LINKd && f->varargs == 1) | 770 if (f->linkage == LINKd && f->varargs == 1) |
764 { | 771 { |
765 // _argptr | 772 // _argptr |
766 LLValue* argptrmem = DtoRawAlloca(fd->ir.irFunc->_argptr->getType(), 0, "_argptr_mem"); | 773 LLValue* argptrmem = DtoRawAlloca(fd->ir.irFunc->_argptr->getType(), 0, "_argptr_mem"); |
792 // is the last statement in a function) | 799 // is the last statement in a function) |
793 bb->eraseFromParent(); | 800 bb->eraseFromParent(); |
794 } else if (!gIR->scopereturned()) { | 801 } else if (!gIR->scopereturned()) { |
795 // llvm requires all basic blocks to end with a TerminatorInst but DMD does not put a return statement | 802 // llvm requires all basic blocks to end with a TerminatorInst but DMD does not put a return statement |
796 // in automatically, so we do it here. | 803 // in automatically, so we do it here. |
797 | 804 |
798 // pass the previous block into this block | 805 // pass the previous block into this block |
806 #ifndef DISABLE_DEBUG_INFO | |
799 if (global.params.symdebug) DtoDwarfFuncEnd(fd); | 807 if (global.params.symdebug) DtoDwarfFuncEnd(fd); |
808 #endif | |
800 if (func->getReturnType() == LLType::getVoidTy(gIR->context())) { | 809 if (func->getReturnType() == LLType::getVoidTy(gIR->context())) { |
801 llvm::ReturnInst::Create(gIR->context(), gIR->scopebb()); | 810 llvm::ReturnInst::Create(gIR->context(), gIR->scopebb()); |
802 } | 811 } |
803 else if (!fd->isMain()) { | 812 else if (!fd->isMain()) { |
804 AsmBlockStatement* asmb = fd->fbody->endsWithAsm(); | 813 AsmBlockStatement* asmb = fd->fbody->endsWithAsm(); |