Daniel Micay
f2932e4661
make small (<= size_of::<int>()) enums immediate
...
C-like enums are excluded from this for now, because the code paths
specific to them need to be changed.
fn foo() -> Option<~int> { Some(~5) }
Before:
; Function Attrs: uwtable
define void @_ZN3foo18hdec6e36682b87eeaf4v0.0E(%"enum.std::option::Option<~int>[#1 ]"* noalias nocapture sret, { i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone) #0 {
"function top level":
%2 = tail call %"enum.std::libc::types::common::c95::c_void[#1 ]"* @"_ZN2rt11global_heap10malloc_raw17h56c543b77f9b78aY11v0.9$x2dpreE"({ i64, %tydesc*, i8*, i8*, i8 }* undef, i64 8)
%3 = bitcast %"enum.std::libc::types::common::c95::c_void[#1 ]"* %2 to i64*
store i64 5, i64* %3, align 8
%4 = getelementptr inbounds %"enum.std::option::Option<~int>[#1 ]"* %0, i64 0, i32 0
store i64* %3, i64** %4, align 8
ret void
}
After:
; Function Attrs: uwtable
define %"enum.std::option::Option<~int>[#1 ]" @_ZN3foo18h2cbf6557a3143edah4v0.0E({ i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone) #0 {
"function top level":
%1 = tail call %"enum.std::libc::types::common::c95::c_void[#1 ]"* @"_ZN2rt11global_heap10malloc_raw18hb1e9dd1beab35edau11v0.9$x2dpreE"({ i64, %tydesc*, i8*, i8*, i8 }* undef, i64 8)
%2 = bitcast %"enum.std::libc::types::common::c95::c_void[#1 ]"* %1 to i64*
store i64 5, i64* %2, align 8
%oldret = insertvalue %"enum.std::option::Option<~int>[#1 ]" undef, i64* %2, 0
ret %"enum.std::option::Option<~int>[#1 ]" %oldret
}
2013-10-02 10:02:52 -04:00
Daniel Micay
abe648d608
treat uninhabited enums as voidish
2013-10-02 10:02:52 -04:00
bors
33a5928b46
auto merge of #9656 : thestinger/rust/immediate, r=alexcrichton
...
fn foo() -> (u32, u8, u8, u8, u8) {
(4, 5, 6, 7, 8)
}
Before:
; Function Attrs: nounwind uwtable
define void @_ZN3foo18hbb616262f874f8daf4v0.0E({ i32, i8, i8, i8, i8 }* noalias nocapture sret, { i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone) #0 {
"function top level":
%2 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 0
store i32 4, i32* %2, align 4
%3 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 1
store i8 5, i8* %3, align 4
%4 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 2
store i8 6, i8* %4, align 1
%5 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 3
store i8 7, i8* %5, align 2
%6 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 4
store i8 8, i8* %6, align 1
ret void
}
After:
; Function Attrs: nounwind readnone uwtable
define { i32, i8, i8, i8, i8 } @_ZN3foo18hbb616262f874f8daf4v0.0E({ i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone) #0 {
"function top level":
ret { i32, i8, i8, i8, i8 } { i32 4, i8 5, i8 6, i8 7, i8 8 }
}
2013-10-01 21:56:27 -07:00
bors
fe4e7478c5
auto merge of #9560 : pcwalton/rust/xc-tuple-structs, r=pcwalton
...
r? @thestinger
2013-10-01 15:06:25 -07:00
Patrick Walton
76d92c5472
librustc: Inline cross-crate tuple struct constructors
2013-10-01 14:24:34 -07:00
Daniel Micay
c9d4ad07c4
remove the float
type
...
It is simply defined as `f64` across every platform right now.
A use case hasn't been presented for a `float` type defined as the
highest precision floating point type implemented in hardware on the
platform. Performance-wise, using the smallest precision correct for the
use case greatly saves on cache space and allows for fitting more
numbers into SSE/AVX registers.
If there was a use case, this could be implemented as simply a type
alias or a struct thanks to `#[cfg(...)]`.
Closes #6592
The mailing list thread, for reference:
https://mail.mozilla.org/pipermail/rust-dev/2013-July/004632.html
2013-10-01 14:54:10 -04:00
Daniel Micay
5e4ae4f45f
make small (<= size_of::<int>()) tuples immediate
...
fn foo() -> (u32, u8, u8, u8, u8) {
(4, 5, 6, 7, 8)
}
Before:
; Function Attrs: nounwind uwtable
define void @_ZN3foo18hbb616262f874f8daf4v0.0E({ i32, i8, i8, i8, i8 }* noalias nocapture sret, { i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone) #0 {
"function top level":
%2 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 0
store i32 4, i32* %2, align 4
%3 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 1
store i8 5, i8* %3, align 4
%4 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 2
store i8 6, i8* %4, align 1
%5 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 3
store i8 7, i8* %5, align 2
%6 = getelementptr inbounds { i32, i8, i8, i8, i8 }* %0, i64 0, i32 4
store i8 8, i8* %6, align 1
ret void
}
After:
; Function Attrs: nounwind readnone uwtable
define { i32, i8, i8, i8, i8 } @_ZN3foo18hbb616262f874f8daf4v0.0E({ i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone) #0 {
"function top level":
ret { i32, i8, i8, i8, i8 } { i32 4, i8 5, i8 6, i8 7, i8 8 }
}
2013-10-01 02:57:59 -04:00
Alex Crichton
1b80558be3
rustc: Remove usage of fmt!
2013-09-30 23:21:19 -07:00
Daniel Micay
ab0a884a73
fix dropping non-primitive immediates
...
Closes #9446
2013-10-01 00:38:37 -04:00
Daniel Micay
11b7109b7b
rm only use of type_is_immediate outside of trans
2013-09-30 18:16:35 -04:00
bors
5011bbfbb6
auto merge of #9630 : blake2-ppc/rust/de-at-smaller, r=huonw
...
This is mostly an incremental change, picking off some uses of
@- or @mut-pointers that can be replaced by references.
Almost all of the builder functions in trans::build are updated,
mostly using `&Block` arguments instead of `@mut Block`.
2013-09-30 10:41:20 -07:00
blake2-ppc
f4d8d8c122
trans::build: Change @mut Block to &Block or &mut Block
...
Use &mut Block and &Block references where possible in the builder
functions in trans::build.
@mut Block remains in a few functions where I could not (not yet at
least) track down the runtime borrowck failures.
2013-09-30 19:37:22 +02:00
blake2-ppc
b88517ec93
trans: Change @ast::Pat and @mut CrateContext in a few places
...
Use borrowed references in a few locations that were encountered when
working on other changes.
2013-09-30 19:37:17 +02:00
blake2-ppc
948b5ab87a
trans: Change @ast::Expr -> &ast::Expr where possible
2013-09-30 19:37:17 +02:00
Alex Crichton
7b18976f08
Remove all usage of @ast::Crate
2013-09-29 16:21:25 -07:00
bors
10e7f12daf
auto merge of #9550 : alexcrichton/rust/remove-printf, r=thestinger
...
The 0.8 release was cut, down with printf!
2013-09-27 08:21:23 -07:00
bors
01313a131b
auto merge of #9548 : thestinger/rust/internal, r=alexcrichton
...
Closes #9494
2013-09-27 06:21:22 -07:00
bors
ae8a2ff379
auto merge of #9538 : thestinger/rust/type_use, r=pcwalton
...
This is broken, and results in poor performance due to the undefined
behaviour in the LLVM IR. LLVM's `mergefunc` is a *much* better way of
doing this since it merges based on the equality of the bytecode.
For example, consider `std::repr`. It generates different code per
type, but is not included in the type bounds of generics.
The `mergefunc` pass works for most of our code but currently hits an
assert on libstd. It is receiving attention upstream so it will be
ready soon, but I don't think removing this broken code should wait any
longer. I've opened #9536 about enabling it by default.
Closes #8651
Closes #3547
Closes #2537
Closes #6971
Closes #9222
2013-09-27 03:31:13 -07:00
Erick Tryzelaar
4834661c66
std and rustc: Convert users of c_str to use .with_c_str
2013-09-26 22:20:39 -07:00
Alex Crichton
409182de6d
Update the compiler to not use printf/printfln
2013-09-26 17:05:59 -07:00
Daniel Micay
2aadd3652d
mark globals as internal when not building a library
...
Closes #9494
2013-09-26 19:21:22 -04:00
Daniel Micay
c3e4e06841
remove type_use
...
This is broken, and results in poor performance due to the undefined
behaviour in the LLVM IR. LLVM's `mergefunc` is a *much* better way of
doing this since it merges based on the equality of the bytecode.
For example, consider `std::repr`. It generates different code per
type, but is not included in the type bounds of generics.
The `mergefunc` pass works for most of our code but currently hits an
assert on libstd. It is receiving attention upstream so it will be
ready soon, but I don't think removing this broken code should wait any
longer. I've opened #9536 about enabling it by default.
Closes #8651
Closes #3547
Closes #2537
Closes #6971
Closes #9222
2013-09-26 17:27:23 -04:00
Alex Crichton
daee1b4d5c
Ensure that skipped items aren't encoded
...
If an item is skipped due to it being unreachable or for some optimization, then
it shouldn't be encoded into the metadata (because it wasn't present in the
first place).
2013-09-26 13:54:50 -07:00
bors
5375cf8718
auto merge of #9491 : thestinger/rust/noreturn, r=huonw
...
Closes #9317
2013-09-25 07:25:56 -07:00
bors
797a373cd1
auto merge of #9492 : pnkfelix/rust/fsk-syntax-visit-refactor-remainder, r=huonw
...
r? anyone
Part of #7081 .
Removed many unnecessary context arguments, turning them into visitors. Removed some @allocation.
If this lands, then I think the only thing left that is unaddressed are:
* the various lint visitors, and
* middle/privacy.rs, which has `impl<'self> Visitor<&'self method_map> for PrivacyVisitor`
2013-09-25 06:10:57 -07:00
Felix S. Klock II
9d0727736b
Fold context into CalleeTranslationVisitor.
2013-09-25 10:59:06 +02:00
Felix S. Klock II
2ceebf1070
Fold context into TransItemVisitor.
2013-09-25 10:58:40 +02:00
Felix S. Klock II
411dce85ea
Fold type_use.rs Context into its Visitor.
2013-09-25 10:55:50 +02:00
Daniel Micay
e76bfae7eb
add noreturn
attribute to functions returning !
...
Closes #9317
2013-09-25 04:45:29 -04:00
bors
4531184614
auto merge of #9432 : alexcrichton/rust/correct-item-visibility, r=pcwalton
...
This fixes private statics and functions from being usable cross-crates, along
with some bad privacy error messages. This is a reopening of #8365 with all the
privacy checks in privacy.rs instead of resolve.rs (where they should be
anyway).
These maps of exported items will hopefully get used for generating
documentation by rustdoc
Closes #8592
2013-09-25 00:55:53 -07:00
bors
d7bb40c50c
auto merge of #9470 : luqmana/rust/bba, r=brson
...
#8431
~~@brson: do we need to bump up the cratemap version for this change?~~ Tis a no.
2013-09-24 20:25:58 -07:00
Luqman Aden
90e009f9b6
Remove the annihilate function from the crate map. Fixes #8431
2013-09-24 20:34:11 -04:00
Daniel Micay
5867bbd794
mark functions internal if not building a library
...
the entry point is wrapped with what should be the only public function
2013-09-24 18:50:28 -04:00
Alex Crichton
10a583ce1a
Correctly encode item visibility in metadata
...
This fixes private statics and functions from being usable cross-crates, along
with some bad privacy error messages. This is a reopening of #8365 with all the
privacy checks in privacy.rs instead of resolve.rs (where they should be
anyway).
These maps of exported items will hopefully get used for generating
documentation by rustdoc
Closes #8592
2013-09-24 09:57:25 -07:00
Patrick Walton
3b1d3e5bf8
librustc: Fix merge fallout.
2013-09-23 18:23:23 -07:00
Patrick Walton
68ea9aed96
librustc: Remove @fn
managed closures from the language.
2013-09-23 18:23:21 -07:00
Patrick Walton
7796d519f9
librustc: Don't use garbage-collected closures to store cleanups.
2013-09-23 18:23:19 -07:00
Patrick Walton
16e87cb527
librustc: Make the fall-through case in match not use garbage collected functions
2013-09-23 18:23:18 -07:00
bors
9705399504
auto merge of #9301 : luqmana/rust/ncm, r=brson
...
Get rid of the crate_map arg!
r? @brson
2013-09-23 15:46:05 -07:00
Luqman Aden
20a10ff9c9
Find the cratemap at runtime on windows.
2013-09-23 18:26:16 -04:00
bors
89cc8529cc
auto merge of #9332 : eugals/rust/master, r=alexcrichton
...
It is intended to optimize/beautify the code generated in a few trivial trait operations.
Let's take the following code as an example:
```
trait Stuff {
fn bar(&self);
}
fn callBar(s: &Stuff) {
s.bar();
}
struct Foo;
impl Stuff for Foo {
fn bar(&self) {
}
}
pub fn main() {
let o = Foo;
callBar(&o as &Stuff);
}
```
At present it is translated into something like:
```
define void @_ZN7callBar_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }*, { %tydesc*, i8* }*) #4 {
"function top level":
%__trait_callee = alloca { %tydesc*, i8* }
%__auto_borrow_obj = alloca { %tydesc*, i8* }
%2 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
%3 = load %tydesc** %2
%4 = getelementptr inbounds { %tydesc*, i8* }* %__auto_borrow_obj, i32 0, i32 0
store %tydesc* %3, %tydesc** %4
%5 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
%6 = load i8** %5
%7 = getelementptr inbounds { %tydesc*, i8* }* %__auto_borrow_obj, i32 0, i32 1
store i8* %6, i8** %7
%8 = bitcast { %tydesc*, i8* }* %__auto_borrow_obj to i8*
%9 = bitcast { %tydesc*, i8* }* %__trait_callee to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %9, i8* %8, i32 8, i32 4, i1 false)
%10 = getelementptr inbounds { %tydesc*, i8* }* %__trait_callee, i32 0, i32 1
%11 = load i8** %10
%12 = bitcast i8* %11 to { i32, %tydesc*, i8*, i8*, i8 }*
%13 = getelementptr inbounds { %tydesc*, i8* }* %__trait_callee, i32 0, i32 0
%14 = bitcast %tydesc** %13 to [1 x i8*]**
%15 = load [1 x i8*]** %14
%16 = getelementptr inbounds [1 x i8*]* %15, i32 0, i32 1
%17 = load i8** %16
%18 = bitcast i8* %17 to void ({ i32, %tydesc*, i8*, i8*, i8 }*)*
call void %18({ i32, %tydesc*, i8*, i8*, i8 }* %12)
ret void
}
...
define void @_ZN4main_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }*) #4 {
"function top level":
%o = alloca %struct.Foo
%1 = alloca { %tydesc*, i8* }
%__auto_borrow_obj = alloca { %tydesc*, i8* }
%2 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
%3 = bitcast i8** %2 to %struct.Foo**
store %struct.Foo* %o, %struct.Foo** %3
%4 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
%5 = bitcast %tydesc** %4 to { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }**
store { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }* @vtable1081, { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }** %5
%6 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
%7 = load %tydesc** %6
%8 = getelementptr inbounds { %tydesc*, i8* }* %__auto_borrow_obj, i32 0, i32 0
store %tydesc* %7, %tydesc** %8
%9 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
%10 = load i8** %9
%11 = getelementptr inbounds { %tydesc*, i8* }* %__auto_borrow_obj, i32 0, i32 1
store i8* %10, i8** %11
call void @_ZN7callBar_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }* undef, { %tydesc*, i8* }* %__auto_borrow_obj)
ret void
}
```
If you apply my patch, it would become way shorter and cleaner:
```
define void @_ZN7callBar_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }*, { %tydesc*, i8* }*) #4 {
"function top level":
%2 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
%3 = load i8** %2
%4 = bitcast i8* %3 to { i32, %tydesc*, i8*, i8*, i8 }*
%5 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
%6 = bitcast %tydesc** %5 to [1 x i8*]**
%7 = load [1 x i8*]** %6
%8 = getelementptr inbounds [1 x i8*]* %7, i32 0, i32 1
%9 = load i8** %8
%10 = bitcast i8* %9 to void ({ i32, %tydesc*, i8*, i8*, i8 }*)*
call void %10({ i32, %tydesc*, i8*, i8*, i8 }* %4)
ret void
}
...
define void @_ZN4main_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }*) #4 {
"function top level":
%o = alloca %struct.Foo
%1 = alloca { %tydesc*, i8* }
%2 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
%3 = bitcast i8** %2 to %struct.Foo**
store %struct.Foo* %o, %struct.Foo** %3
%4 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
%5 = bitcast %tydesc** %4 to { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }**
store { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }* @vtable1081, { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }** %5
call void @_ZN7callBar_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }* undef, { %tydesc*, i8* }* %1)
ret void
}
```
Although this change doesn't increase the compilation speed much (I mentioned only about 1-2% boost on "rustc -O -Z time-passes syntax.rs"), but I still think it's a good thing to do as it greatly simplifies/clarifies LL generated in some cases which would definitely help in the future code generation investigations.
I don't provide any new test cases in this patch as it is merely an optimization.
Sorry guys, I somehow messed my previous PR and I don't see any better way to fix as to recreate it here.
2013-09-20 07:06:13 -07:00
U-NOV2010\eugals
0c3b6ad6b8
will not copy trait_callee on stack if it's source expr is a plain borrowed ref
2013-09-19 18:34:30 +04:00
U-NOV2010\eugals
dfa3f5fa8d
minor Type::opaque_trait code cleanup
2013-09-19 18:34:26 +04:00
U-NOV2010\eugals
2927ab13df
optimized trans_to_datum::auto_borrow_obj code generation in case some trivial cases where simple copying can be applied
2013-09-19 18:34:23 +04:00
Chris Morgan
e2807a4565
Replace unreachable() calls with unreachable!().
...
This is the second of two parts of #8991 , now possible as a new snapshot
has been made. (The first part implemented the unreachable!() macro; it
was #8992 , 6b7b8f2682.)
``std::util::unreachable()`` is removed summarily; any code which used
it should now use the ``unreachable!()`` macro.
Closes #9312 .
Closes #8991 .
2013-09-19 15:04:03 +10:00
bors
8f65529627
auto merge of #9284 : thestinger/rust/main, r=luqmana
...
the real entry point will now pass the user's main function directly to
the scheduler
2013-09-18 15:05:56 -07:00
Luqman Aden
133200a6e2
libstd/librustc: Make the crate_map a weak symbol that libstd links against.
2013-09-18 17:44:04 -04:00
Luqman Aden
9621156fc3
librustc/libstd: No longer pass crate_map to start.
2013-09-18 16:51:27 -04:00
Alex Crichton
817576ee70
Register new snapshots
2013-09-18 11:07:22 -07:00
bors
9e636f106d
auto merge of #9272 : luqmana/rust/esln, r=catamorphism
...
Fixes #9270
2013-09-18 06:45:53 -07:00