Skip to content

Commit a2154c1

Browse files
committed
---
yaml --- r: 96735 b: refs/heads/dist-snap c: 16f69b2 h: refs/heads/master i: 96733: 6267303 96731: 5d2c5b8 96727: 6e8dc6c 96719: 312a072 96703: 6319304 v: v3
1 parent 2dbd6f4 commit a2154c1

File tree

11 files changed

+75
-620
lines changed

11 files changed

+75
-620
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 35e5056b6a89d97d386416da44058cc736994ba9
9+
refs/heads/dist-snap: 16f69b225bdda1000610c5afda5d37dfd52ca306
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/trans/_match.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ use util::common::indenter;
220220
use util::ppaux::{Repr, vec_map_to_str};
221221

222222
use std::hashmap::HashMap;
223-
use std::ptr;
224223
use std::vec;
225224
use syntax::ast;
226225
use syntax::ast::Ident;
@@ -2047,10 +2046,7 @@ pub fn store_arg(mut bcx: @mut Block,
20472046
// Debug information (the llvm.dbg.declare intrinsic to be precise) always expects to get an
20482047
// alloca, which only is the case on the general path, so lets disable the optimized path when
20492048
// debug info is enabled.
2050-
let arg_is_alloca = unsafe { llvm::LLVMIsAAllocaInst(llval) != ptr::null() };
2051-
2052-
let fast_path = (arg_is_alloca || !bcx.ccx().sess.opts.extra_debuginfo)
2053-
&& simple_identifier(pat).is_some();
2049+
let fast_path = !bcx.ccx().sess.opts.extra_debuginfo && simple_identifier(pat).is_some();
20542050

20552051
if fast_path {
20562052
// Optimized path for `x: T` case. This just adopts

branches/dist-snap/src/librustc/middle/trans/base.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,8 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
875875
}
876876
}
877877
878-
pub fn invoke(bcx: @mut Block,
879-
llfn: ValueRef,
880-
llargs: ~[ValueRef],
881-
attributes: &[(uint, lib::llvm::Attribute)],
882-
call_info: Option<NodeInfo>)
878+
pub fn invoke(bcx: @mut Block, llfn: ValueRef, llargs: ~[ValueRef],
879+
attributes: &[(uint, lib::llvm::Attribute)])
883880
-> (ValueRef, @mut Block) {
884881
let _icx = push_ctxt("invoke_");
885882
if bcx.unreachable {
@@ -902,18 +899,11 @@ pub fn invoke(bcx: @mut Block,
902899
}
903900
}
904901
let normal_bcx = sub_block(bcx, "normal return");
905-
let landing_pad = get_landing_pad(bcx);
906-
907-
match call_info {
908-
Some(info) => debuginfo::set_source_location(bcx.fcx, info.id, info.span),
909-
None => debuginfo::clear_source_location(bcx.fcx)
910-
};
911-
912902
let llresult = Invoke(bcx,
913903
llfn,
914904
llargs,
915905
normal_bcx.llbb,
916-
landing_pad,
906+
get_landing_pad(bcx),
917907
attributes);
918908
return (llresult, normal_bcx);
919909
} else {
@@ -923,12 +913,6 @@ pub fn invoke(bcx: @mut Block,
923913
debug!("arg: {}", llarg);
924914
}
925915
}
926-
927-
match call_info {
928-
Some(info) => debuginfo::set_source_location(bcx.fcx, info.id, info.span),
929-
None => debuginfo::clear_source_location(bcx.fcx)
930-
};
931-
932916
let llresult = Call(bcx, llfn, llargs, attributes);
933917
return (llresult, bcx);
934918
}
@@ -1567,7 +1551,6 @@ pub fn alloca_maybe_zeroed(cx: @mut Block, ty: Type, name: &str, zero: bool) ->
15671551
return llvm::LLVMGetUndef(ty.ptr_to().to_ref());
15681552
}
15691553
}
1570-
debuginfo::clear_source_location(cx.fcx);
15711554
let p = Alloca(cx, ty, name);
15721555
if zero {
15731556
let b = cx.fcx.ccx.builder();
@@ -1584,7 +1567,6 @@ pub fn arrayalloca(cx: @mut Block, ty: Type, v: ValueRef) -> ValueRef {
15841567
return llvm::LLVMGetUndef(ty.to_ref());
15851568
}
15861569
}
1587-
debuginfo::clear_source_location(cx.fcx);
15881570
return ArrayAlloca(cx, ty, v);
15891571
}
15901572

