Skip to content

Commit 1949e56

Browse files
committed
---
yaml --- r: 221027 b: refs/heads/auto c: 70e8220 h: refs/heads/master i: 221025: acefb3f 221023: 9f06007 v: v3
1 parent 9f16001 commit 1949e56

File tree

13 files changed

+112
-168
lines changed

13 files changed

+112
-168
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: c85ba3e9cb4620c6ec8273a34cce6707e91778cb
11+
refs/heads/auto: 70e8220166744045780fd1c658f796df6a99a936
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/libcore/str/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,12 +871,12 @@ impl<'a> DoubleEndedIterator for LinesAny<'a> {
871871
Section: Comparing strings
872872
*/
873873

874-
/// Bytewise slice equality
874+
// share the implementation of the lang-item vs. non-lang-item
875+
// eq_slice.
875876
/// NOTE: This function is (ab)used in rustc::middle::trans::_match
876877
/// to compare &[u8] byte slices that are not necessarily valid UTF-8.
877-
#[lang = "str_eq"]
878878
#[inline]
879-
fn eq_slice(a: &str, b: &str) -> bool {
879+
fn eq_slice_(a: &str, b: &str) -> bool {
880880
// NOTE: In theory n should be libc::size_t and not usize, but libc is not available here
881881
#[allow(improper_ctypes)]
882882
extern { fn memcmp(s1: *const i8, s2: *const i8, n: usize) -> i32; }
@@ -887,6 +887,15 @@ fn eq_slice(a: &str, b: &str) -> bool {
887887
}
888888
}
889889

890+
/// Bytewise slice equality
891+
/// NOTE: This function is (ab)used in rustc::middle::trans::_match
892+
/// to compare &[u8] byte slices that are not necessarily valid UTF-8.
893+
#[lang = "str_eq"]
894+
#[inline]
895+
fn eq_slice(a: &str, b: &str) -> bool {
896+
eq_slice_(a, b)
897+
}
898+
890899
/*
891900
Section: Misc
892901
*/

branches/auto/src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn krate(sess: &Session, krate: &ast::Crate, def_map: &DefMap) -> NamedRegio
109109

110110
impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
111111
fn visit_item(&mut self, item: &ast::Item) {
112-
// Items save/restore the set of labels. This way inner items
112+
// Items save/restore the set of labels. This way innner items
113113
// can freely reuse names, be they loop labels or lifetimes.
114114
let saved = replace(&mut self.labels_in_fn, vec![]);
115115

@@ -151,29 +151,6 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
151151
replace(&mut self.labels_in_fn, saved);
152152
}
153153

154-
fn visit_foreign_item(&mut self, item: &ast::ForeignItem) {
155-
// Items save/restore the set of labels. This way inner items
156-
// can freely reuse names, be they loop labels or lifetimes.
157-
let saved = replace(&mut self.labels_in_fn, vec![]);
158-
159-
// Items always introduce a new root scope
160-
self.with(RootScope, |_, this| {
161-
match item.node {
162-
ast::ForeignItemFn(_, ref generics) => {
163-
this.visit_early_late(subst::FnSpace, generics, |this| {
164-
visit::walk_foreign_item(this, item);
165-
})
166-
}
167-
ast::ForeignItemStatic(..) => {
168-
visit::walk_foreign_item(this, item);
169-
}
170-
}
171-
});
172-
173-
// Done traversing the item; restore saved set of labels.
174-
replace(&mut self.labels_in_fn, saved);
175-
}
176-
177154
fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
178155
b: &'v ast::Block, s: Span, _: ast::NodeId) {
179156
match fk {

branches/auto/src/librustc_trans/back/lto.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ use llvm::archive_ro::ArchiveRO;
1616
use llvm::{ModuleRef, TargetMachineRef, True, False};
1717
use rustc::metadata::cstore;
1818
use rustc::util::common::time;
19+
use back::write::{ModuleConfig, with_llvm_pmb};
1920

2021
use libc;
2122
use flate;
2223

2324
use std::ffi::CString;
2425

2526
pub fn run(sess: &session::Session, llmod: ModuleRef,
26-
tm: TargetMachineRef, reachable: &[String]) {
27+
tm: TargetMachineRef, reachable: &[String],
28+
config: &ModuleConfig) {
2729
if sess.opts.cg.prefer_dynamic {
2830
sess.err("cannot prefer dynamic linking when performing LTO");
2931
sess.note("only 'staticlib' and 'bin' outputs are supported with LTO");
@@ -144,19 +146,11 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
144146
llvm::LLVMRustAddAnalysisPasses(tm, pm, llmod);
145147
llvm::LLVMRustAddPass(pm, "verify\0".as_ptr() as *const _);
146148

147-
let opt = match sess.opts.optimize {
148-
config::No => 0,
149-
config::Less => 1,
150-
config::Default => 2,
151-
config::Aggressive => 3,
152-
};
153-
154-
let builder = llvm::LLVMPassManagerBuilderCreate();
155-
llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt);
156-
llvm::LLVMPassManagerBuilderPopulateLTOPassManager(builder, pm,
157-
/* Internalize = */ False,
158-
/* RunInliner = */ True);
159-
llvm::LLVMPassManagerBuilderDispose(builder);
149+
with_llvm_pmb(llmod, config, &mut |b| {
150+
llvm::LLVMPassManagerBuilderPopulateLTOPassManager(b, pm,
151+
/* Internalize = */ False,
152+
/* RunInliner = */ True);
153+
});
160154

161155
llvm::LLVMRustAddPass(pm, "verify\0".as_ptr() as *const _);
162156

branches/auto/src/librustc_trans/back/write.rs

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
249249

250250
/// Module-specific configuration for `optimize_and_codegen`.
251251
#[derive(Clone)]
252-
struct ModuleConfig {
252+
pub struct ModuleConfig {
253253
/// LLVM TargetMachine to use for codegen.
254254
tm: TargetMachineRef,
255255
/// Names of additional optimization passes to run.
@@ -444,72 +444,72 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
444444
llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
445445
}
446446

447-
match config.opt_level {
448-
Some(opt_level) => {
449-
// Create the two optimizing pass managers. These mirror what clang
450-
// does, and are by populated by LLVM's default PassManagerBuilder.
451-
// Each manager has a different set of passes, but they also share
452-
// some common passes.
453-
let fpm = llvm::LLVMCreateFunctionPassManagerForModule(llmod);
454-
let mpm = llvm::LLVMCreatePassManager();
455-
456-
// If we're verifying or linting, add them to the function pass
457-
// manager.
458-
let addpass = |pass: &str| {
459-
let pass = CString::new(pass).unwrap();
460-
llvm::LLVMRustAddPass(fpm, pass.as_ptr())
461-
};
447+
if config.opt_level.is_some() {
448+
// Create the two optimizing pass managers. These mirror what clang
449+
// does, and are by populated by LLVM's default PassManagerBuilder.
450+
// Each manager has a different set of passes, but they also share
451+
// some common passes.
452+
let fpm = llvm::LLVMCreateFunctionPassManagerForModule(llmod);
453+
let mpm = llvm::LLVMCreatePassManager();
454+
455+
// If we're verifying or linting, add them to the function pass
456+
// manager.
457+
let addpass = |pass: &str| {
458+
let pass = CString::new(pass).unwrap();
459+
llvm::LLVMRustAddPass(fpm, pass.as_ptr())
460+
};
462461

463-
if !config.no_verify { assert!(addpass("verify")); }
464-
if !config.no_prepopulate_passes {
465-
llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
466-
llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
467-
populate_llvm_passes(fpm, mpm, llmod, opt_level, &config);
468-
}
462+
if !config.no_verify { assert!(addpass("verify")); }
463+
if !config.no_prepopulate_passes {
464+
llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
465+
llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
466+
with_llvm_pmb(llmod, &config, &mut |b| {
467+
llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(b, fpm);
468+
llvm::LLVMPassManagerBuilderPopulateModulePassManager(b, mpm);
469+
})
470+
}
469471

470-
for pass in &config.passes {
471-
if !addpass(pass) {
472-
cgcx.handler.warn(&format!("unknown pass `{}`, ignoring",
473-
pass));
474-
}
472+
for pass in &config.passes {
473+
if !addpass(pass) {
474+
cgcx.handler.warn(&format!("unknown pass `{}`, ignoring",
475+
pass));
475476
}
477+
}
476478

477-
for pass in &cgcx.plugin_passes {
478-
if !addpass(pass) {
479-
cgcx.handler.err(&format!("a plugin asked for LLVM pass \
480-
`{}` but LLVM does not \
481-
recognize it", pass));
482-
}
479+
for pass in &cgcx.plugin_passes {
480+
if !addpass(pass) {
481+
cgcx.handler.err(&format!("a plugin asked for LLVM pass \
482+
`{}` but LLVM does not \
483+
recognize it", pass));
483484
}
485+
}
484486

485-
cgcx.handler.abort_if_errors();
487+
cgcx.handler.abort_if_errors();
486488

487-
// Finally, run the actual optimization passes
488-
time(config.time_passes, "llvm function passes", (), |()|
489-
llvm::LLVMRustRunFunctionPassManager(fpm, llmod));
490-
time(config.time_passes, "llvm module passes", (), |()|
491-
llvm::LLVMRunPassManager(mpm, llmod));
489+
// Finally, run the actual optimization passes
490+
time(config.time_passes, "llvm function passes", (), |()|
491+
llvm::LLVMRustRunFunctionPassManager(fpm, llmod));
492+
time(config.time_passes, "llvm module passes", (), |()|
493+
llvm::LLVMRunPassManager(mpm, llmod));
492494

493-
// Deallocate managers that we're now done with
494-
llvm::LLVMDisposePassManager(fpm);
495-
llvm::LLVMDisposePassManager(mpm);
495+
// Deallocate managers that we're now done with
496+
llvm::LLVMDisposePassManager(fpm);
497+
llvm::LLVMDisposePassManager(mpm);
496498

497-
match cgcx.lto_ctxt {
498-
Some((sess, reachable)) if sess.lto() => {
499-
time(sess.time_passes(), "all lto passes", (), |()|
500-
lto::run(sess, llmod, tm, reachable));
499+
match cgcx.lto_ctxt {
500+
Some((sess, reachable)) if sess.lto() => {
501+
time(sess.time_passes(), "all lto passes", (), |()|
502+
lto::run(sess, llmod, tm, reachable, &config));
501503

502-
if config.emit_lto_bc {
503-
let name = format!("{}.lto.bc", name_extra);
504-
let out = output_names.with_extension(&name);
505-
let out = path2cstr(&out);
506-
llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
507-
}
508-
},
509-
_ => {},
510-
}
511-
},
512-
None => {},
504+
if config.emit_lto_bc {
505+
let name = format!("{}.lto.bc", name_extra);
506+
let out = output_names.with_extension(&name);
507+
let out = path2cstr(&out);
508+
llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
509+
}
510+
},
511+
_ => {},
512+
}
513513
}
514514

515515
// A codegen-specific pass manager is used to generate object
@@ -1001,15 +1001,14 @@ pub unsafe fn configure_llvm(sess: &Session) {
10011001
llvm_args.as_ptr());
10021002
}
10031003

1004-
unsafe fn populate_llvm_passes(fpm: llvm::PassManagerRef,
1005-
mpm: llvm::PassManagerRef,
1006-
llmod: ModuleRef,
1007-
opt: llvm::CodeGenOptLevel,
1008-
config: &ModuleConfig) {
1004+
pub unsafe fn with_llvm_pmb(llmod: ModuleRef,
1005+
config: &ModuleConfig,
1006+
f: &mut FnMut(llvm::PassManagerBuilderRef)) {
10091007
// Create the PassManagerBuilder for LLVM. We configure it with
10101008
// reasonable defaults and prepare it to actually populate the pass
10111009
// manager.
10121010
let builder = llvm::LLVMPassManagerBuilderCreate();
1011+
let opt = config.opt_level.unwrap_or(llvm::CodeGenLevelNone);
10131012

10141013
llvm::LLVMRustConfigurePassManagerBuilder(builder, opt,
10151014
config.merge_functions,
@@ -1037,8 +1036,6 @@ unsafe fn populate_llvm_passes(fpm: llvm::PassManagerRef,
10371036
}
10381037
}
10391038

1040-
// Use the builder to populate the function/module pass managers.
1041-
llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(builder, fpm);
1042-
llvm::LLVMPassManagerBuilderPopulateModulePassManager(builder, mpm);
1039+
f(builder);
10431040
llvm::LLVMPassManagerBuilderDispose(builder);
10441041
}

branches/auto/src/librustc_trans/save/dump_csv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
478478

479479
let ctor_id = match def.ctor_id {
480480
Some(node_id) => node_id,
481-
None => ast::DUMMY_NODE_ID,
481+
None => -1,
482482
};
483483
let val = self.span.snippet(item.span);
484484
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Struct);
@@ -536,7 +536,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
536536
ast::StructVariantKind(ref struct_def) => {
537537
let ctor_id = match struct_def.ctor_id {
538538
Some(node_id) => node_id,
539-
None => ast::DUMMY_NODE_ID,
539+
None => -1,
540540
};
541541
self.fmt.struct_variant_str(variant.span,
542542
self.span.span_for_first_ident(variant.span),

branches/auto/src/librustc_trans/trans/cleanup.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -774,22 +774,20 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
774774
// At this point, `popped_scopes` is empty, and so the final block
775775
// that we return to the user is `Cleanup(AST 24)`.
776776
while let Some(mut scope) = popped_scopes.pop() {
777-
if !scope.cleanups.is_empty() {
778-
let name = scope.block_name("clean");
779-
debug!("generating cleanups for {}", name);
780-
let bcx_in = self.new_block(label.is_unwind(),
781-
&name[..],
782-
None);
783-
let mut bcx_out = bcx_in;
784-
for cleanup in scope.cleanups.iter().rev() {
785-
bcx_out = cleanup.trans(bcx_out,
786-
scope.debug_loc);
787-
}
788-
build::Br(bcx_out, prev_llbb, DebugLoc::None);
789-
prev_llbb = bcx_in.llbb;
790-
791-
scope.add_cached_early_exit(label, prev_llbb);
777+
let name = scope.block_name("clean");
778+
debug!("generating cleanups for {}", name);
779+
let bcx_in = self.new_block(label.is_unwind(),
780+
&name[..],
781+
None);
782+
let mut bcx_out = bcx_in;
783+
for cleanup in scope.cleanups.iter().rev() {
784+
bcx_out = cleanup.trans(bcx_out,
785+
scope.debug_loc);
792786
}
787+
build::Br(bcx_out, prev_llbb, DebugLoc::None);
788+
prev_llbb = bcx_in.llbb;
789+
790+
scope.add_cached_early_exit(label, prev_llbb);
793791
self.push_scope(scope);
794792
}
795793

branches/auto/src/librustc_typeck/astconv.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ use middle::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs};
5959
use middle::traits;
6060
use middle::ty::{self, RegionEscape, Ty, ToPredicate, HasTypeFlags};
6161
use middle::ty_fold;
62-
use require_c_abi_if_variadic;
6362
use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope, ExplicitRscope,
6463
ObjectLifetimeDefaultRscope, ShiftedRscope, BindingRscope,
6564
ElisionFailureInfo, ElidedLifetime};
@@ -1576,7 +1575,10 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
15761575
}
15771576
ast::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ),
15781577
ast::TyBareFn(ref bf) => {
1579-
require_c_abi_if_variadic(tcx, &bf.decl, bf.abi, ast_ty.span);
1578+
if bf.decl.variadic && bf.abi != abi::C {
1579+
span_err!(tcx.sess, ast_ty.span, E0045,
1580+
"variadic function must have C calling convention");
1581+
}
15801582
let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl);
15811583
tcx.mk_fn(None, tcx.mk_bare_fn(bare_fn))
15821584
}

branches/auto/src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ use middle::ty::{Disr, ParamTy, ParameterEnvironment};
9797
use middle::ty::{self, HasTypeFlags, RegionEscape, ToPolyTraitRef, Ty};
9898
use middle::ty::{MethodCall, MethodCallee};
9999
use middle::ty_fold::{TypeFolder, TypeFoldable};
100-
use require_c_abi_if_variadic;
101100
use rscope::{ElisionFailureInfo, RegionScope};
102101
use session::Session;
103102
use {CrateCtxt, lookup_full_def, require_same_types};
@@ -686,7 +685,10 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
686685
}
687686

688687
if let ast::ForeignItemFn(ref fn_decl, _) = item.node {
689-
require_c_abi_if_variadic(ccx.tcx, fn_decl, m.abi, item.span);
688+
if fn_decl.variadic && m.abi != abi::C {
689+
span_err!(ccx.tcx.sess, item.span, E0045,
690+
"variadic function must have C calling convention");
691+
}
690692
}
691693
}
692694
}

0 commit comments

Comments
 (0)