Skip to content

Commit 4219192

Browse files
committed
---
yaml --- r: 6811 b: refs/heads/master c: 544bcfe h: refs/heads/master i: 6809: 39eab89 6807: 251558a v: v3
1 parent b5658b7 commit 4219192

File tree

6 files changed

+88
-48
lines changed

6 files changed

+88
-48
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: fa6d871e11bc4f765062cff41fbce5d977e24ea5
2+
refs/heads/master: 544bcfece238d47ca600fd09cef1f282a7a9bb26

trunk/src/comp/middle/debuginfo.rs

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,34 +306,65 @@ fn get_local_var_metadata(bcx: @block_ctxt, local: @ast::local)
306306
ret mdval;
307307
}
308308

309-
fn update_source_pos(cx: @block_ctxt, s: codemap::span) {
309+
fn update_source_pos(cx: @block_ctxt, s: codemap::span) -> @debug_source_pos {
310+
let dsp = @debug_source_pos(cx);
310311
if !bcx_ccx(cx).sess.get_opts().debuginfo {
311-
ret;
312+
ret dsp;
313+
}
314+
let cm = bcx_ccx(cx).sess.get_codemap();
315+
if vec::is_empty(cx.source_pos.pos) {
316+
cx.source_pos.usable = true;
317+
}
318+
cx.source_pos.pos += [codemap::lookup_char_pos(cm, s.lo)]; //XXX maybe hi
319+
ret dsp;
320+
}
321+
322+
fn invalidate_source_pos(cx: @block_ctxt) -> @invalidated_source_pos {
323+
let isp = @invalidated_source_pos(cx);
324+
if !bcx_ccx(cx).sess.get_opts().debuginfo {
325+
ret isp;
312326
}
313-
cx.source_pos = option::some(
314-
codemap::lookup_char_pos(bcx_ccx(cx).sess.get_codemap(),
315-
s.lo)); //XXX maybe hi
327+
cx.source_pos.usable = false;
328+
ret isp;
329+
}
316330

331+
fn revalidate_source_pos(cx: @block_ctxt) {
332+
if !bcx_ccx(cx).sess.get_opts().debuginfo {
333+
ret;
334+
}
335+
cx.source_pos.usable = true;
317336
}
318337

319338
fn reset_source_pos(cx: @block_ctxt) {
320-
cx.source_pos = option::none;
339+
if !bcx_ccx(cx).sess.get_opts().debuginfo {
340+
ret;
341+
}
342+
vec::pop(cx.source_pos.pos);
343+
}
344+
345+
resource debug_source_pos(bcx: @block_ctxt) {
346+
reset_source_pos(bcx);
347+
}
348+
resource invalidated_source_pos(bcx: @block_ctxt) {
349+
revalidate_source_pos(bcx);
321350
}
322351

323352
fn add_line_info(cx: @block_ctxt, llinstr: ValueRef) {
324353
if !bcx_ccx(cx).sess.get_opts().debuginfo ||
325-
option::is_none(cx.source_pos) {
354+
!cx.source_pos.usable ||
355+
vec::is_empty(cx.source_pos.pos) {
326356
ret;
327357
}
328-
let loc = option::get(cx.source_pos);
358+
let loc = option::get(vec::last(cx.source_pos.pos));
329359
let blockmd = get_block_metadata(cx);
330-
let kind_id = llvm::LLVMGetMDKindID(as_buf("dbg"), str::byte_len("dbg"));
360+
let kind_id = llvm::LLVMGetMDKindID(as_buf("dbg"),
361+
str::byte_len("dbg"));
331362
let scopedata = [lli32(loc.line as int),
332363
lli32(loc.col as int),
333364
blockmd.node,
334365
llnull()];
335366
let dbgscope = llmdnode(scopedata);
336-
llvm::LLVMSetMetadata(llinstr, kind_id, dbgscope);
367+
llvm::LLVMSetMetadata(llinstr, kind_id, dbgscope);
337368
}
338369

339370
fn get_function_metadata(cx: @crate_ctxt, item: @ast::item,

trunk/src/comp/middle/trans.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,7 +3519,7 @@ fn trans_temp_expr(bcx: @block_ctxt, e: @ast::expr) -> result {
35193519
// - exprs with non-immediate type never get dest=by_val
35203520
fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
35213521
let tcx = bcx_tcx(bcx);
3522-
debuginfo::update_source_pos(bcx, e.span);
3522+
let _s = debuginfo::update_source_pos(bcx, e.span);
35233523

35243524
if expr_is_lval(bcx, e) {
35253525
ret lval_to_dps(bcx, e, dest);
@@ -4014,7 +4014,7 @@ fn trans_stmt(cx: @block_ctxt, s: ast::stmt) -> @block_ctxt {
40144014
}
40154015

40164016
let bcx = cx;
4017-
debuginfo::update_source_pos(cx, s.span);
4017+
let _s = debuginfo::update_source_pos(cx, s.span);
40184018

40194019
alt s.node {
40204020
ast::stmt_expr(e, _) { bcx = trans_expr(cx, e, ignore); }
@@ -4038,7 +4038,7 @@ fn trans_stmt(cx: @block_ctxt, s: ast::stmt) -> @block_ctxt {
40384038
_ { bcx_ccx(cx).sess.unimpl("stmt variant"); }
40394039
}
40404040

4041-
debuginfo::reset_source_pos(cx);
4041+
//debuginfo::reset_source_pos(cx);
40424042
ret bcx;
40434043
}
40444044

@@ -4063,7 +4063,8 @@ fn new_block_ctxt(cx: @fn_ctxt, parent: block_parent, kind: block_kind,
40634063
mutable lpad: option::none,
40644064
sp: cx.sp,
40654065
fcx: cx,
4066-
mutable source_pos: option::none};
4066+
source_pos: {mutable usable: false,
4067+
mutable pos: []}};
40674068
alt parent {
40684069
parent_some(cx) {
40694070
if cx.unreachable { Unreachable(bcx); }
@@ -4108,7 +4109,8 @@ fn new_raw_block_ctxt(fcx: @fn_ctxt, llbb: BasicBlockRef) -> @block_ctxt {
41084109
mutable lpad: option::none,
41094110
sp: fcx.sp,
41104111
fcx: fcx,
4111-
mutable source_pos: option::none};
4112+
source_pos: {mutable usable: false,
4113+
mutable pos: []}};
41124114
}
41134115

41144116

@@ -4176,7 +4178,8 @@ fn llstaticallocas_block_ctxt(fcx: @fn_ctxt) -> @block_ctxt {
41764178
mutable lpad: option::none,
41774179
sp: fcx.sp,
41784180
fcx: fcx,
4179-
mutable source_pos: option::none};
4181+
source_pos: {mutable usable: false,
4182+
mutable pos: []}};
41804183
}
41814184

41824185
fn llderivedtydescs_block_ctxt(fcx: @fn_ctxt) -> @block_ctxt {
@@ -4190,7 +4193,8 @@ fn llderivedtydescs_block_ctxt(fcx: @fn_ctxt) -> @block_ctxt {
41904193
mutable lpad: option::none,
41914194
sp: fcx.sp,
41924195
fcx: fcx,
4193-
mutable source_pos: option::none};
4196+
source_pos: {mutable usable: false,
4197+
mutable pos: []}};
41944198
}
41954199

41964200

@@ -4263,20 +4267,22 @@ fn trans_block(bcx: @block_ctxt, b: ast::blk) -> @block_ctxt {
42634267
fn trans_block_dps(bcx: @block_ctxt, b: ast::blk, dest: dest)
42644268
-> @block_ctxt {
42654269
let bcx = bcx;
4266-
debuginfo::update_source_pos(bcx, b.span);
42674270
block_locals(b) {|local| bcx = alloc_local(bcx, local); };
42684271
for s: @ast::stmt in b.node.stmts {
4272+
let _s = debuginfo::update_source_pos(bcx, b.span);
42694273
bcx = trans_stmt(bcx, *s);
4274+
//debuginfo::reset_source_pos(bcx);
42704275
}
42714276
alt b.node.expr {
42724277
some(e) {
42734278
let bt = ty::type_is_bot(bcx_tcx(bcx), ty::expr_ty(bcx_tcx(bcx), e));
4279+
let _s = debuginfo::update_source_pos(bcx, e.span);
42744280
bcx = trans_expr(bcx, e, bt ? ignore : dest);
4281+
//debuginfo::reset_source_pos(bcx);
42754282
}
42764283
_ { assert dest == ignore || bcx.unreachable; }
42774284
}
42784285
let rv = trans_block_cleanups(bcx, find_scope_cx(bcx));
4279-
debuginfo::reset_source_pos(bcx);
42804286
ret rv;
42814287
}
42824288

trunk/src/comp/middle/trans_build.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ fn GEP(cx: @block_ctxt, Pointer: ValueRef, Indices: [ValueRef]) -> ValueRef {
408408
unsafe {
409409
let instr = llvm::LLVMBuildGEP(B(cx), Pointer, vec::to_ptr(Indices),
410410
vec::len(Indices), noname());
411-
debuginfo::add_line_info(cx, instr);
411+
//debuginfo::add_line_info(cx, instr);
412412
ret instr;
413413
}
414414
}
@@ -425,18 +425,18 @@ fn InBoundsGEP(cx: @block_ctxt, Pointer: ValueRef, Indices: [ValueRef]) ->
425425
ValueRef {
426426
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); }
427427
unsafe {
428-
let v = llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
429-
vec::to_ptr(Indices),
430-
vec::len(Indices), noname());
431-
debuginfo::add_line_info(cx, v);
432-
ret v;
428+
let instr = llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
429+
vec::to_ptr(Indices),
430+
vec::len(Indices), noname());
431+
//debuginfo::add_line_info(cx, instr);
432+
ret instr;
433433
}
434434
}
435435

