Mercurial > projects > ldc
comparison gen/runtime.cpp @ 1300:329e45865d84
Add 'nounwind' attribute to the relevant runtime functions, and use it when
deciding whether or not to generate an invoke instead of a call.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Mon, 04 May 2009 20:26:45 +0200 |
parents | 00b408a5b7fa |
children | c78fd2d30da1 |
comparison
equal
deleted
inserted
replaced
1299:847b767b2d0b | 1300:329e45865d84 |
---|---|
196 // Construct some attribute lists used below (possibly multiple times) | 196 // Construct some attribute lists used below (possibly multiple times) |
197 llvm::AttrListPtr | 197 llvm::AttrListPtr |
198 NoAttrs, | 198 NoAttrs, |
199 Attr_NoAlias | 199 Attr_NoAlias |
200 = NoAttrs.addAttr(0, NoAlias), | 200 = NoAttrs.addAttr(0, NoAlias), |
201 Attr_NoUnwind | |
202 = NoAttrs.addAttr(~0U, NoUnwind), | |
201 Attr_ReadOnly | 203 Attr_ReadOnly |
202 = NoAttrs.addAttr(~0U, ReadOnly), | 204 = NoAttrs.addAttr(~0U, ReadOnly), |
205 Attr_ReadOnly_NoUnwind | |
206 = Attr_ReadOnly.addAttr(~0U, NoUnwind), | |
203 Attr_ReadOnly_1_NoCapture | 207 Attr_ReadOnly_1_NoCapture |
204 = Attr_ReadOnly.addAttr(1, NoCapture), | 208 = Attr_ReadOnly.addAttr(1, NoCapture), |
205 Attr_ReadOnly_1_3_NoCapture | 209 Attr_ReadOnly_1_3_NoCapture |
206 = Attr_ReadOnly_1_NoCapture.addAttr(3, NoCapture), | 210 = Attr_ReadOnly_1_NoCapture.addAttr(3, NoCapture), |
207 Attr_ReadOnly_1_4_NoCapture | 211 Attr_ReadOnly_1_4_NoCapture |
208 = Attr_ReadOnly_1_NoCapture.addAttr(4, NoCapture), | 212 = Attr_ReadOnly_1_NoCapture.addAttr(4, NoCapture), |
213 Attr_ReadOnly_NoUnwind_1_NoCapture | |
214 = Attr_ReadOnly_1_NoCapture.addAttr(~0U, NoUnwind), | |
209 Attr_ReadNone | 215 Attr_ReadNone |
210 = NoAttrs.addAttr(~0U, ReadNone), | 216 = NoAttrs.addAttr(~0U, ReadNone), |
211 Attr_1_NoCapture | 217 Attr_1_NoCapture |
212 = NoAttrs.addAttr(1, NoCapture), | 218 = NoAttrs.addAttr(1, NoCapture), |
213 Attr_NoAlias_1_NoCapture | 219 Attr_NoAlias_1_NoCapture |
505 std::string fname("_d_toObject"); | 511 std::string fname("_d_toObject"); |
506 std::vector<const LLType*> types; | 512 std::vector<const LLType*> types; |
507 types.push_back(voidPtrTy); | 513 types.push_back(voidPtrTy); |
508 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | 514 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
509 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) | 515 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
510 ->setAttributes(Attr_ReadOnly); | 516 ->setAttributes(Attr_ReadOnly_NoUnwind); |
511 } | 517 } |
512 | 518 |
513 // cast interface | 519 // cast interface |
514 // Object _d_interface_cast(void* p, ClassInfo c) | 520 // Object _d_interface_cast(void* p, ClassInfo c) |
515 { | 521 { |
517 std::vector<const LLType*> types; | 523 std::vector<const LLType*> types; |
518 types.push_back(voidPtrTy); | 524 types.push_back(voidPtrTy); |
519 types.push_back(classInfoTy); | 525 types.push_back(classInfoTy); |
520 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | 526 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
521 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) | 527 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
522 ->setAttributes(Attr_ReadOnly); | 528 ->setAttributes(Attr_ReadOnly_NoUnwind); |
523 } | 529 } |
524 | 530 |
525 // dynamic cast | 531 // dynamic cast |
526 // Object _d_dynamic_cast(Object o, ClassInfo c) | 532 // Object _d_dynamic_cast(Object o, ClassInfo c) |
527 { | 533 { |
529 std::vector<const LLType*> types; | 535 std::vector<const LLType*> types; |
530 types.push_back(objectTy); | 536 types.push_back(objectTy); |
531 types.push_back(classInfoTy); | 537 types.push_back(classInfoTy); |
532 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | 538 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
533 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) | 539 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
534 ->setAttributes(Attr_ReadOnly); | 540 ->setAttributes(Attr_ReadOnly_NoUnwind); |
535 } | 541 } |
536 | 542 |
537 ///////////////////////////////////////////////////////////////////////////////////// | 543 ///////////////////////////////////////////////////////////////////////////////////// |
538 ///////////////////////////////////////////////////////////////////////////////////// | 544 ///////////////////////////////////////////////////////////////////////////////////// |
539 ///////////////////////////////////////////////////////////////////////////////////// | 545 ///////////////////////////////////////////////////////////////////////////////////// |
567 std::string fname("_adReverse"); | 573 std::string fname("_adReverse"); |
568 std::vector<const LLType*> types; | 574 std::vector<const LLType*> types; |
569 types.push_back(rt_array(byteTy)); | 575 types.push_back(rt_array(byteTy)); |
570 types.push_back(sizeTy); | 576 types.push_back(sizeTy); |
571 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false); | 577 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false); |
572 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 578 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
579 ->setAttributes(Attr_NoUnwind); | |
573 } | 580 } |
574 | 581 |
575 // void[] _adDupT(TypeInfo ti, void[] a) | 582 // void[] _adDupT(TypeInfo ti, void[] a) |
576 { | 583 { |
577 std::string fname("_adDupT"); | 584 std::string fname("_adDupT"); |
605 std::vector<const LLType*> types; | 612 std::vector<const LLType*> types; |
606 types.push_back(rt_array(byteTy)); | 613 types.push_back(rt_array(byteTy)); |
607 types.push_back(rt_array(byteTy)); | 614 types.push_back(rt_array(byteTy)); |
608 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | 615 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
609 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) | 616 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
610 ->setAttributes(Attr_ReadOnly); | 617 ->setAttributes(Attr_ReadOnly_NoUnwind); |
611 } | 618 } |
612 | 619 |
613 // void[] _adSort(void[] a, TypeInfo ti) | 620 // void[] _adSort(void[] a, TypeInfo ti) |
614 { | 621 { |
615 std::string fname("_adSort"); | 622 std::string fname("_adSort"); |
629 std::string fname("_aaLen"); | 636 std::string fname("_aaLen"); |
630 std::vector<const LLType*> types; | 637 std::vector<const LLType*> types; |
631 types.push_back(aaTy); | 638 types.push_back(aaTy); |
632 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); | 639 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); |
633 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) | 640 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
634 ->setAttributes(Attr_ReadOnly_1_NoCapture); | 641 ->setAttributes(Attr_ReadOnly_NoUnwind_1_NoCapture); |
635 } | 642 } |
636 | 643 |
637 // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) | 644 // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) |
638 { | 645 { |
639 std::string fname("_aaGet"); | 646 std::string fname("_aaGet"); |
752 std::string fname2("_moduleDtor"); | 759 std::string fname2("_moduleDtor"); |
753 std::vector<const LLType*> types; | 760 std::vector<const LLType*> types; |
754 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | 761 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
755 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 762 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
756 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | 763 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); |
757 } | |
758 | |
759 ///////////////////////////////////////////////////////////////////////////////////// | |
760 ///////////////////////////////////////////////////////////////////////////////////// | |
761 ///////////////////////////////////////////////////////////////////////////////////// | |
762 | |
763 // Object _d_dynamic_cast(Object o, ClassInfo c) | |
764 { | |
765 std::string fname("_d_dynamic_cast"); | |
766 std::vector<const LLType*> types; | |
767 types.push_back(objectTy); | |
768 types.push_back(classInfoTy); | |
769 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
770 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) | |
771 ->setAttributes(Attr_ReadOnly); | |
772 } | |
773 | |
774 // Object _d_interface_cast(void* p, ClassInfo c) | |
775 { | |
776 std::string fname("_d_interface_cast"); | |
777 std::vector<const LLType*> types; | |
778 types.push_back(voidPtrTy); | |
779 types.push_back(classInfoTy); | |
780 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
781 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) | |
782 ->setAttributes(Attr_ReadOnly); | |
783 } | 764 } |
784 | 765 |
785 ///////////////////////////////////////////////////////////////////////////////////// | 766 ///////////////////////////////////////////////////////////////////////////////////// |
786 ///////////////////////////////////////////////////////////////////////////////////// | 767 ///////////////////////////////////////////////////////////////////////////////////// |
787 ///////////////////////////////////////////////////////////////////////////////////// | 768 ///////////////////////////////////////////////////////////////////////////////////// |