Commit Graph

81 Commits

Author SHA1 Message Date
Josh Stone df0466d0bb Rebase to the llvm-project monorepo
The new git submodule src/llvm-project is a monorepo replacing src/llvm
and src/tools/{clang,lld,lldb}.  This also serves as a rebase for these
projects to the new 8.x branch from trunk.

The src/llvm-emscripten fork is unchanged for now.
2019-01-25 15:39:54 -08:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Niv Kaminer 897c18235a FIXME(52456) remove fixme and combine all extern items in one block 2018-12-19 10:51:47 +02:00
Nikita Popov 706e67b0a0 Bump minimum required LLVM version to 6.0 2018-12-09 12:05:40 +01:00
bors 9cd3bef4cf Auto merge of #55010 - tromey:Bug-9224-generic-parameters, r=michaelwoerister
Add template parameter debuginfo to generic types

This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes #9224
2018-12-03 11:59:11 +00:00
Nikita Popov cbf748993f Enable -mergefunc-use-aliases
If the Rust LLVM fork is used, enable the -mergefunc-use-aliases
flag, which will create aliases for merged functions, rather than
inserting a call from one to the other.

A number of codegen tests needed to be adjusted, because functions
that previously fell below the thunk limit are now being merged.
Merging is prevented either using -C no-prepopulate-passes, or by
making the functions non-identical.

I expect that this is going to break something, somewhere, because
it isn't able to deal with aliases properly, but we won't find out
until we try :)

This fixes #52651.
2018-11-30 00:52:16 +01:00
Tom Tromey fb204cb92f Add template parameter debuginfo to generic types
This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes #9224
2018-11-29 13:04:09 -07:00
Denis Merigoux c9f26c2155 Beginning of moving all backend-agnostic code to rustc_codegen_ssa 2018-11-16 14:55:42 +02:00
Denis Merigoux 566fa4d003 Moved common.rs enums 2018-11-16 14:38:19 +02:00
Denis Merigoux 39fd4d9274 Starting to move backend-agnostic code into codegen_utils
IntPredicate moved
2018-11-16 14:38:19 +02:00
Denis Merigoux 0514c7b1b2 Generalized some base.rs methods 2018-11-16 14:11:59 +02:00
Denis Merigoux 3e77f2fc4f Use the method form for CodegenCx everywhere 2018-11-16 14:11:59 +02:00
Denis Merigoux 8714e6bce6 Traitification of common.rs methods 2018-11-16 14:11:59 +02:00
Denis Merigoux d577ec7e5f New files and folders for traits
Moved common enums to common
2018-11-16 14:11:59 +02:00
Denis Merigoux 1ca750683e Generalized AsmDialect for BuilderMethods 2018-11-16 14:11:09 +02:00
Denis Merigoux b761538997 Generalized SynchronisationScope for BuilderMethods 2018-11-16 14:11:09 +02:00
Denis Merigoux b699866290 Generalized AtomicOrdering for BuilderMethods 2018-11-16 14:11:09 +02:00
Denis Merigoux 275589150b Generalized AtomicRmwBinOp for BuilderMethods 2018-11-16 14:11:09 +02:00
Denis Merigoux bc86624c43 Removed useless traits for IntPredicate and RealPredicate 2018-11-16 14:11:09 +02:00
Denis Merigoux 8590336d49 Generalized RealPredicate 2018-11-16 14:11:09 +02:00
Denis Merigoux 51b7f2739b Generalized IntPredicate in the BuilderMethods trait 2018-11-16 14:11:09 +02:00
bors 775eab5883 Auto merge of #55698 - nikic:remove-llvm-4-support, r=alexcrichton
Remove support for building against LLVM 4

With emscripten removed in #55626, we no longer need to support building against LLVM 4.
2018-11-11 22:38:54 +00:00
Mark Rousskov 78cab36139
Rollup merge of #55633 - nikic:memcpy-align, r=nagisa
Support memcpy/memmove with differing src/dst alignment

If LLVM 7 is used, generate memcpy/memmove with differing src/dst alignment. I've added new FFI functions to construct these through the builder API, which is more convenient than dealing with differing intrinsic signatures depending on the LLVM version.

