File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: a172f5aef5f7d26fba9dbf94a1ade60d6d62ba74
2
+ refs/heads/master: 86309ed3ea896473641c9cdeadf16b02931b8ac8
Original file line number Diff line number Diff line change @@ -4609,12 +4609,26 @@ fn trans_constant(&@crate_ctxt cx, @ast.item it) -> @crate_ctxt {
4609
4609
auto n_variants = _vec. len [ ast. variant ] ( variants) ;
4610
4610
while ( i < n_variants) {
4611
4611
auto variant = variants. ( i) ;
4612
+
4613
+ auto discrim_val = C_int ( i as int ) ;
4614
+
4615
+ // FIXME: better name.
4616
+ auto discrim_gvar = llvm. LLVMAddGlobal ( cx. llmod , T_int ( ) ,
4617
+ _str. buf ( "tag_discrim" ) ) ;
4618
+
4619
+ // FIXME: Eventually we do want to export these, but we need
4620
+ // to figure out what name they get first!
4621
+ llvm. LLVMSetInitializer ( discrim_gvar, discrim_val) ;
4622
+ llvm. LLVMSetGlobalConstant ( discrim_gvar, True ) ;
4623
+ llvm. LLVMSetLinkage ( discrim_gvar, lib. llvm . LLVMPrivateLinkage
4624
+ as llvm . Linkage ) ;
4625
+
4612
4626
if ( _vec. len [ ast. variant_arg ] ( variant. args ) == 0 u) {
4613
4627
// Nullary tags become constants. (N-ary tags are treated
4614
4628
// as functions and generated later.)
4615
4629
4616
4630
auto union_val = C_zero_byte_arr ( info. size as uint ) ;
4617
- auto val = C_struct ( vec ( C_int ( i as int ) , union_val) ) ;
4631
+ auto val = C_struct ( vec ( discrim_val , union_val) ) ;
4618
4632
4619
4633
// FIXME: better name
4620
4634
auto gvar = llvm. LLVMAddGlobal ( cx. llmod , val_ty ( val) ,
You can’t perform that action at this time.
0 commit comments