Skip to content

Commit d68c5cc

Browse files
committed
Use c_ulonglong now that it works in FFI, etc...
Annotate FIXMEs; remove obsolete FIXMEs; remove an unnecessary PointerCast.
1 parent dc77386 commit d68c5cc

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

src/rustc/lib/llvm.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,11 @@ native mod llvm {
491491
fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
492492
fn LLVMGetGC(Fn: ValueRef) -> *c_char;
493493
fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
494-
fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint, HighPA: c_uint);
495-
fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_uint;
496-
fn LLVMRemoveFunctionAttr(Fn: ValueRef, PA: c_uint, HighPA: c_uint);
494+
fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_ulonglong, HighPA:
495+
c_ulonglong);
496+
fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
497+
fn LLVMRemoveFunctionAttr(Fn: ValueRef, PA: c_ulonglong, HighPA:
498+
c_ulonglong);
497499

498500
/* Operations on parameters */
499501
fn LLVMCountParams(Fn: ValueRef) -> c_uint;

src/rustc/middle/trans/base.rs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// but many TypeRefs correspond to one ty::t; for instance, tup(int, int,
1414
// int) and rec(x=int, y=int, z=int) will have the same TypeRef.
1515

16-
import libc::c_uint;
16+
import libc::{c_uint, c_ulonglong};
1717
import std::{map, time, list};
1818
import std::map::hashmap;
1919
import std::map::{int_hash, str_hash};
@@ -450,25 +450,25 @@ fn get_static_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
450450
}
451451

452452
fn set_no_inline(f: ValueRef) {
453-
llvm::LLVMAddFunctionAttr(f, lib::llvm::NoInlineAttribute as c_uint,
454-
0u as c_uint);
453+
llvm::LLVMAddFunctionAttr(f, lib::llvm::NoInlineAttribute as c_ulonglong,
454+
0u as c_ulonglong);
455455
}
456456

457457
fn set_no_unwind(f: ValueRef) {
458-
llvm::LLVMAddFunctionAttr(f, lib::llvm::NoUnwindAttribute as c_uint,
459-
0u as c_uint);
458+
llvm::LLVMAddFunctionAttr(f, lib::llvm::NoUnwindAttribute as c_ulonglong,
459+
0u as c_ulonglong);
460460
}
461461

462462
// Tell LLVM to emit the information necessary to unwind the stack for the
463463
// function f.
464464
fn set_uwtable(f: ValueRef) {
465-
llvm::LLVMAddFunctionAttr(f, lib::llvm::UWTableAttribute as c_uint,
466-
0u as c_uint);
465+
llvm::LLVMAddFunctionAttr(f, lib::llvm::UWTableAttribute as c_ulonglong,
466+
0u as c_ulonglong);
467467
}
468468

469469
fn set_inline_hint(f: ValueRef) {
470-
llvm::LLVMAddFunctionAttr(f, lib::llvm::InlineHintAttribute as c_uint,
471-
0u as c_uint);
470+
llvm::LLVMAddFunctionAttr(f, lib::llvm::InlineHintAttribute
471+
as c_ulonglong, 0u as c_ulonglong);
472472
}
473473