436436
fn StructGEP(cx: @block_ctxt, Pointer: ValueRef, Idx: uint) -> ValueRef {
437437
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); }
438438
let instr = llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx, noname());
439-
debuginfo::add_line_info(cx, instr);
439+
//debuginfo::add_line_info(cx, instr);
440440
ret instr;
441441
}
442442

@@ -458,137 +458,137 @@ fn GlobalStringPtr(cx: @block_ctxt, _Str: sbuf) -> ValueRef {
458458
fn Trunc(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
459459
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
460460
let instr = llvm::LLVMBuildTrunc(B(cx), Val, DestTy, noname());
461-
debuginfo::add_line_info(cx, instr);
461+
//debuginfo::add_line_info(cx, instr);
462462
ret instr;
463463
}
464464

465465
fn ZExt(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
466466
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
467467
let instr = llvm::LLVMBuildZExt(B(cx), Val, DestTy, noname());
468-
debuginfo::add_line_info(cx, instr);
468+
//debuginfo::add_line_info(cx, instr);
469469
ret instr;
470470
}
471471

472472
fn SExt(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
473473
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
474474
let instr = llvm::LLVMBuildSExt(B(cx), Val, DestTy, noname());
475-
debuginfo::add_line_info(cx, instr);
475+
//debuginfo::add_line_info(cx, instr);
476476
ret instr;
477477
}
478478

479479
fn FPToUI(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
480480
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
481481
let instr = llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, noname());
482-
debuginfo::add_line_info(cx, instr);
482+
//debuginfo::add_line_info(cx, instr);
483483
ret instr;
484484
}
485485