Fixes #49740.
2018-11-08 18:14:49 -07:00
Nikita Popov 3cc8b17451 Remove support for building against LLVM 4
With emscripten removed in #55626, we no longer need to support
building against LLVM 4.
2018-11-05 15:04:26 +01:00
Nikita Popov 463ad9098e Support memcpy/memmove with differing src/dst alignment
If LLVM 7 is used, generate memcpy/memmove with differing
src/dst alignment. I've added new FFI functions to construct
these through the builder API, which is more convenient than
dealing with differing intrinsic signatures depending on the
LLVM version.
2018-11-04 18:54:37 +01:00
Nikita Popov d794597698 Remove checks for LLVM < 4.0
While we still have to support LLVM 4.0 for Emscripten, we can
drop checks for LLVM >= 4.0 and < 4.0.
2018-11-01 21:09:02 +01:00
Tom Tromey 71ce4c3007 Fix DWARF generation for enums
The DWARF generated for Rust enums was always somewhat unusual.
Rather than using DWARF constructs directly, it would emit magic field
names like "RUST$ENCODED$ENUM$0$Name" and "RUST$ENUM$DISR".  Since
PR #45225, though, even this has not worked -- the ad hoc scheme was
not updated to handle the wider variety of niche-filling layout
optimizations now available.

This patch changes the generated DWARF to use the standard tags meant
for this purpose; namely, DW_TAG_variant and DW_TAG_variant_part.

The patch to implement this went in to LLVM 7.  In order to work with
older versions of LLVM, and because LLVM doesn't do anything here for
PDB, the existing code is kept as a fallback mode.

Support for this DWARF is in the Rust lldb and in gdb 8.2.

