Skip to content

Commit 17f2264

Browse files
committed
---
yaml --- r: 125925 b: refs/heads/try c: d4dfb7d h: refs/heads/master i: 125923: 1cf2a37 v: v3
1 parent 012091f commit 17f2264

File tree

28 files changed

+521
-182
lines changed

28 files changed

+521
-182
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: f2fa55903e378368ed9173560f03a0ef16e371c2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9fc8394d3bce22ab483f98842434c84c396212ae
5-
refs/heads/try: ca18c12243589fc3662d9d6b6f75686518994f2b
5+
refs/heads/try: d4dfb7d84c2af1e3bb7b6efe41c22c4ab17118e8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/mk/grammar.mk

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SG = $(S)src/grammar/
1313
B = $(CFG_BUILD_DIR)/$(CFG_BUILD)/stage2/
1414
L = $(B)lib/rustlib/$(CFG_BUILD)/lib
1515
LD = $(CFG_BUILD)/stage2/lib/rustlib/$(CFG_BUILD)/lib/
16-
RUSTC = $(B)bin/rustc
16+
RUSTC = $(STAGE2_T_$(CFG_BUILD)_H_$(CFG_BUILD))
1717

1818
# Run the reference lexer against libsyntax and compare the tokens and spans.
1919
# If "// ignore-lexer-test" is present in the file, it will be ignored.
@@ -37,19 +37,25 @@ $(BG)RustLexer.class: $(SG)RustLexer.g4
3737
$(BG)verify: $(SG)verify.rs rustc-stage2-H-$(CFG_BUILD) $(LD)stamp.regex_macros $(LD)stamp.rustc
3838
$(Q)$(RUSTC) -O --out-dir $(BG) -L $(L) $(SG)verify.rs
3939

40-
check-lexer: $(BG) $(BG)RustLexer.class $(BG)verify
4140
ifdef CFG_JAVAC
4241
ifdef CFG_ANTLR4
4342
ifdef CFG_GRUN
43+
check-lexer: $(BG) $(BG)RustLexer.class $(BG)verify
4444
$(info Verifying libsyntax against the reference lexer ...)
4545
$(Q)$(SG)check.sh $(S) "$(BG)" \
4646
"$(CFG_GRUN)" "$(BG)verify" "$(BG)RustLexer.tokens"
4747
else
48-
$(info grun not available, skipping lexer test...)
48+
$(info cfg: grun not available, skipping lexer test...)
49+
check-lexer:
50+
4951
endif
5052
else
51-
$(info antlr4 not available, skipping lexer test...)
53+
$(info cfg: antlr4 not available, skipping lexer test...)
54+
check-lexer:
55+
5256
endif
5357
else
54-
$(info javac not available, skipping lexer test...)
58+
$(info cfg: javac not available, skipping lexer test...)
59+
check-lexer:
60+
5561
endif

branches/try/mk/tests.mk

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,28 +171,41 @@ endif
171171
# Main test targets
172172
######################################################################
173173

174+
# The main testing target. Tests lots of stuff.
174175
check: cleantmptestlogs cleantestlibs check-notidy tidy
175176

177+
# As above but don't bother running tidy.
176178
check-notidy: cleantmptestlogs cleantestlibs all check-stage2
177179
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
178180

181+
# A slightly smaller set of tests for smoke testing.
179182
check-lite: cleantestlibs cleantmptestlogs \
180183
$(foreach crate,$(TEST_TARGET_CRATES),check-stage2-$(crate)) \
181184
check-stage2-rpass \
182185
check-stage2-rfail check-stage2-cfail check-stage2-rmake
183186
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
184187

188+
# Only check the 'reference' tests: rpass/cfail/rfail/rmake.
185189
check-ref: cleantestlibs cleantmptestlogs check-stage2-rpass \
186190
check-stage2-rfail check-stage2-cfail check-stage2-rmake
187191
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
188192