486486
fn FPToSI(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
487487
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
488488
let instr = llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, noname());
489-
debuginfo::add_line_info(cx, instr);
489+
//debuginfo::add_line_info(cx, instr);
490490
ret instr;
491491
}
492492

493493
fn UIToFP(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
494494
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
495495
let instr = llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, noname());
496-
debuginfo::add_line_info(cx, instr);
496+
//debuginfo::add_line_info(cx, instr);
497497
ret instr;
498498
}
499499

500500
fn SIToFP(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
501501
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
502502
let instr = llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, noname());
503-
debuginfo::add_line_info(cx, instr);
503+
//debuginfo::add_line_info(cx, instr);
504504
ret instr;
505505
}
506506

507507
fn FPTrunc(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
508508
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
509509
let instr = llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, noname());
510-
debuginfo::add_line_info(cx, instr);
510+
//debuginfo::add_line_info(cx, instr);
511511
ret instr;
512512
}
513513

514514
fn FPExt(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
515515
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
516516
let instr = llvm::LLVMBuildFPExt(B(cx), Val, DestTy, noname());
517-
debuginfo::add_line_info(cx, instr);
517+
//debuginfo::add_line_info(cx, instr);
518518
ret instr;
519519
}
520520

521521
fn PtrToInt(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
522522
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
523523
let instr = llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, noname());
524-
debuginfo::add_line_info(cx, instr);
524+
//debuginfo::add_line_info(cx, instr);
525525
ret instr;
526526
}
527527

