comparison gen/arrays.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 6b62e8cdf970
children 7086a84ab3d6
comparison
equal deleted inserted replaced
314:8d98e42ece93 315:a9697749e898
230 } 230 }
231 231
232 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, funcname); 232 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, funcname);
233 assert(fn); 233 assert(fn);
234 Logger::cout() << "calling array init function: " << *fn <<'\n'; 234 Logger::cout() << "calling array init function: " << *fn <<'\n';
235 llvm::CallInst* call = llvm::CallInst::Create(fn, args.begin(), args.end(), "", gIR->scopebb()); 235 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end());
236 call->setCallingConv(llvm::CallingConv::C); 236 call->setCallingConv(llvm::CallingConv::C);
237 } 237 }
238 238
239 ////////////////////////////////////////////////////////////////////////////////////////// 239 //////////////////////////////////////////////////////////////////////////////////////////
240 240
410 // get runtime function 410 // get runtime function
411 bool zeroInit = arrayType->toBasetype()->nextOf()->isZeroInit(); 411 bool zeroInit = arrayType->toBasetype()->nextOf()->isZeroInit();
412 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_newarrayT" : "_d_newarrayiT" ); 412 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_newarrayT" : "_d_newarrayiT" );
413 413
414 // call allocator 414 // call allocator
415 LLValue* newptr = gIR->ir->CreateCall2(fn, arrayTypeInfo, arrayLen, ".gc_mem"); 415 LLValue* newptr = gIR->CreateCallOrInvoke2(fn, arrayTypeInfo, arrayLen, ".gc_mem")->get();
416 416
417 // cast to wanted type 417 // cast to wanted type
418 const LLType* dstType = DtoType(arrayType)->getContainedType(1); 418 const LLType* dstType = DtoType(arrayType)->getContainedType(1);
419 if (newptr->getType() != dstType) 419 if (newptr->getType() != dstType)
420 newptr = DtoBitCast(newptr, dstType, ".gc_mem"); 420 newptr = DtoBitCast(newptr, dstType, ".gc_mem");
458 if (!firstDim) firstDim = dim; 458 if (!firstDim) firstDim = dim;
459 DtoStore(dim, DtoGEPi1(dimsArg, i)); 459 DtoStore(dim, DtoGEPi1(dimsArg, i));
460 } 460 }
461 461
462 // call allocator 462 // call allocator
463 LLValue* newptr = gIR->ir->CreateCall3(fn, arrayTypeInfo, DtoConstSize_t(ndims), dimsArg, ".gc_mem"); 463 LLValue* newptr = gIR->CreateCallOrInvoke3(fn, arrayTypeInfo, DtoConstSize_t(ndims), dimsArg, ".gc_mem")->get();
464 464
465 // cast to wanted type 465 // cast to wanted type
466 const LLType* dstType = DtoType(arrayType)->getContainedType(1); 466 const LLType* dstType = DtoType(arrayType)->getContainedType(1);
467 if (newptr->getType() != dstType) 467 if (newptr->getType() != dstType)
468 newptr = DtoBitCast(newptr, dstType, ".gc_mem"); 468 newptr = DtoBitCast(newptr, dstType, ".gc_mem");
504 504
505 LLValue* arrPtr = DtoArrayPtr(array); 505 LLValue* arrPtr = DtoArrayPtr(array);
506 Logger::cout() << "arrPtr = " << *arrPtr << '\n'; 506 Logger::cout() << "arrPtr = " << *arrPtr << '\n';
507 args.push_back(DtoBitCast(arrPtr, fn->getFunctionType()->getParamType(3), "tmp")); 507 args.push_back(DtoBitCast(arrPtr, fn->getFunctionType()->getParamType(3), "tmp"));
508 508
509 LLValue* newptr = gIR->ir->CreateCall(fn, args.begin(), args.end(), ".gc_mem"); 509 LLValue* newptr = gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), ".gc_mem")->get();
510 if (newptr->getType() != arrPtr->getType()) 510 if (newptr->getType() != arrPtr->getType())
511 newptr = DtoBitCast(newptr, arrPtr->getType(), ".gc_mem"); 511 newptr = DtoBitCast(newptr, arrPtr->getType(), ".gc_mem");
512 512
513 return new DSliceValue(arrayType, newdim->getRVal(), newptr); 513 return new DSliceValue(arrayType, newdim->getRVal(), newptr);
514 } 514 }
751 751
752 pt = fn->getFunctionType()->getParamType(2); 752 pt = fn->getFunctionType()->getParamType(2);
753 args.push_back(DtoBitCast(tival, pt)); 753 args.push_back(DtoBitCast(tival, pt));
754 } 754 }
755 755
756 llvm::CallInst* call = gIR->ir->CreateCall(fn, args.begin(), args.end(), "tmp"); 756 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp");
757 757
758 // set param attrs 758 // set param attrs
759 llvm::PAListPtr palist; 759 llvm::PAListPtr palist;
760 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); 760 palist = palist.addAttr(1, llvm::ParamAttr::ByVal);
761 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); 761 palist = palist.addAttr(2, llvm::ParamAttr::ByVal);
762 call->setParamAttrs(palist); 762 call->setParamAttrs(palist);
763 763
764 return call; 764 return call->get();
765 } 765 }
766 766
767 ////////////////////////////////////////////////////////////////////////////////////////// 767 //////////////////////////////////////////////////////////////////////////////////////////
768 LLValue* DtoArrayEquals(TOK op, DValue* l, DValue* r) 768 LLValue* DtoArrayEquals(TOK op, DValue* l, DValue* r)
769 { 769 {
852 args.push_back(len); 852 args.push_back(len);
853 args.push_back(llvm::ConstantInt::get(DtoSize_t(), esz, false)); 853 args.push_back(llvm::ConstantInt::get(DtoSize_t(), esz, false));
854 args.push_back(llvm::ConstantInt::get(DtoSize_t(), nsz, false)); 854 args.push_back(llvm::ConstantInt::get(DtoSize_t(), nsz, false));
855 855
856 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len"); 856 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len");
857 return llvm::CallInst::Create(fn, args.begin(), args.end(), "tmp", gIR->scopebb()); 857 return gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp")->get();
858 } 858 }
859 859
860 ////////////////////////////////////////////////////////////////////////////////////////// 860 //////////////////////////////////////////////////////////////////////////////////////////
861 LLValue* DtoDynArrayIs(TOK op, DValue* l, DValue* r) 861 LLValue* DtoDynArrayIs(TOK op, DValue* l, DValue* r)
862 { 862 {