193+
# Only check the docs.
189194
check-docs: cleantestlibs cleantmptestlogs check-stage2-docs
190195
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
191196

192197
# NOTE: Remove after reprogramming windows bots
193198
check-fast: check-lite
194199

195-
check-syntax: check-lexer
200+
# Some less critical tests that are not prone to breakage.
201+
# Not run as part of the normal test suite, but tested by bors on checkin.
202+
check-secondary: check-lexer check-pretty
203+
204+
# check + check-secondary.
205+
check-all: check check-secondary
206+
207+
# Pretty-printing tests.
208+
check-pretty: check-stage2-T-$(CFG_BUILD)-H-$(CFG_BUILD)-pretty-exec
196209

197210
.PHONY: cleantmptestlogs cleantestlibs
198211

branches/try/src/libcollections/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<V> SmallIntMap<V> {
263263
}
264264
}
265265

266-
/// Empties the hash map, moving all values into the specified closure.
266+
/// Empties the map, moving all values into the specified closure.
267267
///
268268
/// # Example
269269
///

branches/try/src/libcore/fmt/num.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use iter::Iterator; // NOTE(stage0): Remove after snapshot.
2626
use option::{Some, None}; // NOTE(stage0): Remove after snapshot.
2727

2828
/// A type that represents a specific radix
29+
#[doc(hidden)]
2930
trait GenericRadix {
3031
/// The number of digits.
3132
fn base(&self) -> u8;

branches/try/src/librustc/front/std_inject.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,15 @@ impl<'a> fold::Folder for StandardLibraryInjector<'a> {
8686
*ty == config::CrateTypeExecutable
8787
});
8888
if use_start(&krate) && any_exe {
89+
let visible_rt_name = "rt";
90+
let actual_rt_name = "native";
91+
// Gensym the ident so it can't be named
92+
let visible_rt_name = token::gensym_ident(visible_rt_name);
93+
let actual_rt_name = token::intern_and_get_ident(actual_rt_name);
94+
8995
vis.push(ast::ViewItem {
90-
node: ast::ViewItemExternCrate(token::str_to_ident("native"),
91-
None,
96+
node: ast::ViewItemExternCrate(visible_rt_name,
97+
Some((actual_rt_name, ast::CookedStr)),
9298
ast::DUMMY_NODE_ID),
9399
attrs: Vec::new(),
94100
vis: ast::Inherited,

branches/try/src/librustc/middle/trans/base.rs

Lines changed: 77 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str) -> ValueRef {
281281

282282
let llfn = decl_fn(ccx, name, llvm::CCallConv, llfty, output);
283283
let attrs = get_fn_llvm_attributes(ccx, fn_ty);
284-
for &(idx, attr) in attrs.iter() {
285-
unsafe {
286-
llvm::LLVMAddFunctionAttribute(llfn, idx as c_uint, attr);
287-
}
288-
}
284+
attrs.apply_llfn(llfn);
289285

290286
llfn
291287
}
@@ -962,7 +958,7 @@ pub fn invoke<'a>(
962958
llargs.as_slice(),
963959
normal_bcx.llbb,
964960
landing_pad,
965-
attributes.as_slice());
961+
Some(attributes));
966962
return (llresult, normal_bcx);
967963
} else {
968964
debug!("calling {} at {}", llfn, bcx.llbb);
@@ -975,7 +971,7 @@ pub fn invoke<'a>(
975971
None => debuginfo::clear_source_location(bcx.fcx)
976972
};
977973

978-
let llresult = Call(bcx, llfn, llargs.as_slice(), attributes.as_slice());
974+
let llresult = Call(bcx, llfn, llargs.as_slice(), Some(attributes));
979975
return (llresult, bcx);
980976
}
981977
}
@@ -1081,7 +1077,7 @@ pub fn call_lifetime_start(cx: &Block, ptr: ValueRef) {
10811077
let llsize = C_u64(ccx, machine::llsize_of_alloc(ccx, val_ty(ptr).element_type()));
10821078
let ptr = PointerCast(cx, ptr, Type::i8p(ccx));
10831079
let lifetime_start = ccx.get_intrinsic(&"llvm.lifetime.start");
1084-
Call(cx, lifetime_start, [llsize, ptr], []);
1080+
Call(cx, lifetime_start, [llsize, ptr], None);
10851081
}
10861082

