summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/llvm
AgeCommit message (Collapse)AuthorLines
2018-10-23Revert "rustc: Fix (again) simd vectors by-val in ABI"Alex Crichton-2/+0
This reverts commit 3cc8f738d4247a9b475d8e074b621e602ac2b7be.
2018-10-20Rollup merge of #55073 - alexcrichton:demote-simd, r=nagisaManish Goregaokar-0/+2
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-19rustc: Fix (again) simd vectors by-val in ABIAlex Crichton-0/+2
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-19Prefer unwrap_or_else to unwrap_or in case of function calls/allocationsljedrz-2/+2
2018-10-18Rollup merge of #55128 - varkor:LLVMRustInlineAsmVerify-return-bool, r=rkruppekennytm-2/+2
Fix LLVMRustInlineAsmVerify return type mismatch Fixes https://github.com/rust-lang/rust/issues/54918. r? @rkruppe cc @levex
2018-10-18Rollup merge of #54933 - ljedrz:cleanup_codegen_llvm/misc, r=varkorkennytm-1/+1
Cleanup the rest of codegen_llvm - improve common patterns - convert string literals with `to_owned` - remove explicit `return`s - whitespace & formatting improvements
2018-10-16Fix LLVMRustInlineAsmVerify return type mismatchvarkor-2/+2
2018-10-12exit with status code 101 on fatal LLVM errorAndy Russell-0/+2
Fixes #54992.
2018-10-11Support for disabling the PLT on ELF targetsGabriel Majeri-0/+1
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-09codegen_llvm/misc: convert string literals with to_ownedljedrz-1/+1
2018-09-28Auto merge of #54568 - levex:issue-54130, r=nagisabors-0/+3
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! :tada:), 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-26add -Z emit-stack-sizesJorge Aparicio-1/+2
2018-09-25codegen_llvm: check inline assembly constraints with LLVMLevente Kurusa-0/+3
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-14Remove LLVM 3.9 workaround.Unknown-9/+3
2018-08-31Provide a way of accessing the ThinLTO module import map in rustc.Michael Woerister-0/+9
2018-08-28Fix warnings about the `native` target-cpuAlex Crichton-0/+1
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-19Add Builder::array_alloca.Masaki Hara-0/+5
2018-08-14Rollup merge of #53290 - whitequark:fix-35741, r=nagisakennytm-1/+2
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-13Auto merge of #53161 - michaelwoerister:cstrings, r=wesleywiserbors-2/+3
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-12Make LLVM emit assembly comments with -Z asm-comments.whitequark-1/+2
Fixes #35741.
2018-08-10[nll] librustc_codegen_llvm: change Child signature to fix error pointed out ↵memoryruins-1/+1
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-10Introduce SmallCStr and use it where applicable.Michael Woerister-2/+3
2018-08-07Auto merge of #51007 - AstralSorcerer:master, r=nagisabors-0/+1
Make globals with private linkage unnamed. Fixes #50862. cc @oli-obk @nagisa
2018-07-31Make globals with private linkage unnamed. Fixes #50862.Colin Pronovost-0/+1
2018-07-31rustc: Handle linker diagnostic from LLVMAlex Crichton-0/+5
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-30rustc_codegen_llvm: fix ownership of DIBuilder.Irina Popa-30/+31
2018-07-30rustc_codegen_llvm: fix ownership of Builder.Irina Popa-94/+103
2018-07-30rustc_codegen_llvm: fix tidy errors.Irina Popa-4/+11
2018-07-30rustc_codegen_llvm: use safe references for ThinLTOData.Irina Popa-6/+6
2018-07-30rustc_codegen_llvm: use safe references for ThinLTOBuffer.Irina Popa-4/+4
2018-07-30rustc_codegen_llvm: use safe references for ModuleBuffer.Irina Popa-4/+4
2018-07-30rustc_codegen_llvm: use safe references for RustArchiveMember.Irina Popa-6/+6
2018-07-30rustc_codegen_llvm: use safe references for ArchiveChild.Irina Popa-35/+53
2018-07-30rustc_codegen_llvm: use safe references for ArchiveIterator.Irina Popa-9/+6
2018-07-30rustc_codegen_llvm: use safe references for Linker.Irina Popa-5/+4
2018-07-30rustc_codegen_llvm: use safe references for SectionIterator.Irina Popa-14/+13
2018-07-30rustc_codegen_llvm: use safe references for PassManager.Irina Popa-18/+17
2018-07-30rustc_codegen_llvm: use safe references for OperandBundleDef.Irina Popa-18/+20
2018-07-30rustc_codegen_llvm: use safe mutable references for output parameters.Irina Popa-10/+10
2018-07-30rustc_codegen_llvm: use safe references for RustString.Irina Popa-30/+33
2018-07-30rustc_codegen_llvm: use safe references for Twine, DiagnosticInfo, SMDiagnostic.Irina Popa-24/+21
2018-07-30rustc_codegen_llvm: use safe references for Archive.Irina Popa-17/+11
2018-07-30rustc_codegen_llvm: use safe references for TargetMachine.Irina Popa-8/+7
2018-07-30rustc_codegen_llvm: use safe references for Pass.Irina Popa-4/+3
2018-07-30rustc_codegen_llvm: use safe references for PassManagerBuilder.Irina Popa-14/+13
2018-07-30rustc_codegen_llvm: use safe references for MemoryBuffer and ObjectFile.Irina Popa-17/+14
2018-07-30rustc_codegen_llvm: remove more unused functions.Irina Popa-176/+19
2018-07-30rustc_codegen_llvm: remove unused UseRef type.Irina Popa-7/+0
2018-07-30rustc_codegen_llvm: use safe references for BasicBlock.Irina Popa-25/+24
2018-07-30rustc_codegen_llvm: use safe references for Value.Irina Popa-506/+510