@@ -40,10 +40,8 @@ import syntax::codemap::span;
4040import lib:: llvm:: llvm;
4141import lib:: llvm:: builder;
4242import lib:: llvm:: target_data;
43- import lib:: llvm:: type_handle;
4443import lib:: llvm:: type_names;
4544import lib:: llvm:: mk_target_data;
46- import lib:: llvm:: mk_type_handle;
4745import lib:: llvm:: mk_type_names;
4846import lib:: llvm:: llvm:: ModuleRef ;
4947import lib:: llvm:: llvm:: ValueRef ;
@@ -475,18 +473,29 @@ fn T_struct(&TypeRef[] elts) -> TypeRef {
475473 False ) ;
476474}
477475
478- fn T_opaque ( ) -> TypeRef { ret llvm:: LLVMOpaqueType ( ) ; }
476+ fn T_named_struct ( & str name) -> TypeRef {
477+ auto c = llvm:: LLVMGetGlobalContext ( ) ;
478+ ret llvm:: LLVMStructCreateNamed ( c, str:: buf ( name) ) ;
479+ }
480+
481+ fn set_struct_body( TypeRef t, & TypeRef [ ] elts) {
482+ llvm:: LLVMStructSetBody ( t, std:: ivec:: to_ptr ( elts) , std:: ivec:: len ( elts) ,
483+ False ) ;
484+ }
479485
480486fn T_empty_struct ( ) -> TypeRef { ret T_struct ( ~[ ] ) ; }
481487
482488fn T_rust_object ( ) -> TypeRef {
483- auto e = T_ptr ( T_empty_struct ( ) ) ;
484- ret T_struct ( ~[ e, e] ) ;
489+ auto t = T_named_struct ( "rust_object" ) ;
490+ auto e = T_ptr ( T_empty_struct ( ) ) ;
491+ set_struct_body ( t, ~[ e, e] ) ;
492+ ret t;
485493}
486494
487495fn T_task ( ) -> TypeRef {
488- auto t =
489- T_struct ( ~[ T_int ( ) , // Refcount
496+ auto t = T_named_struct ( "task" ) ;
497+
498+ auto elems = ~[ T_int ( ) , // Refcount
490499 T_int ( ) , // Delegate pointer
491500 T_int ( ) , // Stack segment pointer
492501 T_int ( ) , // Runtime SP
@@ -495,7 +504,8 @@ fn T_task() -> TypeRef {
495504
496505 T_int ( ) , // Domain pointer
497506 // Crate cache pointer
498- T_int ( ) ] ) ;
507+ T_int ( ) ] ;
508+ set_struct_body ( t, elems) ;
499509 ret t;
500510}
501511
@@ -532,18 +542,17 @@ fn T_cmp_glue_fn(&crate_ctxt cx) -> TypeRef {
532542}
533543
534544fn T_tydesc ( TypeRef taskptr_type ) -> TypeRef {
535- auto th = mk_type_handle ( ) ;
536- auto abs_tydesc = llvm:: LLVMResolveTypeHandle ( th. llth ) ;
537- auto tydescpp = T_ptr ( T_ptr ( abs_tydesc) ) ;
545+ auto tydesc = T_named_struct ( "tydesc" ) ;
546+ auto tydescpp = T_ptr ( T_ptr ( tydesc) ) ;
538547 auto pvoid = T_ptr ( T_i8 ( ) ) ;
539548 auto glue_fn_ty =
540549 T_ptr ( T_fn ( ~[ T_ptr ( T_nil ( ) ) , taskptr_type, T_ptr ( T_nil ( ) ) , tydescpp,
541550 pvoid] , T_void ( ) ) ) ;
542551 auto cmp_glue_fn_ty =
543552 T_ptr ( T_fn ( ~[ T_ptr ( T_i1 ( ) ) , taskptr_type, T_ptr ( T_nil ( ) ) , tydescpp,
544553 pvoid, pvoid, T_i8 ( ) ] , T_void ( ) ) ) ;
545- auto tydesc =
546- T_struct ( ~[ tydescpp, // first_param
554+
555+ auto elems = ~[ tydescpp, // first_param
547556 T_int ( ) , // size
548557 T_int ( ) , // align
549558 glue_fn_ty, // copy_glue
@@ -553,11 +562,9 @@ fn T_tydesc(TypeRef taskptr_type) -> TypeRef {
553562 glue_fn_ty, // mark_glue
554563 glue_fn_ty, // obj_drop_glue
555564 glue_fn_ty, // is_stateful
556- cmp_glue_fn_ty] ) ; // cmp_glue
557-
558- llvm:: LLVMRefineType ( abs_tydesc, tydesc) ;
559- auto t = llvm:: LLVMResolveTypeHandle ( th. llth ) ;
560- ret t;
565+ cmp_glue_fn_ty] ;
566+ set_struct_body ( tydesc, elems) ;
567+ ret tydesc;
561568}
562569
563570fn T_array ( TypeRef t, uint n) -> TypeRef { ret llvm:: LLVMArrayType ( t, n) ; }
@@ -915,10 +922,6 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
915922 case ( ty:: ty_type) { llty = T_ptr ( cx. tydesc_type ) ; }
916923 }
917924 assert ( llty as int != 0 ) ;
918- if ( cx. sess . get_opts ( ) . save_temps ) {
919- llvm:: LLVMAddTypeName ( cx. llmod , str:: buf ( ty_to_short_str ( cx. tcx , t) ) ,
920- llty) ;
921- }
922925 cx. lltypes . insert ( t, llty) ;
923926 ret llty;
924927}
@@ -1096,6 +1099,11 @@ fn C_struct(&ValueRef[] elts) -> ValueRef {
10961099 False ) ;
10971100}
10981101
1102+ fn C_named_struct ( TypeRef T , & ValueRef [ ] elts) -> ValueRef {
1103+ ret llvm:: LLVMConstNamedStruct ( T , std:: ivec:: to_ptr ( elts ) ,
1104+ std:: ivec:: len ( elts ) ) ;
1105+ }
1106+
10991107fn C_array ( TypeRef ty, & ValueRef [ ] elts) -> ValueRef {
11001108 ret llvm:: LLVMConstArray ( ty , std:: ivec:: to_ptr ( elts ) ,
11011109 std:: ivec:: len ( elts ) ) ;
@@ -1971,7 +1979,8 @@ fn emit_tydescs(&@crate_ctxt ccx) {
19711979 case ( some( ?v) ) { ccx. stats. n_real_glues += 1 u; v }
19721980 } ;
19731981 auto tydesc =
1974- C_struct ( ~[ C_null ( T_ptr ( T_ptr ( ccx. tydesc_type) ) ) , ti. size,
1982+ C_named_struct ( ccx. tydesc_type,
1983+ ~[ C_null ( T_ptr ( T_ptr ( ccx. tydesc_type) ) ) , ti. size,
19751984 ti. align, copy_glue, // copy_glue
19761985 drop_glue, // drop_glue
19771986 free_glue, // free_glue
@@ -9074,11 +9083,6 @@ fn i2p(ValueRef v, TypeRef t) -> ValueRef {
90749083 ret llvm:: LLVMConstIntToPtr ( v, t) ;
90759084}
90769085
9077- fn create_typedefs( & @crate_ctxt cx) {
9078- llvm:: LLVMAddTypeName ( cx. llmod, str :: buf( "task") , cx. task_type) ;
9079- llvm:: LLVMAddTypeName ( cx. llmod, str :: buf( "tydesc") , cx. tydesc_type) ;
9080- }
9081-
90829086fn declare_intrinsics( ModuleRef llmod) -> hashmap[ str , ValueRef ] {
90839087 let TypeRef [ ] T_memmove32_args =
90849088 ~[ T_ptr ( T_i8 ( ) ) , T_ptr ( T_i8 ( ) ) , T_i32 ( ) , T_i32 ( ) , T_i1 ( ) ] ;
@@ -9298,7 +9302,6 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
92989302 tydesc_type=tydesc_type,
92999303 task_type=task_type) ;
93009304 auto cx = new_local_ctxt( ccx) ;
9301- create_typedefs( ccx) ;
93029305 collect_items( ccx, crate ) ;
93039306 collect_tag_ctors( ccx, crate ) ;
93049307 trans_constants( ccx, crate ) ;
0 commit comments