528528
fn IntToPtr(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
529529
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
530530
let instr = llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, noname());
531-
debuginfo::add_line_info(cx, instr);
531+
//debuginfo::add_line_info(cx, instr);
532532
ret instr;
533533
}
534534

535535
fn BitCast(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
536536
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
537537
let instr = llvm::LLVMBuildBitCast(B(cx), Val, DestTy, noname());
538-
debuginfo::add_line_info(cx, instr);
538+
//debuginfo::add_line_info(cx, instr);
539539
ret instr;
540540
}
541541

542542
fn ZExtOrBitCast(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) ->
543543
ValueRef {
544544
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
545545
let instr = llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, noname());
546-
debuginfo::add_line_info(cx, instr);
546+
//debuginfo::add_line_info(cx, instr);
547547
ret instr;
548548
}
549549

550550
fn SExtOrBitCast(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) ->
551551
ValueRef {
552552
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
553553
let instr = llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, noname());
554-
debuginfo::add_line_info(cx, instr);
554+
//debuginfo::add_line_info(cx, instr);
555555
ret instr;
556556
}
557557

558558
fn TruncOrBitCast(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) ->
559559
ValueRef {
560560
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
561561
let instr = llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, noname());
562-
debuginfo::add_line_info(cx, instr);
562+
//debuginfo::add_line_info(cx, instr);
563563
ret instr;
564564
}
565565

566566
fn Cast(cx: @block_ctxt, Op: Opcode, Val: ValueRef, DestTy: TypeRef,
567567
_Name: sbuf) -> ValueRef {
568568
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
569569
let instr = llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, noname());
570-
debuginfo::add_line_info(cx, instr);
570+
//debuginfo::add_line_info(cx, instr);
571571
ret instr;
572572
}
573573

574574
fn PointerCast(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
575575
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
576576
let instr = llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, noname());
577-
debuginfo::add_line_info(cx, instr);
577+
//debuginfo::add_line_info(cx, instr);
578578
ret instr;
579579
}
580580

581581
fn IntCast(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
582582
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
583583
let instr = llvm::LLVMBuildIntCast(B(cx), Val, DestTy, noname());
584-
debuginfo::add_line_info(cx, instr);
584+
//debuginfo::add_line_info(cx, instr);
585585
ret instr;
586586
}
587587

588588
fn FPCast(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
589589
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
590590
let instr = llvm::LLVMBuildFPCast(B(cx), Val, DestTy, noname());
591-
debuginfo::add_line_info(cx, instr);
591+
//debuginfo::add_line_info(cx, instr);
592592
ret instr;
593593
}
594594

@@ -670,7 +670,7 @@ fn Call(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
670670
unsafe {
671671
let instr = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
672672
vec::len(Args), noname());
673-
debuginfo::add_line_info(cx, instr);
673+
//debuginfo::add_line_info(cx, instr);
674674
ret instr;
675675
}
676676
}

trunk/src/comp/middle/trans_common.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ type block_ctxt =
386386
mutable lpad: option::t<BasicBlockRef>,
387387
sp: span,
388388
fcx: @fn_ctxt,
389-
mutable source_pos: option::t<syntax::codemap::loc>};
389+
source_pos: {mutable usable: bool,
390+
mutable pos: [syntax::codemap::loc]}};
390391

391392
// FIXME: we should be able to use option::t<@block_parent> here but
392393
// the infinite-tag check in rustboot gets upset.

trunk/src/comp/middle/trans_vec.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fn pointer_add(bcx: @block_ctxt, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
2727
}
2828

2929
fn alloc_raw(bcx: @block_ctxt, fill: ValueRef, alloc: ValueRef) -> result {
30+
let _s = debuginfo::invalidate_source_pos(bcx);
3031
let ccx = bcx_ccx(bcx);
3132
let llvecty = ccx.opaque_vec_type;
3233
let vecsize = Add(bcx, alloc, llsize_of(ccx, llvecty));
@@ -45,6 +46,7 @@ type alloc_result =
4546
llunitty: TypeRef};
4647

4748
fn alloc(bcx: @block_ctxt, vec_ty: ty::t, elts: uint) -> alloc_result {
49+
let _s = debuginfo::invalidate_source_pos(bcx);
4850
let ccx = bcx_ccx(bcx);
4951
let unit_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
5052
let llunitty = type_of_or_i8(bcx, unit_ty);

0 commit comments

Comments
 (0)