Skip to content

Commit 50481f5

Browse files
committed
auto merge of #15784 : dotdash/rust/unreach, r=luqmana
`call_visit_glue` is only ever called from trans_intrinsic, and the block won't be unreachable there. Also, the comment doesn't make sense anymore. When the code was introduced in 38fee95 the function was also responsible for the cleanup glue, which is no longer the case. While we're at it, also fixed the debug message to output the right function name.
2 parents 320dbc1 + d368ffd commit 50481f5

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

src/librustc/middle/trans/glue.rs

+5-26
Original file line numberDiff line numberDiff line change
@@ -178,33 +178,12 @@ pub fn lazily_emit_visit_glue(ccx: &CrateContext, ti: &tydesc_info) -> ValueRef
178178
}
179179

180180
// See [Note-arg-mode]
181-
pub fn call_visit_glue(bcx: &Block, v: ValueRef, tydesc: ValueRef,
182-
static_ti: Option<&tydesc_info>) {
183-
let _icx = push_ctxt("call_tydesc_glue_full");
184-
let ccx = bcx.ccx();
185-
// NB: Don't short-circuit even if this block is unreachable because
186-
// GC-based cleanup needs to the see that the roots are live.
187-
if bcx.unreachable.get() && !ccx.sess().no_landing_pads() { return; }
188-
189-
let static_glue_fn = static_ti.map(|sti| lazily_emit_visit_glue(ccx, sti));
190-
191-
// When static type info is available, avoid casting to a generic pointer.
192-
let llrawptr = if static_glue_fn.is_none() {
193-
PointerCast(bcx, v, Type::i8p(ccx))
194-
} else {
195-
v
196-
};
181+
pub fn call_visit_glue(bcx: &Block, v: ValueRef, tydesc: ValueRef) {
182+
let _icx = push_ctxt("call_visit_glue");
197183

198-
let llfn = {
199-
match static_glue_fn {
200-
None => {
201-
// Select out the glue function to call from the tydesc
202-
let llfnptr = GEPi(bcx, tydesc, [0u, abi::tydesc_field_visit_glue]);
203-
Load(bcx, llfnptr)
204-
}
205-
Some(sgf) => sgf
206-
}
207-
};
184+
// Select the glue function to call from the tydesc
185+
let llfn = Load(bcx, GEPi(bcx, tydesc, [0u, abi::tydesc_field_visit_glue]));
186+
let llrawptr = PointerCast(bcx, v, Type::i8p(bcx.ccx()));
208187

209188
Call(bcx, llfn, [llrawptr], []);
210189
}

src/librustc/middle/trans/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pub fn trans_intrinsic_call<'a>(mut bcx: &'a Block<'a>, node: ast::NodeId,
296296
let td = *llargs.get(0);
297297
let visitor = *llargs.get(1);
298298
let td = PointerCast(bcx, td, ccx.tydesc_type().ptr_to());
299-
glue::call_visit_glue(bcx, visitor, td, None);
299+
glue::call_visit_glue(bcx, visitor, td);
300300
C_nil(ccx)
301301
}
302302
(_, "offset") => {

0 commit comments

Comments
 (0)