@@ -1828,7 +1810,6 @@ pub fn finish_fn(fcx: @mut FunctionContext, last_bcx: @mut Block) {
18281810
None => last_bcx
18291811
};
18301812
build_return_block(fcx, ret_cx);
1831-
debuginfo::clear_source_location(fcx);
18321813
fcx.cleanup();
18331814
}
18341815

branches/dist-snap/src/librustc/middle/trans/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ pub fn trans_call_inner(in_cx: @mut Block,
697697
}
698698

699699
// Invoke the actual rust fn and update bcx/llresult.
700-
let (llret, b) = base::invoke(bcx, llfn, llargs, attrs, call_info);
700+
let (llret, b) = base::invoke(bcx, llfn, llargs, attrs);
701701
bcx = b;
702702
llresult = llret;
703703

branches/dist-snap/src/librustc/middle/trans/debuginfo.rs

Lines changed: 19 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -85,43 +85,6 @@ continuation, storing all state needed to continue traversal at the type members
8585
been registered with the cache. (This implementation approach might be a tad over-engineered and
8686
may change in the future)
8787
88-
89-
## Source Locations and Line Information
90-
In addition to data type descriptions the debugging information must also allow to map machine code
91-
locations back to source code locations in order to be useful. This functionality is also handled in
92-
this module. The following functions allow to control source mappings:
93-
94-
+ set_source_location()
95-
+ clear_source_location()
96-
+ start_emitting_source_locations()
97-
98-
`set_source_location()` allows to set the current source location. All IR instructions created after
99-
a call to this function will be linked to the given source location, until another location is
100-
specified with `set_source_location()` or the source location is cleared with
101-
`clear_source_location()`. In the later case, subsequent IR instruction will not be linked to any
102-
source location. As you can see, this is a stateful API (mimicking the one in LLVM), so be careful
103-
with source locations set by previous calls. It's probably best to not rely on any specific state
104-
being present at a given point in code.
105-
106-
One topic that deserves some extra attention is *function prologues*. At the beginning of a
107-
function's machine code there are typically a few instructions for loading argument values into
108-
allocas and checking if there's enough stack space for the function to execute. This *prologue* is
109-
not visible in the source code and LLVM puts a special PROLOGUE END marker into the line table at
110-
the first non-prologue instruction of the function. In order to find out where the prologue ends,
111-
LLVM looks for the first instruction in the function body that is linked to a source location. So,
112-
when generating prologue instructions we have to make sure that we don't emit source location
113-
information until the 'real' function body begins. For this reason, source location emission is
114-
disabled by default for any new function being translated and is only activated after a call to the
115-
third function from the list above, `start_emitting_source_locations()`. This function should be
116-
called right before regularly starting to translate the top-level block of the given function.
117-
118-
There is one exception to the above rule: `llvm.dbg.declare` instruction must be linked to the
119-
source location of the variable being declared. For function parameters these `llvm.dbg.declare`
120-
instructions typically occur in the middle of the prologue, however, they are ignored by LLVM's
121-
prologue detection. The `create_argument_metadata()` and related functions take care of linking the
122-
`llvm.dbg.declare` instructions to the correct source locations even while source location emission
123-
is still disabled, so there is no need to do anything special with source location handling here.
124-
12588
*/
12689

12790

@@ -688,16 +651,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
688651
(function_name.clone(), file_metadata)
689652
};
690653

691-
// Clang sets this parameter to the opening brace of the function's block, so let's do this too.
692-
let scope_line = span_start(cx, top_level_block.span).line;
693-
694-
// The is_local_to_unit flag indicates whether a function is local to the current compilation
695-
// unit (i.e. if it is *static* in the C-sense). The *reachable* set should provide a good
696-
// approximation of this, as it contains everything that might leak out of the current crate
697-
// (by being externally visible or by being inlined into something externally visible). It might
698-
// better to use the `exported_items` set from `driver::CrateAnalysis` in the future, but (atm)
699-
// this set is not available in the translation pass.
700-
let is_local_to_unit = !cx.reachable.contains(&fn_ast_id);
654+
let scope_line = get_scope_line(cx, top_level_block, loc.line);
701655

