librustc: Stop generating first-class aggregates in visit glue, since they kick us off fast isel. Closes #4352. rs=minor-perf-improvement
This commit is contained in:
parent
9abcacc0f3
commit
7b245d46ed
@ -1094,6 +1094,8 @@ fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef {
|
||||
return g;
|
||||
}
|
||||
|
||||
// NB: Do not use `do_spill_noroot` to make this into a constant string, or
|
||||
// you will be kicked off fast isel. See issue #4352 for an example of this.
|
||||
fn C_estr_slice(cx: @crate_ctxt, s: ~str) -> ValueRef {
|
||||
let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s), T_ptr(T_i8()));
|
||||
C_struct(~[cs, C_uint(cx, str::len(s) + 1u /* +1 for null */)])
|
||||
|
@ -46,8 +46,17 @@ impl reflector {
|
||||
}
|
||||
|
||||
fn c_slice(s: ~str) -> ValueRef {
|
||||
let ss = C_estr_slice(self.bcx.ccx(), s);
|
||||
do_spill_noroot(self.bcx, ss)
|
||||
// We're careful to not use first class aggregates here because that
|
||||
// will kick us off fast isel. (Issue #4352.)
|
||||
let bcx = self.bcx;
|
||||
let str_vstore = ty::vstore_slice(ty::re_static);
|
||||
let str_ty = ty::mk_estr(bcx.tcx(), str_vstore);
|
||||
let scratch = scratch_datum(bcx, str_ty, false);
|
||||
let c_str = PointerCast(bcx, C_cstr(bcx.ccx(), s), T_ptr(T_i8()));
|
||||
Store(bcx, c_str, GEPi(bcx, scratch.val, [ 0, 0 ]));
|
||||
let len = C_uint(bcx.ccx(), s.len() + 1);
|
||||
Store(bcx, len, GEPi(bcx, scratch.val, [ 0, 1 ]));
|
||||
scratch.val
|
||||
}
|
||||
|
||||
fn c_size_and_align(t: ty::t) -> ~[ValueRef] {
|
||||
|
Loading…
Reference in New Issue
Block a user