Commit Graph

384 Commits

Author SHA1 Message Date
bors
b355906919 Auto merge of #51131 - qnighy:unsized-locals, r=eddyb
Implement Unsized Rvalues

This PR is the first step to implement RFC1909: unsized rvalues (#48055).

## Implemented

- `Sized` is removed for arguments and local bindings. (under `#![feature(unsized_locals)]`)
- Unsized locations are allowed in MIR
- Unsized places and operands are correctly translated at codegen

## Not implemented in this PR

- Additional `Sized` checks:
  - tuple struct constructor (accidentally compiles now)
  - closure arguments at closure generation (accidentally compiles now)
  - upvars (ICEs now)
- Generating vtable for `fn method(self)` (ICEs now)
- VLAs: `[e; n]` where `n` isn't const
- Reduce unnecessary allocations

## Current status

- [x] Fix `__rust_probestack` (rust-lang-nursery/compiler-builtins#244)
  - [x] Get the fix merged
- [x] `#![feature(unsized_locals)]`
  - [x] Give it a tracking issue number
- [x] Lift sized checks in typeck and MIR-borrowck
  - [ ] <del>Forbid `A(unsized-expr)`</del> will be another PR
- [x] Minimum working codegen
- [x] Add more examples and fill in unimplemented codegen paths
- [ ] <del>Loosen object-safety rules (will be another PR)</del>
- [ ] <del>Implement `Box<FnOnce>` (will be another PR)</del>
- [ ] <del>Reduce temporaries (will be another PR)</del>
2018-08-19 12:21:56 +00:00
Jorge Aparicio
98e4cd50f9 fix: use detected MSVC's link.exe 2018-08-19 12:35:58 +02:00
Jorge Aparicio
c8ef8b6602 LinkerFlavor::Gcc defaults to cc, not gcc 2018-08-19 09:39:19 +02:00
Masaki Hara
c488d59add Integrate OperandValue::UnsizedRef into OperandValue::Ref. 2018-08-19 08:07:33 +09:00
Masaki Hara
6e15e7c126 Integrate PassMode::UnsizedIndirect into PassMode::Indirect. 2018-08-19 08:07:33 +09:00
Masaki Hara
800f2c13a3 Implement simple codegen for unsized rvalues. 2018-08-19 08:07:33 +09:00
Masaki Hara
cd0476a390 Add Builder::array_alloca. 2018-08-19 08:06:42 +09:00
bors
a9fe312b98 Auto merge of #52592 - eddyb:or-default, r=Mark-Simulacrum
Use the new Entry::or_default method where possible.
2018-08-18 21:58:37 +00:00
Eduard-Mihai Burtescu
14aed81d9a Use the new Entry::or_default method where possible. 2018-08-18 20:19:45 +03:00
Jorge Aparicio
cafeb6f05b fatal -> bug 2018-08-18 17:19:42 +02:00
bors
a3ad012e2d Auto merge of #53286 - nagisa:cast-assumes, r=eddyb
Do not generate assumes for plain integer casts

I gave up on making anything more elegant for now.

r? @eddyb
2018-08-18 14:35:42 +00:00
Jorge Aparicio
750e72b9e0 add lld_flavor info to target spec
this field defaults to the LD / GNU flavor
2018-08-18 16:31:36 +02:00
bjorn3
d52047faf0 Remove LinkMeta struct 2018-08-18 12:08:06 +02:00
bors
6b1ff19af3 Auto merge of #53437 - alexcrichton:fix-target-features, r=michaelwoerister
Set more llvm function attributes for __rust_try

This shim is generated elsewhere in the compiler so this commit adds support to
ensure it goes through similar paths as the rest of the compiler to set llvm
function attributes like target features.

cc #53372
2018-08-18 02:50:39 +00:00
bors
1fa944914c Auto merge of #53356 - michaelwoerister:itlto, r=alexcrichton
Preliminary work for incremental ThinLTO (CGU name edition)

Bring back the first half of #52266 but hopefully without the performance regression.
2018-08-17 21:24:22 +00:00
Alex Crichton
31884427eb Set more llvm function attributes for __rust_try
This shim is generated elsewhere in the compiler so this commit adds support to
ensure it goes through similar paths as the rest of the compiler to set llvm
function attributes like target features.

cc #53372
2018-08-16 13:23:35 -07:00
Alex Crichton
ed39cc074a wasm: Remove --strip-debug argument to LLD
Originally added in #52887 this commit disables passing `--strip-debug` to LLD
when optimized. This bring back the original bug of emitting broken debuginfo
but currently it *also* strips the `name` section which makes it very difficult
to inspect the final binary. A real fix is happening at
https://reviews.llvm.org/D50729 and we can reevaluate once we've updated LLD to
have that commit.
2018-08-16 10:17:06 -07:00
bors
0f4b4987cd Auto merge of #53237 - overdrivenpotato:wasm-export-table, r=alexcrichton
Export WASM table by default

This allows loading a rust-generated `.wasm` binary in a host and using the exported table much like the `memory` export.
2018-08-15 14:40:46 +00:00
Michael Woerister
d662083a6c Use CGU name as LLVM module name and add some caching to CGU name generation. 2018-08-15 14:50:54 +02:00
kennytm
47f66e7372
Rollup merge of #53290 - whitequark:fix-35741, r=nagisa
Make LLVM emit assembly comments with -Z asm-comments

Fixes #35741, and makes `-Z asm-comments` actually do something useful.

Before:
```
	.section	.text.main,"ax",@progbits
	.globl	main
	.p2align	4, 0x90
	.type	main,@function
main:
	.cfi_startproc
	pushq	%rax
	.cfi_def_cfa_offset 16
	movslq	%edi, %rax
	leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
	movq	%rsi, (%rsp)
	movq	%rax, %rsi
	movq	(%rsp), %rdx
	callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
	movl	%eax, %ecx
	movl	%ecx, %eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	main, .Lfunc_end8-main
	.cfi_endproc
```

After:
```
	.section	.text.main,"ax",@progbits
	.globl	main                    # -- Begin function main
	.p2align	4, 0x90
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movslq	%edi, %rax
	leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
	movq	%rsi, (%rsp)            # 8-byte Spill
	movq	%rax, %rsi
	movq	(%rsp), %rdx            # 8-byte Reload
	callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
	movl	%eax, %ecx
	movl	%ecx, %eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	main, .Lfunc_end8-main
	.cfi_endproc
                                        # -- End function
```
2018-08-14 23:59:16 +08:00
kennytm
e862efa65d
Rollup merge of #53274 - bjorn3:remove_statics_field, r=nagisa
Remove statics field from CodegenCx

It doesnt seem to be used anywhere.
2018-08-14 23:59:15 +08:00
kennytm
764755b0b0
Rollup merge of #53239 - cuviper:llvm5-closure-alloca, r=eddyb
rustc_codegen_llvm: Restore the closure env alloca hack for LLVM 5.

This hack was removed in #50949, but without it I found that building
`std` with full debuginfo would print many LLVM `DW_OP_LLVM_fragment`
errors, then die `LLVM ERROR: Failed to strip malformed debug info`.

It doesn't seem to be a problem for LLVM 6, so we can re-enable the hack
just for older LLVM.

This reverts commit da579ef75e.
Fixes #53204.
r? @eddyb
2018-08-14 23:59:11 +08:00
bors
a78ae85e59 Auto merge of #53161 - michaelwoerister:cstrings, r=wesleywiser
Avoid many allocations for CStrings during codegen.

Giving in to my irrational fear of dynamic allocations. Let's see what perf says to this.
2018-08-13 11:19:07 +00:00
Guillaume Gomez
3e9a1a1b82
Rollup merge of #53230 - memoryruins:nll_bootstrap_4, r=nikomatsakis
[nll] enable feature(nll) on various crates for bootstrap: part 4

#53172

r? @nikomatsakis
2018-08-12 23:26:56 +02:00
whitequark
66fd1ebfae Make LLVM emit assembly comments with -Z asm-comments.
Fixes #35741.
2018-08-12 17:59:33 +00:00
Simonas Kazlauskas
dc02a6070f Do not generate assumes for plain integer casts 2018-08-12 18:38:46 +03:00
bjorn3
44af068388 Remove statics field from CodegenCx 2018-08-11 18:54:36 +02:00
memoryruins
0123ac12e2 [nll] librustc_codegen_llvm: remove unused mut annotation 2018-08-10 06:31:40 -04:00
memoryruins
085535bbe1 [nll] librustc_codegen_llvm: change Child signature to fix error pointed out by nll
As explained by eddyb in #53221, "An &ArchiveChild doesn't point into the archive itself, it points to an owned object that itself points to the archive, and LLVMRustArchiveMemberNew copies the ArchiveChild (whereas the current signature suggests it keeps the &ArchiveChild)."
2018-08-10 06:31:10 -04:00
memoryruins
46b818e276 [nll] librustc_codegen_llvm: enable feature(nll) for bootstrap 2018-08-10 06:28:24 -04:00
Michael Woerister
88d84b38f1 Introduce SmallCStr and use it where applicable. 2018-08-10 11:13:00 +02:00
Michael Woerister
9585c5dc1f Introduce const_cstr!() macro and use it where applicable. 2018-08-10 10:22:44 +02:00
bors
db1acaac7f Auto merge of #53073 - Mark-Simulacrum:data-structures, r=pnkfelix
Cleanup to librustc::session and related code

No functional changes, just some cleanup.

This also creates the `rustc_fs_util` crate, but I can remove that change if desired. It felt a little odd to force crates to depend on librustc for some fs utilities; and also seemed good to generally keep the size of librustc lower (for compile times); fs_util will compile in parallel with essentially the first crate since it has no dependencies beyond std.
2018-08-10 00:14:52 +00:00
Josh Stone
763e72110a rustc_codegen_llvm: Restore the closure env alloca hack for LLVM 5.
This hack was removed in #50949, but without it I found that building
`std` with full debuginfo would print many LLVM `DW_OP_LLVM_fragment`
errors, then die `LLVM ERROR: Failed to strip malformed debug info`.

It doesn't seem to be a problem for LLVM 6, so we can re-enable the hack
just for older LLVM.

This reverts commit da579ef75e.
Fixes #53204.
r? @eddyb
2018-08-09 16:35:25 -07:00
Jorge Aparicio
a0911cf95d address review comments 2018-08-09 17:18:08 -05:00
Jorge Aparicio
eb74f21f5a try to infer linker flavor from linker name and vice versa 2018-08-09 16:08:36 -05:00
Marko Mijalkovic
c7a39b190e Export WASM table by default 2018-08-09 16:19:16 -04:00
bors
8958ed6722 Auto merge of #53216 - kennytm:rollup, r=kennytm
Rollup of 15 pull requests

Successful merges:

 - #52773 (Avoid unnecessary pattern matching against Option and Result)
 - #53082 (Fix doc link (again))
 - #53094 (Automatically expand section if url id point to one of its component)
 - #53106 (atomic ordering docs)
 - #53110 (Account for --remap-path-prefix in save-analysis)
 - #53116 (NetBSD: fix signedess of char)
 - #53179 (Whitelist wasm32 simd128 target feature)
 - #53183 (Suggest comma when missing in macro call)
 - #53207 (Add individual docs for rotate_{left, right})
 - #53211 ([nll] enable feature(nll) on various crates for bootstrap)
 - #53214 ([nll] enable feature(nll) on various crates for bootstrap: part 2)
 - #53215 (Slightly refactor syntax_ext/format)
 - #53217 (inline some short functions)
 - #53219 ([nll] enable feature(nll) on various crates for bootstrap: part 3)
 - #53222 (A few cleanups for rustc_target)
2018-08-09 19:05:14 +00:00
kennytm
7f886cf12b
Rollup merge of #53179 - gnzlbg:patch-3, r=alexcrichton
Whitelist wasm32 simd128 target feature

r? @alexcrichton
2018-08-10 01:01:20 +08:00
Mark Rousskov
bd6fe1e700 Move Fingerprint to data structures 2018-08-09 10:00:25 -06:00
Mark Rousskov
dea13b4bc7 Move path2cstr to rustc_fs_util 2018-08-09 10:00:25 -06:00
Mark Rousskov
e3177c6f3f Move rustc::util::fs into separate (new) crate 2018-08-09 10:00:25 -06:00
bors
b73535f1e9 Auto merge of #53031 - michaelwoerister:cross-lto, r=alexcrichton
Apply some fixes to cross-language LTO (especially when targeting MSVC)

This PR contains a few fixes that were needed in order to get Firefox compiling with Rust/C++ cross-language ThinLTO on Windows. The commits are self-contained and should be self-explanatory.

r? @alexcrichton
2018-08-09 13:20:14 +00:00
Michael Woerister
3a70050377 Address review comments for #53031 and fix some merge fallout. 2018-08-08 13:40:23 +02:00
gnzlbg
5ce865e1c4
Add wasm32 simd128 target feature 2018-08-08 01:39:52 +02:00
Alex Crichton
7c58ab671f rustc: Tweak visibility of some lang items
This commit tweaks the linker-level visibility of some lang items that rustc
uses and defines. Notably this means that `#[panic_implementation]` and
`#[alloc_error_handler]` functions are never marked as `internal`. It's up to
the linker to eliminate these, not rustc.

Additionally `#[global_allocator]` generated symbols are no longer forced to
`Default` visibility (fully exported), but rather they're relaxed to `Hidden`
visibility). This symbols are *not* needed across DLL boundaries, only as a
local implementation detail of the compiler-injected allocator symbols, so
`Hidden` should suffice.

Closes #51342
Closes #52795
2018-08-07 08:42:38 -07:00
Michael Woerister
b27a161939 Annotate functions in LLVM with target-cpu, same as Clang does. 2018-08-07 14:48:20 +02:00
Michael Woerister
f2969ed6c3 Set 'PrepareForThinLTO' whenever doing cross-language LTO. 2018-08-07 14:48:20 +02:00
Michael Woerister
aa9eeff263 Make sure upstream object files are added to staticlibs when compiling
with ThinLTO and cross-lang-lto.

Normally, when compiling with whole-crate-graph ThinLTO, we expect
rustc's LTO step to "uplift" upstream object files/LLVM modules to
the current set of compilation artifacts. Therefore the staticlib
creation code skips this uplifting. However, when compiling with
"cross-language LTO" (i.e. defer LTO to the actual linker), the LTO
step in rustc is not performed, so we have to take care of copying
upstream object files during archive creation (like we already do
when compiling without any LTO).
2018-08-07 14:44:48 +02:00
Michael Woerister
3a3b3317d9 Fix issue around dllimport and ThinLTO as LLD runs it. 2018-08-07 14:44:48 +02:00
kennytm
35d752f130
Rollup merge of #53028 - Mark-Simulacrum:split-out-codegen, r=alexcrichton
Building librustc_codegen_llvm in a separate directory

This allows clearing it out and building it separately from the
compiler. Since it's essentially a different and separate crate this
makes sense to do, each cargo invocation should generally happen in its
own directory.

r? @alexcrichton
2018-08-07 16:55:38 +08:00
bors
11a902431b Auto merge of #51007 - AstralSorcerer:master, r=nagisa
Make globals with private linkage unnamed. Fixes #50862.

cc @oli-obk @nagisa
2018-08-07 02:12:35 +00:00
Mark Rousskov
d8e8a50cf2 Building librustc_codegen_llvm in a separate directory
This allows clearing it out and building it separately from the
compiler. Since it's essentially a different and separate crate this
makes sense to do, each cargo invocation should generally happen in its
own directory.
2018-08-06 07:00:34 -06:00
varkor
c81b95f305 Remove unnecessary feature attributes that sneaked in 2018-08-05 15:54:49 +01:00
Mark Rousskov
a9093a4dd8 Move share_generics getter onto options directly 2018-08-04 06:54:36 -06:00
Mark Rousskov
3cc4450a8a Simplify some handling of target_pointer_width 2018-08-04 06:54:36 -06:00
Mark Rousskov
2bc71971e5 Normalize DebugInfoLevel to standard style 2018-08-04 06:54:34 -06:00
Mark Rousskov
442a4744e3 Normalize EntryFnType variants to standard style 2018-08-04 06:54:12 -06:00
Mark Rousskov
b3267dcb31 Normalize variants of Passes to standard style 2018-08-04 06:53:15 -06:00
Mark Rousskov
2a9344206b Normalize variants of CrateType to standard style
This is a clippy-breaking change.
2018-08-04 06:53:15 -06:00
bors
59fa6bd6c1 Auto merge of #52712 - oli-obk:const_eval_cleanups, r=RalfJung
Reintroduce `Undef` and properly check constant value sizes

r? @RalfJung

cc @eddyb

basically all kinds of silent failures that never occurred are assertions now
2018-08-03 14:28:12 +00:00
bors
88e0ff14a8 Auto merge of #52887 - yurydelendik:disable-lld-symbols, r=alexcrichton
Disable debug sections when optimization flags is set for LLD.

Currently LLD does not error when optimization is set and debugging information sections are present. (See discussion at https://reviews.llvm.org/D47901)

Using `--strip-debug` along with the `-O` option.
2018-08-03 12:22:17 +00:00
Wesley Wiser
45482c6f99 Basic profiling 2018-08-02 18:57:24 -04:00
Oliver Schneider
37e18e7a30 Second field of ScalarPair can be undef in some cases 2018-08-02 13:16:53 +02:00
Pietro Albini
42243f82f4
Rollup merge of #52799 - Mark-Simulacrum:attr-id-bitvecs, r=michaelwoerister
Use BitVector for global sets of AttrId
2018-08-01 21:46:23 +02:00
Oliver Schneider
c6c06854c0 Reintroduce Undef and properly check constant value sizes 2018-08-01 15:29:35 +02:00
Mark Rousskov
9bc4fbb10a Split out growth functionality into BitVector type 2018-08-01 06:50:40 -06:00
Colin Pronovost
3da7c65e92 Make sure we prepare for thin LTO whenever we are emitting bitcode
Emitting LLVM bitcode uses ThinLTOBuffers, so we need to prepare for
thin LTO or we will likely cause errors in LLVM.
2018-08-01 00:27:25 -04:00
Colin Pronovost
02190f397e Make globals with private linkage unnamed. Fixes #50862. 2018-07-31 23:45:18 -04:00
Alex Crichton
f0bceba669 rustc: Handle linker diagnostic from LLVM
Previously linker diagnostic were being hidden when two modules were linked
together but failed to link. This commit fixes the situation by ensuring that we
have a diagnostic handler installed and also adds support for handling linker
diagnostics.
2018-07-31 10:47:27 -07:00
Yury Delendik
e9509d78bd Disable debug sections when optimization flags is set for LLD. 2018-07-30 19:58:26 -05:00
Irina Popa
69ed6b928c rustc_codegen_llvm: fix ownership of DIBuilder. 2018-07-30 20:35:14 +03:00
Irina Popa
54c98ab0dd rustc_codegen_llvm: fix ownership of Builder. 2018-07-30 20:35:11 +03:00
Irina Popa
265f2fa4de rustc_codegen_llvm: fix tidy errors. 2018-07-30 20:35:08 +03:00
Irina Popa
ba006440ee rustc_codegen_llvm: use safe references for ThinLTOData. 2018-07-30 20:34:51 +03:00
Irina Popa
2e3a6af7fa rustc_codegen_llvm: use safe references for ThinLTOBuffer. 2018-07-30 20:10:47 +03:00
Irina Popa
ab4f93c742 rustc_codegen_llvm: use safe references for ModuleBuffer. 2018-07-30 20:10:45 +03:00
Irina Popa
b643e5144e rustc_codegen_llvm: use safe references for RustArchiveMember. 2018-07-30 20:10:44 +03:00
Irina Popa
c7669dff2a rustc_codegen_llvm: use safe references for ArchiveChild. 2018-07-30 20:10:43 +03:00
Irina Popa
e551ed9033 rustc_codegen_llvm: use safe references for ArchiveIterator. 2018-07-30 20:10:42 +03:00
Irina Popa
894467e5b4 rustc_codegen_llvm: use safe references for Linker. 2018-07-30 20:10:41 +03:00
Irina Popa
2c1d7fbb83 rustc_codegen_llvm: use safe references for SectionIterator. 2018-07-30 20:10:39 +03:00
Irina Popa
e22eebaf2b rustc_codegen_llvm: use safe references for PassManager. 2018-07-30 20:10:38 +03:00
Irina Popa
0ab3444540 rustc_codegen_llvm: use safe references for OperandBundleDef. 2018-07-30 20:10:37 +03:00
Irina Popa
92af9694b9 rustc_codegen_llvm: use safe mutable references for output parameters. 2018-07-30 20:10:36 +03:00
Irina Popa
c1eeb69ce8 rustc_codegen_llvm: use safe references for RustString. 2018-07-30 20:10:34 +03:00
Irina Popa
44ae6f1909 rustc_codegen_llvm: use safe references for Twine, DiagnosticInfo, SMDiagnostic. 2018-07-30 20:10:33 +03:00
Irina Popa
41d7d8e35e rustc_codegen_llvm: use safe references for Archive. 2018-07-30 20:10:32 +03:00
Irina Popa
0e3a705269 rustc_codegen_llvm: use safe references for TargetMachine. 2018-07-30 20:10:31 +03:00
Irina Popa
55af020194 rustc_codegen_llvm: use safe references for Pass. 2018-07-30 20:10:30 +03:00
Irina Popa
e9546601a1 rustc_codegen_llvm: use safe references for PassManagerBuilder. 2018-07-30 20:10:29 +03:00
Irina Popa
2f73cef5a3 rustc_codegen_llvm: use safe references for MemoryBuffer and ObjectFile. 2018-07-30 20:10:28 +03:00
Irina Popa
ebec156abf rustc_codegen_llvm: remove more unused functions. 2018-07-30 20:10:25 +03:00
Irina Popa
f224441ed5 rustc_codegen_llvm: remove unused UseRef type. 2018-07-30 19:49:22 +03:00
Irina Popa
3eb50358e4 rustc_codegen_llvm: use safe references for BasicBlock. 2018-07-30 19:49:20 +03:00
Irina Popa
f375185314 rustc_codegen_llvm: use safe references for Value. 2018-07-30 19:49:18 +03:00
Irina Popa
8d17684341 rustc_codegen_llvm: remove _opaque suffix. 2018-07-30 19:32:22 +03:00
Irina Popa
1da26707d6 rustc_codegen_llvm: remove #![allow(dead_code)] from llvm. 2018-07-30 19:32:20 +03:00
Irina Popa
50d764298e rustc_codegen_llvm: remove unused ExecutionEngineRef type. 2018-07-30 19:27:16 +03:00
Irina Popa
eed48f560f rustc_codegen_llvm: use safe references for Metadata and DI*. 2018-07-30 19:27:13 +03:00
Irina Popa
6d0d82ce10 rustc_codegen_llvm: use safe references for DIBuilder. 2018-07-30 18:36:32 +03:00
Irina Popa
2dbde55395 rustc_codegen_llvm: use safe references for Builder. 2018-07-30 18:36:30 +03:00
Irina Popa
d04e66d114 rustc_codegen_llvm: use safe references for Type. 2018-07-30 18:36:29 +03:00
Irina Popa
249d5acaec rustc_codegen_llvm: use safe references for Context and Module. 2018-07-30 18:27:52 +03:00
Irina Popa
af04e9426c rustc_codegen_llvm: move from empty enums to extern types. 2018-07-30 18:12:47 +03:00
Irina Popa
077be49bde rustc_llvm: move to rustc_codegen_llvm::llvm. 2018-07-30 18:03:50 +03:00
bors
7bbcd005b3 Auto merge of #52805 - ljedrz:format_str_literal, r=petrochenkov
Don't format!() string literals

Prefer `to_string()` to `format!()` take 2, this time targetting string literals. In some cases (`&format!("...")` -> `"..."`) also removes allocations. Occurences of `format!("")` are changed to `String::new()`.
2018-07-30 06:29:39 +00:00
bors
866a713258 Auto merge of #52738 - ljedrz:push_to_extend, r=eddyb
Replace push loops with extend() where possible

Or set the vector capacity where I couldn't do it.

According to my [simple benchmark](https://gist.github.com/ljedrz/568e97621b749849684c1da71c27dceb) `extend`ing a vector can be over **10 times** faster than `push`ing to it in a loop:

10 elements (6.1 times faster):
```
test bench_extension ... bench:          75 ns/iter (+/- 23)
test bench_push_loop ... bench:         458 ns/iter (+/- 142)
```

100 elements (11.12 times faster):
```
test bench_extension ... bench:          87 ns/iter (+/- 26)
test bench_push_loop ... bench:         968 ns/iter (+/- 3,528)
```

1000 elements (11.04 times faster):
```
test bench_extension ... bench:         311 ns/iter (+/- 9)
test bench_push_loop ... bench:       3,436 ns/iter (+/- 233)
```

Seems like a good idea to use `extend` as much as possible.
2018-07-29 21:37:47 +00:00
ljedrz
59c8a279da Replace push loops with collect() and extend() where possible 2018-07-29 18:53:22 +02:00
bors
023fd7e74a Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkov
Prefer to_string() to format!()

Simple benchmarks suggest in some cases it can be faster by even 37%:
```
test converting_f64_long  ... bench:         339 ns/iter (+/- 199)
test converting_f64_short ... bench:         136 ns/iter (+/- 34)
test converting_i32_long  ... bench:          87 ns/iter (+/- 16)
test converting_i32_short ... bench:          87 ns/iter (+/- 49)
test converting_str       ... bench:          54 ns/iter (+/- 15)
test formatting_f64_long  ... bench:         349 ns/iter (+/- 176)
test formatting_f64_short ... bench:         145 ns/iter (+/- 14)
test formatting_i32_long  ... bench:          98 ns/iter (+/- 14)
test formatting_i32_short ... bench:          93 ns/iter (+/- 15)
test formatting_str       ... bench:          86 ns/iter (+/- 23)
```
2018-07-29 09:33:37 +00:00
bors
a5c2d0fffa Auto merge of #52764 - sinkuu:cleanup, r=nikomatsakis
Misc cleanups
2018-07-29 06:32:24 +00:00
ljedrz
421b2ba347 Don't format!() string literals 2018-07-28 17:58:52 +02:00
kennytm
7da22148ec
Rollup merge of #52703 - ljedrz:vec_improvements, r=nikomatsakis
Improve a few vectors - calculate capacity or build from iterators

Collecting from iterators improves readability and tailoring vector capacities should be beneficial in terms of performance.
2018-07-28 16:24:57 +08:00
bors
4f1e235744 Auto merge of #52336 - ishitatsuyuki:dyn-rollup, r=Mark-Simulacrum
Rollup of bare_trait_objects PRs

All deny attributes were moved into bootstrap so they can be disabled with a line of config.

Warnings for external tools are allowed and it's up to the tool's maintainer to keep it warnings free.

r? @Mark-Simulacrum
cc @ljedrz @kennytm
2018-07-27 20:27:40 +00:00
Shotaro Yamada
4c1cb7534b Unnecessary to_string 2018-07-27 23:26:36 +09:00
ljedrz
57a5a9b054 Prefer to_string() to format!() 2018-07-27 11:11:18 +02:00
ljedrz
acd38f656a Improve a few vectors - calculate capacity or build from iterators 2018-07-26 21:48:38 +02:00
bors
45b48b9b6d Auto merge of #52735 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 16 pull requests

Successful merges:

 - #52558 (Add tests for ICEs which no longer repro)
 - #52610 (Clarify what a task is)
 - #52617 (Don't match on region kinds when reporting NLL errors)
 - #52635 (Fix #[linkage] propagation though generic functions)
 - #52647 (Suggest to take and ignore args while closure args count mismatching)
 - #52649 (Point spans to inner elements of format strings)
 - #52654 (Format linker args in a way that works for gcc and ld)
 - #52667 (update the stdsimd submodule)
 - #52674 (Impl Executor for Box<E: Executor>)
 - #52690 (ARM: expose `rclass` and `dsp` target features)
 - #52692 (Improve readability in a few sorts)
 - #52695 (Hide some lints which are not quite right the way they are reported to the user)
 - #52718 (State default capacity for BufReader/BufWriter)
 - #52721 (std::ops::Try impl for std::task::Poll)
 - #52723 (rustc: Register crates under their real names)
 - #52734 (sparc ABI issue - structure returning from function is returned in 64bit registers (with tests))

Failed merges:

 - #52678 ([NLL] Use better spans in some errors)

r? @ghost
2018-07-26 17:42:59 +00:00
bors
bfbf8375d7 Auto merge of #52488 - nikomatsakis:nll-issue-48071-universe-and-sub, r=pnkfelix
introduce universes to NLL type check

This branch aims to fix #48071 and also advance chalk integration a bit at the same time. It re-implements the subtyping/type-equating check so that NLL doesn't "piggy back" on the subtyping code of the old type checker.

This new code uses the "universe-based" approach to handling higher-ranked lifetimes, which sidesteps some of the limitations of the current "leak-based" scheme. This avoids the ICE in #48071.

At the same time, I aim for this to potentially be a kind of optimization. This NLL code is (currently) not cached, but it also generates constraints without doing as much instantiation, substitution, and folding. Right now, though, it still piggy backs on the `relate_tys` trait, which is a bit unfortunate -- it means we are doing more hashing and things than we have to. I want to measure the see the perf. Refactoring that trait is something I'd prefer to leave for follow-up work.

r? @pnkfelix -- but I want to measure perf etc first
2018-07-26 15:23:50 +00:00
Mark Rousskov
37835be2e3
Rollup merge of #52690 - paoloteti:rclass-dsp, r=alexcrichton
ARM: expose `rclass` and `dsp` target features

- `dsp`: the subtarget supports the DSP (saturating arith. and such)
         instructions
- `rclass`: target is a Cortex-R

Both features are useful to support ARM MCUs on `coresimd`.

Note: Cortex-R52 is the first Armv8-R with `neon` support.

r? @alexcrichton
cc @japaric
2018-07-26 09:18:35 -06:00
Mark Rousskov
9f91195e2a
Rollup merge of #52654 - alecmocatta:master, r=alexcrichton
Format linker args in a way that works for gcc and ld

Pass multiple linker arguments rather than concatenate with commas (fixes #52634).

`-l library` -> `-llibrary` to work with apple's ld.

To build with apple's ld I'm currently also passing `-C link-args="-arch x86_64 -macosx_version_min 10.13.0"`. I'll try and understand the latter flag better before PRing that.

This PR currently works for me. Hopefully CI will pick up any grievous ramifications in other toolchains?

Thanks to @alexcrichton for the pointer to the relevant code!
2018-07-26 09:18:31 -06:00
Mark Rousskov
c7555cedde
Rollup merge of #52635 - yodaldevoid:issue_18804, r=oli-obk
Fix #[linkage] propagation though generic functions

Fixes #18804

In the non-local branch of `get_static` (where the fix was implemented) `span_fatal` had to be replaced with `bug!` as we have no span in that case.
2018-07-26 09:18:27 -06:00
Paolo Teti
580f437ff2 ARM: expose rclass and dsp target features
- `dsp`: the subtarget supports the DSP (saturating arith. and such)
         instructions
- `rclass`: target is a Cortex-R

Both features are useful to support ARM MCUs on `coresimd`.

Note: Cortex-R52 is the first Armv8-R with `neon` support
2018-07-25 09:27:55 +02:00
Niko Matsakis
145155dc96 parameterize BitVector and BitMatrix by their index types 2018-07-25 06:38:19 +03:00
Tatsuyuki Ishi
e098985939 Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
Gabriel Smith
0bcbe91b48 Deduplicate linkage checking code for statics
Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
2018-07-24 20:17:14 -04:00
Gabriel Smith
a20262c069 Properly set the linkage type on non-local statics
Fixes issue #18804

Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
2018-07-24 20:15:06 -04:00
Mark Rousskov
06ba69d043
Rollup merge of #52391 - Amanieu:volatile_unaligned, r=alexcrichton
Add unaligned volatile intrinsics

Surprisingly enough, it turns out that unaligned volatile loads are actually useful for certain (very niche) types of lock-free code. I included unaligned volatile stores for completeness, but I currently do not know of any use cases for them.

These are only exposed as intrinsics for now. If they turn out to be useful in practice, we can work towards stabilizing them.

r? @alexcrichton
2018-07-24 16:43:44 -06:00
bors
6a3db033ad Auto merge of #52597 - oli-obk:promotion_simplify, r=nagisa
Promoteds are statics and statics have a place, not just a value

r? @eddyb

This makes everything around promoteds a little simpler
2018-07-24 13:10:06 +00:00
alecmocatta
296a179b1c
break --subsystem=x into 2 args; closer to former presumably known-good incantation 2018-07-24 02:11:57 +01:00
alecmocatta
22d0ab0bc3
Pass multiple linker arguments rather than concatenate with commas; -l library -> -llibrary to work with apple's ld 2018-07-24 01:30:43 +01:00
ljedrz
fe588d894f Replace a few expect+format combos with unwrap_or_else+panic 2018-07-23 14:47:13 +02:00
Oliver Schneider
2aab6af0fa Fix tidy 2018-07-23 09:51:30 +02:00
Oliver Schneider
62581b8f0d Explain promoted extraction for simd shuffle 2018-07-23 09:51:30 +02:00
Oliver Schneider
de511438cd Promoteds are statics and statics have a place, not just a value 2018-07-23 09:51:30 +02:00
bors
210d61f05c Auto merge of #52571 - oli-obk:promotion_abort, r=nagisa
Abort if a promoted fails to be const evaluable and its runtime checks didn't trigger

r? @eddyb

cc @RalfJung @nagisa

cc https://github.com/rust-lang/rust/issues/49760
2018-07-23 03:06:08 +00:00
bors
bf7afee52a Auto merge of #52438 - ljedrz:rustc_vec_capacity, r=eddyb
Calculate Vec capacities in librustc

Calculate the required capacity of a few vectors in rustc based on the number of elements they are populated with.
2018-07-21 00:55:46 +00:00
kennytm
7bf3578a39
Rollup merge of #52573 - oli-obk:cleanups, r=RalfJung
Cleanups

r? @RalfJung
2018-07-21 04:08:12 +08:00
kennytm
9a273a3d66
Rollup merge of #52505 - alexcrichton:remove-thinlto-hack, r=nikomatsakis
rustc: Remove a workaround in ThinLTO fixed upstream

This commit removes a hack in our ThinLTO passes which removes available
externally functions manually. The [upstream bug][1] has long since been fixed,
so we should be able to rely on LLVM natively for this now!

[1]: https://bugs.llvm.org/show_bug.cgi?id=35736
2018-07-21 04:08:06 +08:00
ljedrz
e3d14c4c56 Refactor a few push loops to iterators in librustc 2018-07-20 21:57:12 +02:00
Oliver Schneider
7064f69c43 Abort instead of UB if promotion fails 2018-07-20 19:00:48 +02:00
Oliver Schneider
c7d39e0c51 Remove unused method 2018-07-20 18:43:25 +02:00
Alex Crichton
829bc268a9 rustc: Remove a workaroudn in ThinLTO fixed upstream
This commit removes a hack in our ThinLTO passes which removes available
externally functions manually. The [upstream bug][1] has long since been fixed,
so we should be able to rely on LLVM natively for this now!

[1]: https://bugs.llvm.org/show_bug.cgi?id=35736
2018-07-18 11:37:56 -07:00
Alex Crichton
b9024f8a75 rustc: Stabilize #[wasm_import_module] as #[link(...)]
This commit stabilizes the `#[wasm_import_module]` attribute as
`#[link(wasm_import_module = "...")]`. Tracked by #52090 this new directive in
the `#[link]` attribute is used to configured the module name that the imports
are listed with. The WebAssembly specification indicates two utf-8 names are
associated with all imported items, one for the module the item comes from and
one for the item itself. The item itself is configurable in Rust via its
identifier or `#[link_name = "..."]`, but the module name was previously not
configurable and defaulted to `"env"`. This commit ensures that this is also
configurable.

Closes #52090
2018-07-18 07:50:08 -07:00
Alex Crichton
b7ef674832 rustc: Use link_section, not wasm_custom_section
This commit transitions definitions of custom sections on the wasm target from
the unstable `#[wasm_custom_section]` attribute to the
already-stable-for-other-targets `#[link_section]` attribute. Mostly the same
restrictions apply as before, except that this now applies only to statics.

Closes #51088
2018-07-16 09:40:45 -07:00
csmoe
5b0cf56f32 ItemKind 2018-07-16 15:09:17 +02:00
csmoe
7e5d224472 ForeignItemKind 2018-07-16 15:09:17 +02:00
csmoe
fe8955bd58 BinOpKind 2018-07-16 15:09:16 +02:00
Michael Woerister
d992090a70 Revert "Provide a way of accessing the ThinLTO module import map in rustc."
This reverts commit 9df56ca0ee.
2018-07-16 08:59:10 +02:00
Michael Woerister
5c0110f44b Revert "Persist ThinLTO import data in incr. comp. session directory."
This reverts commit 8dc7ddb976.
2018-07-16 08:58:56 +02:00