Closes #32920
Closes #32924
Closes #52762
Closes #53153
2018-10-30 12:06:07 -06:00
Alex Crichton 086f5a55be Revert "rustc: Fix (again) simd vectors by-val in ABI"
This reverts commit 3cc8f738d4.
2018-10-23 00:59:14 -07:00
Manish Goregaokar b860765355 Rollup merge of #55073 - alexcrichton:demote-simd, r=nagisa
The issue of passing around SIMD types as values between functions has
seen [quite a lot] of [discussion], and although we thought [we fixed
it][quite a lot] it [wasn't]! This PR is a change to rustc to, again,
try to fix this issue.

The fundamental problem here remains the same, if a SIMD vector argument
is passed by-value in LLVM's function type, then if the caller and
callee disagree on target features a miscompile happens. We solve this
by never passing SIMD vectors by-value, but LLVM will still thwart us
with its argument promotion pass to promote by-ref SIMD arguments to
by-val SIMD arguments.

This commit is an attempt to thwart LLVM thwarting us. We, just before
codegen, will take yet another look at the LLVM module and demote any
by-value SIMD arguments we see. This is a very manual attempt by us to
ensure the codegen for a module keeps working, and it unfortunately is
likely producing suboptimal code, even in release mode. The saving grace
for this, in theory, is that if SIMD types are passed by-value across
a boundary in release mode it's pretty unlikely to be performance
sensitive (as it's already doing a load/store, and otherwise
perf-sensitive bits should be inlined).

The implementation here is basically a big wad of C++. It was largely
copied from LLVM's own argument promotion pass, only doing the reverse.
In local testing this...

Closes #50154
Closes #52636
Closes #54583
Closes #55059

[quite a lot]: https://github.com/rust-lang/rust/pull/47743
[discussion]: https://github.com/rust-lang/rust/issues/44367
[wasn't]: https://github.com/rust-lang/rust/issues/50154
2018-10-20 13:15:39 -07:00
Alex Crichton 3cc8f738d4 rustc: Fix (again) simd vectors by-val in ABI
The issue of passing around SIMD types as values between functions has
seen [quite a lot] of [discussion], and although we thought [we fixed
it][quite a lot] it [wasn't]! This PR is a change to rustc to, again,
try to fix this issue.

The fundamental problem here remains the same, if a SIMD vector argument
is passed by-value in LLVM's function type, then if the caller and
callee disagree on target features a miscompile happens. We solve this
by never passing SIMD vectors by-value, but LLVM will still thwart us
with its argument promotion pass to promote by-ref SIMD arguments to
by-val SIMD arguments.

This commit is an attempt to thwart LLVM thwarting us. We, just before
codegen, will take yet another look at the LLVM module and demote any
by-value SIMD arguments we see. This is a very manual attempt by us to
ensure the codegen for a module keeps working, and it unfortunately is
likely producing suboptimal code, even in release mode. The saving grace
for this, in theory, is that if SIMD types are passed by-value across
a boundary in release mode it's pretty unlikely to be performance
sensitive (as it's already doing a load/store, and otherwise
perf-sensitive bits should be inlined).

The implementation here is basically a big wad of C++. It was largely
copied from LLVM's own argument promotion pass, only doing the reverse.
In local testing this...

Closes #50154
Closes #52636
Closes #54583
Closes #55059

[quite a lot]: https://github.com/rust-lang/rust/pull/47743
[discussion]: https://github.com/rust-lang/rust/issues/44367
[wasn't]: https://github.com/rust-lang/rust/issues/50154
2018-10-19 02:35:00 -07:00
varkor f40932f106 Fix LLVMRustInlineAsmVerify return type mismatch 2018-10-16 18:22:25 +01:00
Andy Russell 00e1f5b8df
exit with status code 101 on fatal LLVM error
Fixes #54992.
2018-10-12 17:29:40 -04:00
Gabriel Majeri 6009da0794 Support for disabling the PLT on ELF targets
Disable the PLT where possible to improve performance
for indirect calls into shared libraries.

This optimization is enabled by default where possible.

- Add the `NonLazyBind` attribute to `rustllvm`:
  This attribute informs LLVM to skip PLT calls in codegen.

- Disable PLT unconditionally:
  Apply the `NonLazyBind` attribute on every function.

- Only enable no-plt when full relro is enabled:
  Ensures we only enable it when we have linker support.

- Add `-Z plt` as a compiler option
2018-10-11 21:11:00 +03:00
bors d623ec6ba3 Auto merge of #54568 - levex:issue-54130, r=nagisa
codegen_llvm: check inline assembly constraints with LLVM

---%<---
Hey all,

As issue #54130 highlights, constraints are not checked and passing bad constraints to LLVM can crash it since a `Verify()` call is placed inside an assertion (see: `src/llvm/lib/IR/InlineAsm.cpp:39`).

As this is my first PR to the Rust compiler (woot! 🎉), there might be better ways of achieving this result. In particular, I am not too happy about generating an error in codegen; it would be much nicer if we did it earlier. However, @rkruppe [noted on IRC](https://botbot.me/mozilla/rustc/2018-09-25/?msg=104791581&page=1) that this should be fine for an unstable feature and a much better solution than the _status quo_, which is an ICE.

Thanks!
--->%---

LLVM provides a way of checking whether the constraints and the actual
inline assembly make sense. This commit introduces a check before
emitting code for the inline assembly. If LLVM rejects the inline
assembly (or its constraints), then the compiler emits an error E0668
("malformed inline assembly").

Fixes: #54130
Signed-off-by: Levente Kurusa \<lkurusa@acm.org\>
2018-09-28 09:17:28 +00:00
Jorge Aparicio 3c0907ce51 add -Z emit-stack-sizes 2018-09-26 15:21:26 +02:00
Levente Kurusa fec86c8352
codegen_llvm: check inline assembly constraints with LLVM
LLVM provides a way of checking whether the constraints and the actual
inline assembly make sense. This commit introduces a check before
emitting code for the inline assembly. If LLVM rejects the inline
assembly (or its constraints), then the compiler emits an error E0668
("malformed inline assembly").

Signed-off-by: Levente Kurusa <lkurusa@acm.org>
2018-09-25 20:38:35 +02:00
Unknown 40e7667506 Remove LLVM 3.9 workaround. 2018-09-14 19:06:45 +03:00
Michael Woerister 2e587df6e2 Provide a way of accessing the ThinLTO module import map in rustc. 2018-08-31 15:22:52 +02:00
Alex Crichton 1fd45a13de Fix warnings about the `native` target-cpu
This fixes a regression from #53031 where specifying `-C target-cpu=native` is
printing a lot of warnings from LLVM about `native` being an unknown CPU. It
turns out that `native` is indeed an unknown CPU and we have to perform a
mapping to an actual CPU name, but this mapping is only performed in one
location rather than all locations we inform LLVM about the target CPU.

This commit centralizes the mapping of `native` to LLVM's value of the native
CPU, ensuring that all locations we inform LLVM about the `target-cpu` it's
never `native`.

Closes #53322
2018-08-28 13:32:11 -07:00
Masaki Hara cd0476a390 Add Builder::array_alloca. 2018-08-19 08:06:42 +09: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
whitequark 66fd1ebfae Make LLVM emit assembly comments with -Z asm-comments.
Fixes #35741.
2018-08-12 17:59:33 +00: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
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
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
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