Mercurial > projects > ldc
comparison gen/classes.cpp @ 315:a9697749e898 trunk
[svn r336] Made sure calls within a landing pad area are invokes.
Nested trys still need some consideration.
author | ChristianK |
---|---|
date | Thu, 03 Jul 2008 22:05:45 +0200 |
parents | d59c363fccad |
children | 781af50846b2 |
comparison
equal
deleted
inserted
replaced
314:8d98e42ece93 | 315:a9697749e898 |
---|---|
801 assert(newexp->newargs->dim == 1); | 801 assert(newexp->newargs->dim == 1); |
802 | 802 |
803 llvm::Function* fn = newexp->allocator->ir.irFunc->func; | 803 llvm::Function* fn = newexp->allocator->ir.irFunc->func; |
804 assert(fn); | 804 assert(fn); |
805 DValue* arg = ((Expression*)newexp->newargs->data[0])->toElem(gIR); | 805 DValue* arg = ((Expression*)newexp->newargs->data[0])->toElem(gIR); |
806 mem = gIR->ir->CreateCall(fn, arg->getRVal(), "newclass_custom_alloc"); | 806 mem = gIR->CreateCallOrInvoke(fn, arg->getRVal(), "newclass_custom_alloc")->get(); |
807 mem = DtoBitCast(mem, DtoType(tc), "newclass_custom"); | 807 mem = DtoBitCast(mem, DtoType(tc), "newclass_custom"); |
808 } | 808 } |
809 // default allocator | 809 // default allocator |
810 else | 810 else |
811 { | 811 { |
812 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_newclass"); | 812 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_newclass"); |
813 mem = gIR->ir->CreateCall(fn, tc->sym->ir.irStruct->classInfo, "newclass_gc_alloc"); | 813 mem = gIR->CreateCallOrInvoke(fn, tc->sym->ir.irStruct->classInfo, "newclass_gc_alloc")->get(); |
814 mem = DtoBitCast(mem, DtoType(tc), "newclass_gc"); | 814 mem = DtoBitCast(mem, DtoType(tc), "newclass_gc"); |
815 } | 815 } |
816 | 816 |
817 // init | 817 // init |
818 DtoInitClass(tc, mem); | 818 DtoInitClass(tc, mem); |
912 a = DtoBitCast(a, aty); | 912 a = DtoBitCast(a, aty); |
913 ctorargs.push_back(a); | 913 ctorargs.push_back(a); |
914 if (fnarg && fnarg->llvmByVal) | 914 if (fnarg && fnarg->llvmByVal) |
915 palist = palist.addAttr(i+2, llvm::ParamAttr::ByVal); // return,this is 2 | 915 palist = palist.addAttr(i+2, llvm::ParamAttr::ByVal); // return,this is 2 |
916 } | 916 } |
917 llvm::CallInst* call = llvm::CallInst::Create(fn, ctorargs.begin(), ctorargs.end(), "tmp", gIR->scopebb()); | 917 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, ctorargs.begin(), ctorargs.end(), "tmp"); |
918 call->setCallingConv(DtoCallingConv(LINKd)); | 918 call->setCallingConv(DtoCallingConv(LINKd)); |
919 call->setParamAttrs(palist); | 919 call->setParamAttrs(palist); |
920 | 920 |
921 return new DImValue(type, call, false); | 921 return new DImValue(type, call->get(), false); |
922 } | 922 } |
923 | 923 |
924 ////////////////////////////////////////////////////////////////////////////////////////// | 924 ////////////////////////////////////////////////////////////////////////////////////////// |
925 | 925 |
926 void DtoFinalizeClass(LLValue* inst) | 926 void DtoFinalizeClass(LLValue* inst) |
929 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_callfinalizer"); | 929 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_callfinalizer"); |
930 // build args | 930 // build args |
931 LLSmallVector<LLValue*,1> arg; | 931 LLSmallVector<LLValue*,1> arg; |
932 arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); | 932 arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); |
933 // call | 933 // call |
934 llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb()); | 934 gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end(), ""); |
935 } | 935 } |
936 | 936 |
937 ////////////////////////////////////////////////////////////////////////////////////////// | 937 ////////////////////////////////////////////////////////////////////////////////////////// |
938 | 938 |
939 DValue* DtoCastClass(DValue* val, Type* _to) | 939 DValue* DtoCastClass(DValue* val, Type* _to) |
1014 // this could happen in user code as well :/ | 1014 // this could happen in user code as well :/ |
1015 cinfo = DtoBitCast(cinfo, funcTy->getParamType(1)); | 1015 cinfo = DtoBitCast(cinfo, funcTy->getParamType(1)); |
1016 assert(funcTy->getParamType(1) == cinfo->getType()); | 1016 assert(funcTy->getParamType(1) == cinfo->getType()); |
1017 | 1017 |
1018 // call it | 1018 // call it |
1019 LLValue* ret = gIR->ir->CreateCall2(func, obj, cinfo, "tmp"); | 1019 LLValue* ret = gIR->CreateCallOrInvoke2(func, obj, cinfo, "tmp")->get(); |
1020 | 1020 |
1021 // cast return value | 1021 // cast return value |
1022 ret = DtoBitCast(ret, DtoType(_to)); | 1022 ret = DtoBitCast(ret, DtoType(_to)); |
1023 | 1023 |
1024 return new DImValue(_to, ret); | 1024 return new DImValue(_to, ret); |
1037 // void* p | 1037 // void* p |
1038 LLValue* tmp = val->getRVal(); | 1038 LLValue* tmp = val->getRVal(); |
1039 tmp = DtoBitCast(tmp, funcTy->getParamType(0)); | 1039 tmp = DtoBitCast(tmp, funcTy->getParamType(0)); |
1040 | 1040 |
1041 // call it | 1041 // call it |
1042 LLValue* ret = gIR->ir->CreateCall(func, tmp, "tmp"); | 1042 LLValue* ret = gIR->CreateCallOrInvoke(func, tmp, "tmp")->get(); |
1043 | 1043 |
1044 // cast return value | 1044 // cast return value |
1045 if (to != NULL) | 1045 if (to != NULL) |
1046 ret = DtoBitCast(ret, DtoType(to)); | 1046 ret = DtoBitCast(ret, DtoType(to)); |
1047 else | 1047 else |
1077 // unfortunately this is needed as the implementation of object differs somehow from the declaration | 1077 // unfortunately this is needed as the implementation of object differs somehow from the declaration |
1078 // this could happen in user code as well :/ | 1078 // this could happen in user code as well :/ |
1079 cinfo = DtoBitCast(cinfo, funcTy->getParamType(1)); | 1079 cinfo = DtoBitCast(cinfo, funcTy->getParamType(1)); |
1080 | 1080 |
1081 // call it | 1081 // call it |
1082 LLValue* ret = gIR->ir->CreateCall2(func, ptr, cinfo, "tmp"); | 1082 LLValue* ret = gIR->CreateCallOrInvoke2(func, ptr, cinfo, "tmp")->get(); |
1083 | 1083 |
1084 // cast return value | 1084 // cast return value |
1085 ret = DtoBitCast(ret, DtoType(_to)); | 1085 ret = DtoBitCast(ret, DtoType(_to)); |
1086 | 1086 |
1087 return new DImValue(_to, ret); | 1087 return new DImValue(_to, ret); |
1367 for (size_t i = 0; i < cd->dtors.dim; i++) | 1367 for (size_t i = 0; i < cd->dtors.dim; i++) |
1368 { | 1368 { |
1369 DtorDeclaration *d = (DtorDeclaration *)cd->dtors.data[i]; | 1369 DtorDeclaration *d = (DtorDeclaration *)cd->dtors.data[i]; |
1370 DtoForceDeclareDsymbol(d); | 1370 DtoForceDeclareDsymbol(d); |
1371 assert(d->ir.irFunc->func); | 1371 assert(d->ir.irFunc->func); |
1372 builder.CreateCall(d->ir.irFunc->func, thisptr); | 1372 gIR->CreateCallOrInvoke(d->ir.irFunc->func, thisptr); |
1373 } | 1373 } |
1374 builder.CreateRetVoid(); | 1374 builder.CreateRetVoid(); |
1375 | 1375 |
1376 return llvm::ConstantExpr::getBitCast(func, getPtrToType(LLType::Int8Ty)); | 1376 return llvm::ConstantExpr::getBitCast(func, getPtrToType(LLType::Int8Ty)); |
1377 #else | 1377 #else |