474474
fn set_inline_hint_if_appr(attrs: [ast::attribute],
@@ -481,13 +481,12 @@ fn set_inline_hint_if_appr(attrs: [ast::attribute],
481481
}
482482

483483
fn set_always_inline(f: ValueRef) {
484-
llvm::LLVMAddFunctionAttr(f, lib::llvm::AlwaysInlineAttribute as c_uint,
485-
0u as c_uint);
484+
llvm::LLVMAddFunctionAttr(f, lib::llvm::AlwaysInlineAttribute
485+
as c_ulonglong, 0u as c_ulonglong);
486486
}
487487

488488
fn set_custom_stack_growth_fn(f: ValueRef) {
489-
// FIXME: Remove this hack to work around the lack of u64 in the FFI.
490-
llvm::LLVMAddFunctionAttr(f, 0u as c_uint, 1u as c_uint);
489+
llvm::LLVMAddFunctionAttr(f, 0u as c_ulonglong, 1u as c_ulonglong);
491490
}
492491

493492
fn set_glue_inlining(f: ValueRef, t: ty::t) {
@@ -1343,7 +1342,7 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef,
13431342
// FIXME: Provide LLVM with better alignment information when the
13441343
// alignment is statically known (it must be nothing more than a constant
13451344
// int, or LLVM complains -- not even a constant element of a tydesc
1346-
// works).
1345+
// works). (Related to #1645, I think?)
13471346
let _icx = cx.insn_ctxt("call_memmove");
13481347
let ccx = cx.ccx();
13491348
let key = alt ccx.sess.targ_cfg.arch {
@@ -1428,7 +1427,7 @@ fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef,
14281427
// Since it needs to zero out the source, src also needs to be an lval.
14291428
// FIXME: We always zero out the source. Ideally we would detect the
14301429
// case where a variable is always deinitialized by block exit and thus
1431-
// doesn't need to be dropped.
1430+
// doesn't need to be dropped. (Issue #839)
14321431
fn move_val(cx: block, action: copy_action, dst: ValueRef,
14331432
src: lval_result, t: ty::t) -> block {
14341433
let _icx = cx.insn_ctxt("move_val");
@@ -1623,7 +1622,7 @@ fn cast_shift_rhs(op: ast::binop,
16231622
trunc(rhs, lhs_llty)
16241623
} else if lhs_sz > rhs_sz {
16251624
// FIXME: If shifting by negative values becomes not undefined
1626-
// then this is wrong.
1625+
// then this is wrong. (See discussion at #1570)
16271626
zext(rhs, lhs_llty)
16281627
} else {
16291628
rhs
@@ -1713,6 +1712,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop,
17131712
expr_ty(bcx, ex),
17141713
{|bcx|
17151714
// FIXME provide the already-computed address, not the expr
1715+
// #2528
17161716
impl::trans_method_callee(bcx, callee_id, dst, origin)
17171717
},
17181718
arg_exprs([src]), save_in(lhs_res.val));
@@ -2006,7 +2006,7 @@ fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t)
20062006
}
20072007

20082008
fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> {
2009-
// FIXME[mono] could do this recursively. is that worthwhile?
2009+
// FIXME[mono] could do this recursively. is that worthwhile? (#2529)
20102010
alt ty::get(ty).struct {
20112011
ty::ty_box(mt) { some(ty::mk_opaque_box(tcx)) }
20122012
ty::ty_fn(fty) { some(ty::mk_fn(tcx, {purity: ast::impure_fn,
@@ -2379,7 +2379,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id,
23792379
ccx, node_id_type(bcx, id))));
23802380
}
23812381

2382-
// FIXME: Need to support external crust functions
2382+
// FIXME: Need to support external crust functions (#1840)
23832383
if fn_id.crate == ast::local_crate {
23842384
alt bcx.tcx().def_map.find(id) {
23852385
some(ast::def_fn(_, ast::crust_fn)) {
@@ -2480,10 +2480,7 @@ fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee {
24802480
} else {
24812481
// Nullary variant.
24822482
let enum_ty = node_id_type(cx, id);
2483-
let llenumblob = alloc_ty(cx, enum_ty);
2484-
// FIXME: This pointer cast probably isn't necessary
2485-
let llenumty = type_of(ccx, enum_ty);
2486-
let llenumptr = PointerCast(cx, llenumblob, T_ptr(llenumty));
2483+
let llenumptr = alloc_ty(cx, enum_ty);
24872484
let lldiscrimptr = GEPi(cx, llenumptr, [0u, 0u]);
24882485
let lldiscrim_gv = lookup_discriminant(ccx, vid);
24892486
let lldiscrim = Load(cx, lldiscrim_gv);
@@ -3666,7 +3663,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
36663663
expr_ty(bcx, src), is_last_use);
36673664
}
36683665
ast::expr_move(dst, src) {
3669-
// FIXME: calculate copy init-ness in typestate.
3666+
// FIXME: calculate copy init-ness in typestate. (#839)
36703667
assert dest == ignore;
36713668
let src_r = trans_temp_lval(bcx, src);
36723669
let {bcx, val: addr, kind} = trans_lval(src_r.bcx, dst);
@@ -4650,7 +4647,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
46504647

46514648
// FIXME: this should do some structural hash-consing to avoid
46524649
// duplicate constants. I think. Maybe LLVM has a magical mode
4653-
// that does so later on?
4650+
// that does so later on? (#2530)
46544651
fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
46554652
let _icx = cx.insn_ctxt("trans_const_expr");
46564653
alt e.node {
@@ -4754,7 +4751,7 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
47544751
}, _) {
47554752
// FIXME: Instead of recursing here to regenerate the values
47564753
// for other constants, we should just look up the
4757-
// already-defined value
4754+
// already-defined value (#2530)
47584755
trans_const_expr(cx, subexpr)
47594756
}
47604757
_ {
@@ -4800,7 +4797,6 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
48004797
// Make the fn context
48014798
let fcx = new_fn_ctxt_w_id(ccx, path, llctor_decl, ctor_id,
48024799
some(psubsts), some(sp));
4803-
// FIXME: need to substitute into the fn arg types too?
48044800
create_llargs_for_fn_args(fcx, no_self, decl.inputs);
48054801
let mut bcx_top = top_scope_block(fcx, body.info());
48064802
let lltop = bcx_top.llbb;
@@ -4953,8 +4949,6 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
49534949
ast::item_class(tps, _ifaces, items, ctor, m_dtor, _) {
49544950
if tps.len() == 0u {
49554951
let psubsts = {tys: ty::ty_params_to_tys(ccx.tcx, tps),
4956-
// FIXME: vtables have to get filled in depending
4957-
// on ifaces
49584952
vtables: none,
49594953
bounds: @[]};
49604954
trans_class_ctor(ccx, *path, ctor.node.dec, ctor.node.body,

0 commit comments

Comments
 (0)