Skip to content

Commit 114be1e

Browse files
authored
Auto merge of #34315 - Manishearth:rollup, r=Manishearth
Rollup of 4 pull requests - Successful merges: #34298, #34302, #34307, #34312 - Failed merges:
2 parents f911d87 + 019c594 commit 114be1e

File tree

13 files changed

+1037
-934
lines changed

13 files changed

+1037
-934
lines changed

src/bootstrap/build/cc.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ pub fn find(build: &mut Build) {
5757
let compiler = cfg.get_compiler();
5858
let ar = cc2ar(compiler.path(), target);
5959
build.verbose(&format!("CC_{} = {:?}", target, compiler.path()));
60-
build.verbose(&format!("AR_{} = {:?}", target, ar));
60+
if let Some(ref ar) = ar {
61+
build.verbose(&format!("AR_{} = {:?}", target, ar));
62+
}
6163
build.cc.insert(target.to_string(), (compiler, ar));
6264
}
6365

src/bootstrap/build/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub struct Build {
119119
lldb_python_dir: Option<String>,
120120

121121
// Runtime state filled in later on
122-
cc: HashMap<String, (gcc::Tool, PathBuf)>,
122+
cc: HashMap<String, (gcc::Tool, Option<PathBuf>)>,
123123
cxx: HashMap<String, gcc::Tool>,
124124
compiler_rt_built: RefCell<HashMap<String, PathBuf>>,
125125
}
@@ -549,7 +549,7 @@ impl Build {
549549
// FIXME: the guard against msvc shouldn't need to be here
550550
if !target.contains("msvc") {
551551
cargo.env(format!("CC_{}", target), self.cc(target))
552-
.env(format!("AR_{}", target), self.ar(target))
552+
.env(format!("AR_{}", target), self.ar(target).unwrap()) // only msvc is None
553553
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
554554
}
555555

@@ -825,8 +825,8 @@ impl Build {
825825
}
826826

827827
/// Returns the path to the `ar` archive utility for the target specified.
828-
fn ar(&self, target: &str) -> &Path {
829-
&self.cc[target].1
828+
fn ar(&self, target: &str) -> Option<&Path> {
829+
self.cc[target].1.as_ref().map(|p| &**p)
830830
}
831831

832832
/// Returns the path to the C++ compiler for the target specified, may panic

src/bootstrap/build/sanity.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ pub fn check(build: &mut Build) {
7070
// also build some C++ shims for LLVM so we need a C++ compiler.
7171
for target in build.config.target.iter() {
7272
need_cmd(build.cc(target).as_ref());
73-
need_cmd(build.ar(target).as_ref());
73+
if let Some(ar) = build.ar(target) {
74+
need_cmd(ar.as_ref());
75+
}
7476
}
7577
for host in build.config.host.iter() {
7678
need_cmd(build.cxx(host).as_ref());

src/build_helper/lib.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,22 @@ pub fn gnu_target(target: &str) -> String {
3939
}
4040
}
4141

42-
pub fn cc2ar(cc: &Path, target: &str) -> PathBuf {
43-
if target.contains("musl") || target.contains("msvc") {
44-
PathBuf::from("ar")
42+
pub fn cc2ar(cc: &Path, target: &str) -> Option<PathBuf> {
43+
if target.contains("msvc") {
44+
None
45+
} else if target.contains("musl") {
46+
Some(PathBuf::from("ar"))
4547
} else {
4648
let parent = cc.parent().unwrap();
4749
let file = cc.file_name().unwrap().to_str().unwrap();
4850
for suffix in &["gcc", "cc", "clang"] {
4951
if let Some(idx) = file.rfind(suffix) {
5052
let mut file = file[..idx].to_owned();
5153
file.push_str("ar");
52-
return parent.join(&file);
54+
return Some(parent.join(&file));
5355
}
5456
}
55-
parent.join(file)
57+
Some(parent.join(file))
5658
}
5759
}
5860

src/liballoc_jemalloc/build.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ fn main() {
4343
}
4444

4545
let compiler = gcc::Config::new().get_compiler();
46-
let ar = build_helper::cc2ar(compiler.path(), &target);
46+
// only msvc returns None for ar so unwrap is okay
47+
let ar = build_helper::cc2ar(compiler.path(), &target).unwrap();
4748
let cflags = compiler.args()
4849
.iter()
4950
.map(|s| s.to_str().unwrap())

src/librustc_mir/build/scope.rs

+30-27
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ use rustc::ty::{Ty, TyCtxt};
9494
use rustc::mir::repr::*;
9595
use syntax::codemap::Span;
9696
use rustc_data_structures::indexed_vec::Idx;
97+
use rustc_data_structures::fnv::FnvHashMap;
9798

9899
pub struct Scope<'tcx> {
99100
/// the scope-id within the scope_auxiliary
@@ -127,12 +128,8 @@ pub struct Scope<'tcx> {
127128
/// stage.
128129
free: Option<FreeData<'tcx>>,
129130

130-
/// The cached block for the cleanups-on-diverge path. This block
131-
/// contains a block that will just do a RESUME to an appropriate
132-
/// place. This block does not execute any of the drops or free:
133-
/// each of those has their own cached-blocks, which will branch
134-
/// to this point.
135-
cached_block: Option<BasicBlock>
131+
/// The cache for drop chain on “normal” exit into a particular BasicBlock.
132+
cached_exits: FnvHashMap<(BasicBlock, CodeExtent), BasicBlock>,
136133
}
137134

138135
struct DropData<'tcx> {
@@ -172,7 +169,7 @@ pub struct LoopScope {
172169
pub continue_block: BasicBlock,
173170
/// Block to branch into when the loop terminates (either by being `break`-en out from, or by
174171
/// having its condition to become false)
175-
pub break_block: BasicBlock, // where to go on a `break
172+
pub break_block: BasicBlock,
176173
/// Indicates the reachability of the break_block for this loop
177174
pub might_break: bool
178175
}
@@ -183,7 +180,7 @@ impl<'tcx> Scope<'tcx> {
183180
/// Should always be run for all inner scopes when a drop is pushed into some scope enclosing a
184181
/// larger extent of code.
185182
fn invalidate_cache(&mut self) {
186-
self.cached_block = None;
183+
self.cached_exits = FnvHashMap();
187184
for dropdata in &mut self.drops {
188185
dropdata.cached_block = None;
189186
}
@@ -192,7 +189,7 @@ impl<'tcx> Scope<'tcx> {
192189
}
193190
}
194191

195-
/// Returns the cached block for this scope.
192+
/// Returns the cached entrypoint for diverging exit from this scope.
196193
///
197194
/// Precondition: the caches must be fully filled (i.e. diverge_cleanup is called) in order for
198195
/// this method to work correctly.
@@ -270,7 +267,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
270267
extent: extent,
271268
drops: vec![],
272269
free: None,
273-
cached_block: None,
270+
cached_exits: FnvHashMap()
274271
});
275272
self.scope_auxiliary.push(ScopeAuxiliary {
276273
extent: extent,
@@ -314,13 +311,25 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
314311
.unwrap_or_else(||{
315312
span_bug!(span, "extent {:?} does not enclose", extent)
316313
});
317-
314+
let len = self.scopes.len();
315+
assert!(scope_count < len, "should not use `exit_scope` to pop ALL scopes");
318316
let tmp = self.get_unit_temp();
319-
for (idx, ref scope) in self.scopes.iter().enumerate().rev().take(scope_count) {
320-
unpack!(block = build_scope_drops(&mut self.cfg,
321-
scope,
322-
&self.scopes[..idx],
323-
block));
317+
{
318+
let mut rest = &mut self.scopes[(len - scope_count)..];
319+
while let Some((scope, rest_)) = {rest}.split_last_mut() {
320+
rest = rest_;
321+
block = if let Some(&e) = scope.cached_exits.get(&(target, extent)) {
322+
self.cfg.terminate(block, scope.source_info(span),
323+
TerminatorKind::Goto { target: e });
324+
return;
325+
} else {
326+
let b = self.cfg.start_new_block();
327+
self.cfg.terminate(block, scope.source_info(span),
328+
TerminatorKind::Goto { target: b });
329+
scope.cached_exits.insert((target, extent), b);
330+
b
331+
};
332+
unpack!(block = build_scope_drops(&mut self.cfg, scope, rest, block));
324333
if let Some(ref free_data) = scope.free {
325334
let next = self.cfg.start_new_block();
326335
let free = build_free(self.hir.tcx(), &tmp, free_data, next);
@@ -331,14 +340,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
331340
.postdoms
332341
.push(self.cfg.current_location(block));
333342
}
334-
335-
assert!(scope_count < self.scopes.len(),
336-
"should never use `exit_scope` to pop *ALL* scopes");
337-
let scope = self.scopes.iter().rev().skip(scope_count)
338-
.next()
339-
.unwrap();
340-
self.cfg.terminate(block,
341-
scope.source_info(span),
343+
}
344+
let scope = &self.scopes[len - scope_count];
345+
self.cfg.terminate(block, scope.source_info(span),
342346
TerminatorKind::Goto { target: target });
343347
}
344348

@@ -506,10 +510,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
506510
resumeblk
507511
};
508512

509-
for scope in scopes {
513+
for scope in scopes.iter_mut().filter(|s| !s.drops.is_empty() || s.free.is_some()) {
510514
target = build_diverge_scope(hir.tcx(), cfg, &unit_temp, scope, target);
511515
}
512-
513516
Some(target)
514517
}
515518

@@ -534,7 +537,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
534537
next_target.unit()
535538
}
536539

537-
540+
/// Utility function for *non*-scope code to build their own drops
538541
pub fn build_drop_and_replace(&mut self,
539542
block: BasicBlock,
540543
span: Span,

src/librustc_save_analysis/data.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ pub struct EnumData {
102102
pub qualname: String,
103103
pub span: Span,
104104
pub scope: NodeId,
105+
pub variants: Vec<NodeId>,
106+
105107
}
106108

107109
/// Data for extern crates.
@@ -212,6 +214,7 @@ pub struct MethodData {
212214
pub span: Span,
213215
pub scope: NodeId,
214216
pub value: String,
217+
pub decl_id: Option<DefId>,
215218
}
216219

217220
/// Data for modules.
@@ -223,6 +226,7 @@ pub struct ModData {
223226
pub span: Span,
224227
pub scope: NodeId,
225228
pub filename: String,
229+
pub items: Vec<NodeId>,
226230
}
227231

228232
/// Data for a reference to a module.
@@ -242,7 +246,8 @@ pub struct StructData {
242246
pub ctor_id: NodeId,
243247
pub qualname: String,
244248
pub scope: NodeId,
245-
pub value: String
249+
pub value: String,
250+
pub fields: Vec<NodeId>,
246251
}
247252

248253
#[derive(Debug, RustcEncodable)]
@@ -263,7 +268,8 @@ pub struct TraitData {
263268
pub name: String,
264269
pub qualname: String,
265270
pub scope: NodeId,
266-
pub value: String
271+
pub value: String,
272+
pub items: Vec<NodeId>,
267273
}
268274

269275
#[derive(Debug, RustcEncodable)]
@@ -317,6 +323,7 @@ pub struct UseGlobData {
317323
#[derive(Debug, RustcEncodable)]
318324
pub struct VariableData {
319325
pub id: NodeId,
326+
pub kind: VariableKind,
320327
pub name: String,
321328
pub qualname: String,
322329
pub span: Span,
@@ -325,6 +332,14 @@ pub struct VariableData {
325332
pub type_value: String,
326333
}
327334

335+
#[derive(Debug, RustcEncodable)]
336+
pub enum VariableKind {
337+
Static,
338+
Const,
339+
Local,
340+
Field,
341+
}
342+
328343
/// Data for the use of some item (e.g., the use of a local variable, which
329344
/// will refer to that variables declaration (by ref_id)).
330345
#[derive(Debug, RustcEncodable)]

0 commit comments

Comments
 (0)