Skip to content

Commit 490da35

Browse files
committed
Use gvars for vtbls rather than returning const immediates.
1 parent 6a8518c commit 490da35

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/comp/middle/trans.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,13 @@ impure fn trans_vtbl(@crate_ctxt cx, &ast._obj ob) -> ValueRef {
23552355
trans_fn(cx, m.node.meth, m.node.id, m.node.ann);
23562356
methods += llfn;
23572357
}
2358-
ret C_struct(methods);
2358+
auto vtbl = C_struct(methods);
2359+
auto gvar = llvm.LLVMAddGlobal(cx.llmod,
2360+
val_ty(vtbl),
2361+
_str.buf("_rust_vtbl" + "." + cx.path));
2362+
llvm.LLVMSetInitializer(gvar, vtbl);
2363+
llvm.LLVMSetGlobalConstant(gvar, True);
2364+
ret gvar;
23592365
}
23602366

23612367
impure fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,

0 commit comments

Comments
 (0)