comparison gen/typinf.cpp @ 918:a4fcc13da3cd

Changed templates and typeinfo to use linkonce linkage instead of weak linkage, this should fix inlining problems, fixing bug #197 . If problems show up, it's easy to change it back by changing the define in mars.h . I'm 95% sure this is safe, given how we handle templates.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 02 Feb 2009 01:44:51 +0100
parents 2dfd05525e2e
children f0b6549055ab
comparison
equal deleted inserted replaced
917:7e272f2b4fc3 918:a4fcc13da3cd
377 DtoResolveClass(base); 377 DtoResolveClass(base);
378 378
379 const LLStructType* stype = isaStruct(base->type->ir.type->get()); 379 const LLStructType* stype = isaStruct(base->type->ir.type->get());
380 380
381 // create the symbol 381 // create the symbol
382 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); 382 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
383 } 383 }
384 384
385 void TypeInfoTypedefDeclaration::llvmDefine() 385 void TypeInfoTypedefDeclaration::llvmDefine()
386 { 386 {
387 Logger::println("TypeInfoTypedefDeclaration::llvmDefine() %s", toChars()); 387 Logger::println("TypeInfoTypedefDeclaration::llvmDefine() %s", toChars());
451 451
452 ClassDeclaration* base = Type::typeinfoenum; 452 ClassDeclaration* base = Type::typeinfoenum;
453 DtoResolveClass(base); 453 DtoResolveClass(base);
454 454
455 // create the symbol 455 // create the symbol
456 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); 456 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
457 } 457 }
458 458
459 void TypeInfoEnumDeclaration::llvmDefine() 459 void TypeInfoEnumDeclaration::llvmDefine()
460 { 460 {
461 Logger::println("TypeInfoEnumDeclaration::llvmDefine() %s", toChars()); 461 Logger::println("TypeInfoEnumDeclaration::llvmDefine() %s", toChars());
526 { 526 {
527 ClassDeclaration* base = cd; 527 ClassDeclaration* base = cd;
528 DtoResolveClass(base); 528 DtoResolveClass(base);
529 529
530 // create the symbol 530 // create the symbol
531 tid->ir.irGlobal->value = new llvm::GlobalVariable(tid->ir.irGlobal->type.get(), true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module); 531 tid->ir.irGlobal->value = new llvm::GlobalVariable(tid->ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, tid->toChars(), gIR->module);
532 } 532 }
533 533
534 static void LLVM_D_Define_TypeInfoBase(Type* basetype, TypeInfoDeclaration* tid, ClassDeclaration* cd) 534 static void LLVM_D_Define_TypeInfoBase(Type* basetype, TypeInfoDeclaration* tid, ClassDeclaration* cd)
535 { 535 {
536 ClassDeclaration* base = cd; 536 ClassDeclaration* base = cd;
625 // init typeinfo class 625 // init typeinfo class
626 ClassDeclaration* base = Type::typeinfostaticarray; 626 ClassDeclaration* base = Type::typeinfostaticarray;
627 DtoResolveClass(base); 627 DtoResolveClass(base);
628 628
629 // create the symbol 629 // create the symbol
630 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); 630 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
631 } 631 }
632 632
633 void TypeInfoStaticArrayDeclaration::llvmDefine() 633 void TypeInfoStaticArrayDeclaration::llvmDefine()
634 { 634 {
635 Logger::println("TypeInfoStaticArrayDeclaration::toDt() %s", toChars()); 635 Logger::println("TypeInfoStaticArrayDeclaration::toDt() %s", toChars());
685 // init typeinfo class 685 // init typeinfo class
686 ClassDeclaration* base = Type::typeinfoassociativearray; 686 ClassDeclaration* base = Type::typeinfoassociativearray;
687 DtoResolveClass(base); 687 DtoResolveClass(base);
688 688
689 // create the symbol 689 // create the symbol
690 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); 690 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
691 } 691 }
692 692
693 void TypeInfoAssociativeArrayDeclaration::llvmDefine() 693 void TypeInfoAssociativeArrayDeclaration::llvmDefine()
694 { 694 {
695 Logger::println("TypeInfoAssociativeArrayDeclaration::toDt() %s", toChars()); 695 Logger::println("TypeInfoAssociativeArrayDeclaration::toDt() %s", toChars());
806 806
807 ClassDeclaration* base = Type::typeinfostruct; 807 ClassDeclaration* base = Type::typeinfostruct;
808 DtoResolveClass(base); 808 DtoResolveClass(base);
809 809
810 // create the symbol 810 // create the symbol
811 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); 811 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
812 } 812 }
813 813
814 void TypeInfoStructDeclaration::llvmDefine() 814 void TypeInfoStructDeclaration::llvmDefine()
815 { 815 {
816 Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars()); 816 Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars());
1022 ClassDeclaration* base = Type::typeinfoclass; 1022 ClassDeclaration* base = Type::typeinfoclass;
1023 assert(base); 1023 assert(base);
1024 DtoResolveClass(base); 1024 DtoResolveClass(base);
1025 1025
1026 // create the symbol 1026 // create the symbol
1027 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, llvm::GlobalValue::WeakLinkage, NULL, toChars(), gIR->module); 1027 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
1028 } 1028 }
1029 1029
1030 void TypeInfoClassDeclaration::llvmDefine() 1030 void TypeInfoClassDeclaration::llvmDefine()
1031 { 1031 {
1032 Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars()); 1032 Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars());
1078 ClassDeclaration* base = Type::typeinfointerface; 1078 ClassDeclaration* base = Type::typeinfointerface;
1079 assert(base); 1079 assert(base);
1080 DtoResolveClass(base); 1080 DtoResolveClass(base);
1081 1081
1082 // create the symbol 1082 // create the symbol
1083 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); 1083 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
1084 } 1084 }
1085 1085
1086 void TypeInfoInterfaceDeclaration::llvmDefine() 1086 void TypeInfoInterfaceDeclaration::llvmDefine()
1087 { 1087 {
1088 Logger::println("TypeInfoInterfaceDeclaration::llvmDefine() %s", toChars()); 1088 Logger::println("TypeInfoInterfaceDeclaration::llvmDefine() %s", toChars());
1136 ClassDeclaration* base = Type::typeinfotypelist; 1136 ClassDeclaration* base = Type::typeinfotypelist;
1137 assert(base); 1137 assert(base);
1138 DtoResolveClass(base); 1138 DtoResolveClass(base);
1139 1139
1140 // create the symbol 1140 // create the symbol
1141 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); 1141 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
1142 } 1142 }
1143 1143
1144 void TypeInfoTupleDeclaration::llvmDefine() 1144 void TypeInfoTupleDeclaration::llvmDefine()
1145 { 1145 {
1146 Logger::println("TypeInfoTupleDeclaration::llvmDefine() %s", toChars()); 1146 Logger::println("TypeInfoTupleDeclaration::llvmDefine() %s", toChars());
1183 // build array type 1183 // build array type
1184 const LLArrayType* arrTy = LLArrayType::get(tiTy, dim); 1184 const LLArrayType* arrTy = LLArrayType::get(tiTy, dim);
1185 LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits); 1185 LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits);
1186 1186
1187 // need the pointer to the first element of arrC, so create a global for it 1187 // need the pointer to the first element of arrC, so create a global for it
1188 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; 1188 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;
1189 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(arrTy,true,_linkage,arrC,".tupleelements",gIR->module); 1189 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(arrTy,true,_linkage,arrC,".tupleelements",gIR->module);
1190 1190
1191 // get pointer to first element 1191 // get pointer to first element
1192 llvm::ConstantInt* zero = DtoConstSize_t(0); 1192 llvm::ConstantInt* zero = DtoConstSize_t(0);
1193 LLConstant* idxs[2] = { zero, zero }; 1193 LLConstant* idxs[2] = { zero, zero };