Skip to content

Commit 4fadc9c

Browse files
committed
---
yaml --- r: 1710 b: refs/heads/master c: 78bcfe2 h: refs/heads/master v: v3
1 parent ebf7899 commit 4fadc9c

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 37cc67fbfe9a7ebb7795f05713f1c08513ea19ba
2+
refs/heads/master: 78bcfe28f2d01cd19087b0a29871742a729e4e49

trunk/src/comp/middle/trans.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5277,19 +5277,12 @@ fn trans_const(@crate_ctxt cx, @ast.expr e,
52775277
&ast.def_id cid, &ast.ann ann) {
52785278
auto t = node_ann_type(cx, ann);
52795279
auto v = trans_const_expr(cx, e);
5280-
if (ty.type_is_scalar(t)) {
5281-
// The scalars come back as 1st class LLVM vals
5282-
// which we have to stick into global constants.
5283-
auto g = llvm.LLVMAddGlobal(cx.llmod, val_ty(v),
5284-
_str.buf(cx.names.next(cx.path)));
5285-
llvm.LLVMSetInitializer(g, v);
5286-
llvm.LLVMSetGlobalConstant(g, True);
5287-
llvm.LLVMSetLinkage(g, lib.llvm.LLVMPrivateLinkage
5288-
as llvm.Linkage);
5289-
cx.consts.insert(cid, g);
5290-
} else {
5291-
cx.consts.insert(cid, v);
5292-
}
5280+
5281+
// The scalars come back as 1st class LLVM vals
5282+
// which we have to stick into global constants.
5283+
auto g = cx.consts.get(cid);
5284+
llvm.LLVMSetInitializer(g, v);
5285+
llvm.LLVMSetGlobalConstant(g, True);
52935286
}
52945287

52955288
fn trans_item(@crate_ctxt cx, &ast.item item) {
@@ -5488,8 +5481,14 @@ fn collect_native_item(&@crate_ctxt cx, @ast.native_item i) -> @crate_ctxt {
54885481
fn collect_item(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
54895482

54905483
alt (i.node) {
5491-
case (ast.item_const(?name, _, _, ?cid, _)) {
5484+
case (ast.item_const(?name, _, _, ?cid, ?ann)) {
5485+
auto typ = node_ann_type(cx, ann);
5486+
auto g = llvm.LLVMAddGlobal(cx.llmod, type_of(cx, typ),
5487+
_str.buf(cx.names.next(name)));
5488+
llvm.LLVMSetLinkage(g, lib.llvm.LLVMPrivateLinkage
5489+
as llvm.Linkage);
54925490
cx.items.insert(cid, i);
5491+
cx.consts.insert(cid, g);
54935492
}
54945493

54955494
case (ast.item_mod(?name, ?m, ?mid)) {

0 commit comments

Comments
 (0)