10871083
pub fn call_lifetime_end(cx: &Block, ptr: ValueRef) {
@@ -1095,7 +1091,7 @@ pub fn call_lifetime_end(cx: &Block, ptr: ValueRef) {
10951091
let llsize = C_u64(ccx, machine::llsize_of_alloc(ccx, val_ty(ptr).element_type()));
10961092
let ptr = PointerCast(cx, ptr, Type::i8p(ccx));
10971093
let lifetime_end = ccx.get_intrinsic(&"llvm.lifetime.end");
1098-
Call(cx, lifetime_end, [llsize, ptr], []);
1094+
Call(cx, lifetime_end, [llsize, ptr], None);
10991095
}
11001096

11011097
pub fn call_memcpy(cx: &Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
@@ -1111,7 +1107,7 @@ pub fn call_memcpy(cx: &Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef,
11111107
let size = IntCast(cx, n_bytes, ccx.int_type);
11121108
let align = C_i32(ccx, align as i32);
11131109
let volatile = C_bool(ccx, false);
1114-
Call(cx, memcpy, [dst_ptr, src_ptr, size, align, volatile], []);
1110+
Call(cx, memcpy, [dst_ptr, src_ptr, size, align, volatile], None);
11151111
}
11161112

11171113
pub fn memcpy_ty(bcx: &Block, dst: ValueRef, src: ValueRef, t: ty::t) {
@@ -1156,7 +1152,7 @@ fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
11561152
let size = machine::llsize_of(ccx, ty);
11571153
let align = C_i32(ccx, llalign_of_min(ccx, ty) as i32);
11581154
let volatile = C_bool(ccx, false);
1159-
b.call(llintrinsicfn, [llptr, llzeroval, size, align, volatile], []);
1155+
b.call(llintrinsicfn, [llptr, llzeroval, size, align, volatile], None);
11601156
}
11611157

11621158
pub fn alloc_ty(bcx: &Block, t: ty::t, name: &str) -> ValueRef {
@@ -2040,7 +2036,7 @@ fn register_fn(ccx: &CrateContext,
20402036
}
20412037

20422038
pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
2043-
-> Vec<(uint, u64)> {
2039+
-> llvm::AttrBuilder {
20442040
use middle::ty::{BrAnon, ReLateBound};
20452041

20462042
let (fn_sig, abi, has_env) = match ty::get(fn_ty).sty {
@@ -2056,31 +2052,33 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
20562052
_ => fail!("expected closure or function.")
20572053
};
20582054

2055+
// Since index 0 is the return value of the llvm func, we start
2056+
// at either 1 or 2 depending on whether there's an env slot or not
2057+
let mut first_arg_offset = if has_env { 2 } else { 1 };
2058+
let mut attrs = llvm::AttrBuilder::new();
2059+
let ret_ty = fn_sig.output;
2060+
20592061
// These have an odd calling convention, so we skip them for now.
20602062
//
20612063
// FIXME(pcwalton): We don't have to skip them; just untuple the result.
20622064
if abi == RustCall {
2063-
return Vec::new()
2065+
return attrs;
20642066
}
20652067

2066-
// Since index 0 is the return value of the llvm func, we start
2067-
// at either 1 or 2 depending on whether there's an env slot or not
2068-
let mut first_arg_offset = if has_env { 2 } else { 1 };
2069-
let mut attrs = Vec::new();
2070-
let ret_ty = fn_sig.output;
2071-
20722068
// A function pointer is called without the declaration
20732069
// available, so we have to apply any attributes with ABI
20742070
// implications directly to the call instruction. Right now,
20752071
// the only attribute we need to worry about is `sret`.
20762072
if type_of::return_uses_outptr(ccx, ret_ty) {
2077-
attrs.push((1, llvm::StructRetAttribute as u64));
2073+
let llret_sz = llsize_of_real(ccx, type_of::type_of(ccx, ret_ty));
20782074

20792075
// The outptr can be noalias and nocapture because it's entirely
2080-
// invisible to the program. We can also mark it as nonnull
2081-
attrs.push((1, llvm::NoAliasAttribute as u64));
2082-
attrs.push((1, llvm::NoCaptureAttribute as u64));
2083-
attrs.push((1, llvm::NonNullAttribute as u64));
2076+
// invisible to the program. We also know it's nonnull as well
2077+
// as how many bytes we can dereference
2078+
attrs.arg(1, llvm::StructRetAttribute)
2079+
.arg(1, llvm::NoAliasAttribute)
2080+
.arg(1, llvm::NoCaptureAttribute)
2081+
.arg(1, llvm::DereferenceableAttribute(llret_sz));
20842082

20852083
// Add one more since there's an outptr
20862084
first_arg_offset += 1;
@@ -2094,27 +2092,28 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
20942092
ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
20952093
} => {}
20962094
ty::ty_uniq(_) => {
2097-
attrs.push((llvm::ReturnIndex as uint, llvm::NoAliasAttribute as u64));
2095+
attrs.ret(llvm::NoAliasAttribute);
20982096
}
20992097
_ => {}
21002098
}
21012099

2102-
// We can also mark the return value as `nonnull` in certain cases
2100+
// We can also mark the return value as `dereferenceable` in certain cases
21032101
match ty::get(ret_ty).sty {
21042102
// These are not really pointers but pairs, (pointer, len)
21052103
ty::ty_uniq(it) |
21062104
ty::ty_rptr(_, ty::mt { ty: it, .. }) if match ty::get(it).sty {
21072105
ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
21082106
} => {}
2109-
ty::ty_uniq(_) | ty::ty_rptr(_, _) => {
2110-
attrs.push((llvm::ReturnIndex as uint, llvm::NonNullAttribute as u64));
2107+
ty::ty_uniq(inner) | ty::ty_rptr(_, ty::mt { ty: inner, .. }) => {
2108+
let llret_sz = llsize_of_real(ccx, type_of::type_of(ccx, inner));
2109+
attrs.ret(llvm::DereferenceableAttribute(llret_sz));
21112110
}
21122111
_ => {}
21132112
}
21142113

21152114
match ty::get(ret_ty).sty {
21162115
ty::ty_bool => {
2117-
attrs.push((llvm::ReturnIndex as uint, llvm::ZExtAttribute as u64));
2116+
attrs.ret(llvm::ZExtAttribute);
21182117
}
21192118
_ => {}
21202119
}
@@ -2124,44 +2123,77 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
21242123
match ty::get(t).sty {
21252124
// this needs to be first to prevent fat pointers from falling through
21262125
_ if !type_is_immediate(ccx, t) => {
2126+
let llarg_sz = llsize_of_real(ccx, type_of::type_of(ccx, t));
2127+
21272128
// For non-immediate arguments the callee gets its own copy of
21282129
// the value on the stack, so there are no aliases. It's also
21292130
// program-invisible so can't possibly capture
2130-
attrs.push((idx, llvm::NoAliasAttribute as u64));
2131-
attrs.push((idx, llvm::NoCaptureAttribute as u64));
2132-
attrs.push((idx, llvm::NonNullAttribute as u64));
2131+
attrs.arg(idx, llvm::NoAliasAttribute)
2132+
.arg(idx, llvm::NoCaptureAttribute)
2133+
.arg(idx, llvm::DereferenceableAttribute(llarg_sz));
21332134
}
2135+
21342136
ty::ty_bool => {
2135-
attrs.push((idx, llvm::ZExtAttribute as u64));
2137+
attrs.arg(idx, llvm::ZExtAttribute);
21362138
}
2139+
21372140
// `~` pointer parameters never alias because ownership is transferred
2138-
ty::ty_uniq(_) => {
2139-
attrs.push((idx, llvm::NoAliasAttribute as u64));
2140-
attrs.push((idx, llvm::NonNullAttribute as u64));
2141+
ty::ty_uniq(inner) => {
2142+
let llsz = llsize_of_real(ccx, type_of::type_of(ccx, inner));
2143+
2144+
attrs.arg(idx, llvm::NoAliasAttribute)
2145+
.arg(idx, llvm::DereferenceableAttribute(llsz));
2146+
}
2147+
2148+
// The visit glue deals only with opaque pointers so we don't
2149+
// actually know the concrete type of Self thus we don't know how
2150+
// many bytes to mark as dereferenceable so instead we just mark
2151+
// it as nonnull which still holds true
2152+
ty::ty_rptr(b, ty::mt { ty: it, mutbl }) if match ty::get(it).sty {
2153+
ty::ty_param(_) => true, _ => false
2154+
} && mutbl == ast::MutMutable => {
2155+
attrs.arg(idx, llvm::NoAliasAttribute)
2156+
.arg(idx, llvm::NonNullAttribute);
2157+
2158+
match b {
2159+
ReLateBound(_, BrAnon(_)) => {
2160+
attrs.arg(idx, llvm::NoCaptureAttribute);
2161+
}
2162+
_ => {}
2163+
}
21412164
}
2165+
21422166
// `&mut` pointer parameters never alias other parameters, or mutable global data
21432167
// `&` pointer parameters never alias either (for LLVM's purposes) as long as the
21442168
// interior is safe
21452169
ty::ty_rptr(b, mt) if mt.mutbl == ast::MutMutable ||
21462170
!ty::type_contents(ccx.tcx(), mt.ty).interior_unsafe() => {
2147-
attrs.push((idx, llvm::NoAliasAttribute as u64));
2148-
attrs.push((idx, llvm::NonNullAttribute as u64));
2171+
2172+
let llsz = llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
2173+
attrs.arg(idx, llvm::NoAliasAttribute)
2174+
.arg(idx, llvm::DereferenceableAttribute(llsz));
2175+
21492176
match b {
21502177
ReLateBound(_, BrAnon(_)) => {
2151-
attrs.push((idx, llvm::NoCaptureAttribute as u64));
2178+
attrs.arg(idx, llvm::NoCaptureAttribute);
21522179
}
21532180
_ => {}
21542181
}
21552182
}
2183+
21562184
// When a reference in an argument has no named lifetime, it's impossible for that
21572185
// reference to escape this function (returned or stored beyond the call by a closure).
2158-
ty::ty_rptr(ReLateBound(_, BrAnon(_)), _) => {
2159-
attrs.push((idx, llvm::NoCaptureAttribute as u64));
2160-
attrs.push((idx, llvm::NonNullAttribute as u64));
2186+
ty::ty_rptr(ReLateBound(_, BrAnon(_)), mt) => {
2187+
let llsz = llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
2188+
attrs.arg(idx, llvm::NoCaptureAttribute)
2189+
.arg(idx, llvm::DereferenceableAttribute(llsz));
21612190
}
2162-
// & pointer parameters are never null
2163-
ty::ty_rptr(_, _) => {
2164-
attrs.push((idx, llvm::NonNullAttribute as u64));
2191+
2192+
// & pointer parameters are also never null and we know exactly how
2193+
// many bytes we can dereference
2194+
ty::ty_rptr(_, mt) => {
2195+
let llsz = llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
2196+
attrs.arg(idx, llvm::DereferenceableAttribute(llsz));
21652197
}
21662198
_ => ()
21672199
}

0 commit comments

Comments
 (0)