702656
let fn_metadata = function_name.with_c_str(|function_name| {
703657
linkage_name.with_c_str(|linkage_name| {
@@ -710,7 +664,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
710664
file_metadata,
711665
loc.line as c_uint,
712666
function_type_metadata,
713-
is_local_to_unit,
667+
false,
714668
true,
715669
scope_line as c_uint,
716670
FlagPrototyped as c_uint,
@@ -733,9 +687,6 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
733687
let arg_pats = fn_decl.inputs.map(|arg_ref| arg_ref.pat);
734688
populate_scope_map(cx, arg_pats, top_level_block, fn_metadata, &mut fn_debug_context.scope_map);
735689

736-
// Clear the debug location so we don't assign them in the function prelude
737-
set_debug_location(cx, UnknownLocation);
738-
739690
return FunctionDebugContext(fn_debug_context);
740691

741692
fn get_function_signature(cx: &mut CrateContext,
@@ -886,6 +837,21 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
886837

887838
return create_DIArray(DIB(cx), template_params);
888839
}
840+
841+
fn get_scope_line(cx: &CrateContext,
842+
top_level_block: &ast::Block,
843+
default: uint)
844+
-> uint {
845+
match *top_level_block {
846+
ast::Block { stmts: ref statements, .. } if statements.len() > 0 => {
847+
span_start(cx, statements[0].span).line
848+
}
849+
ast::Block { expr: Some(@ref expr), .. } => {
850+
span_start(cx, expr.span).line
851+
}
852+
_ => default
853+
}
854+
}
889855
}
890856

891857
//=-------------------------------------------------------------------------------------------------
@@ -2162,8 +2128,7 @@ fn set_debug_location(cx: &mut CrateContext, debug_location: DebugLocation) {
21622128
let metadata_node;
21632129

21642130
match debug_location {
2165-
KnownLocation { scope, line, .. } => {
2166-
let col = 0; // Always set the column to zero like Clang and GCC
2131+
KnownLocation { scope, line, col } => {
21672132
debug!("setting debug location to {} {}", line, col);
21682133
let elements = [C_i32(line as i32), C_i32(col as i32), scope, ptr::null()];
21692134
unsafe {
@@ -2279,14 +2244,7 @@ fn populate_scope_map(cx: &mut CrateContext,
22792244
})
22802245
}
22812246

2282-
// Clang creates a separate scope for function bodies, so let's do this too
2283-
with_new_scope(cx,
2284-
fn_entry_block.span,
2285-
&mut scope_stack,
2286-
scope_map,
2287-
|cx, scope_stack, scope_map| {
2288-
walk_block(cx, fn_entry_block, scope_stack, scope_map);
2289-
});
2247+
walk_block(cx, fn_entry_block, &mut scope_stack, scope_map);
22902248

22912249
// local helper functions for walking the AST.
22922250
fn with_new_scope(cx: &mut CrateContext,

branches/dist-snap/src/librustc/middle/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub fn trans_struct_drop(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast:
429429
add_clean(bcx, llfld_a, fld.mt.ty);
430430
}
431431

432-
let (_, bcx) = invoke(bcx, dtor_addr, args, [], None);
432+
let (_, bcx) = invoke(bcx, dtor_addr, args, []);
433433
bcx
434434
})
435435
}

branches/dist-snap/src/libstd/ptr.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ use util::swap;
2121

2222
#[cfg(not(test))] use cmp::{Eq, Ord};
2323

24-
/// Calculate the offset from a pointer
24+
/// Calculate the offset from a pointer.
25+
/// The `count` argument is in units of T; e.g. a `count` of 3
26+
/// represents a pointer offset of `3 * sizeof::<T>()` bytes.
2527
#[inline]
2628
pub unsafe fn offset<T>(ptr: *T, count: int) -> *T {
2729
intrinsics::offset(ptr, count)
2830
}
2931

3032
/// Calculate the offset from a mut pointer. The count *must* be in bounds or
3133
/// otherwise the loads of this address are undefined.
34+
/// The `count` argument is in units of T; e.g. a `count` of 3
35+
/// represents a pointer offset of `3 * sizeof::<T>()` bytes.
3236
#[inline]
3337
pub unsafe fn mut_offset<T>(ptr: *mut T, count: int) -> *mut T {
3438
intrinsics::offset(ptr as *T, count) as *mut T

branches/dist-snap/src/test/debug-info/basic-types-metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
// debugger:whatis f64
4646
// check:type = f64
4747
// debugger:info functions _yyy
48-
// check:[...]![...]_yyy()();
48+
// check:[...]
49+
// check:![...]_yyy()();
4950
// debugger:detach
5051
// debugger:quit
5152

0 commit comments

Comments
 (0)