summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/context.rs
AgeCommit message (Collapse)AuthorLines
2018-10-19Prefer `Default::default` over `FxHash*::default` in struct constructorsOliver Scherer-9/+9
2018-10-19Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hackOliver Scherer-9/+9
2018-10-13Check the invariant for `principal` inside the methodOliver Scherer-1/+1
2018-10-11Auto merge of #54592 - GabrielMajeri:no-plt, r=nagisabors-0/+7
Support for disabling PLT for better function call performance This PR gives `rustc` the ability to skip the PLT when generating function calls into shared libraries. This can improve performance by reducing branch indirection. AFAIK, the only advantage of using the PLT is to allow for ELF lazy binding. However, since Rust already [enables full relro for security](https://github.com/rust-lang/rust/pull/43170), lazy binding was disabled anyway. This is a little known feature which is supported by [GCC](https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html) and [Clang](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fplt) as `-fno-plt` (some Linux distros [enable it by default](https://git.archlinux.org/svntogit/packages.git/tree/trunk/makepkg.conf?h=packages/pacman#n40) for all builds). Implementation inspired by [this patch](https://reviews.llvm.org/D39079#change-YvkpNDlMs_LT) which adds `-fno-plt` support to Clang. ## Performance I didn't run a lot of benchmarks, but these are the results on my machine for a `clap` [benchmark](https://github.com/clap-rs/clap/blob/master/benches/05_ripgrep.rs): ``` name control ns/iter no-plt ns/iter diff ns/iter diff % speedup build_app_long 11,097 10,733 -364 -3.28% x 1.03 build_app_short 11,089 10,742 -347 -3.13% x 1.03 build_help_long 186,835 182,713 -4,122 -2.21% x 1.02 build_help_short 80,949 78,455 -2,494 -3.08% x 1.03 parse_clean 12,385 12,044 -341 -2.75% x 1.03 parse_complex 19,438 19,017 -421 -2.17% x 1.02 parse_lots 431,493 421,421 -10,072 -2.33% x 1.02 ``` A small performance improvement across the board, with no downsides. It's likely binaries which make a lot of function calls into dynamic libraries could see even more improvements. [This comment](https://patchwork.ozlabs.org/patch/468993/#1028255) suggests that, in some cases, `-fno-plt` could improve PIC/PIE code performance by 10%. ## Security benefits **Bonus**: some of the speculative execution attacks rely on the PLT, by disabling it we reduce a big attack surface and reduce the need for [`retpoline`](https://reviews.llvm.org/D41723). ## Remaining PLT calls The compiled binaries still have plenty of PLT calls, coming from C/C++ libraries. Building dependencies with `CFLAGS=-fno-plt CXXFLAGS=-fno-plt` removes them.
2018-10-11Support for disabling the PLT on ELF targetsGabriel Majeri-0/+7
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-08codegen_llvm: remove explicit returnsljedrz-1/+2
2018-10-08codegen_llvm: improve common patternsljedrz-7/+6
2018-10-08codegen_llvm: whitespace & formatting improvementsljedrz-7/+7
2018-08-22Remove Ty prefix from Ty{Bool|Char|Int|Uint|Float|Str}varkor-1/+1
2018-08-22Remove Ty prefix from Ty{Foreign|Param}varkor-1/+1
2018-08-22Remove Ty prefix from ↵varkor-1/+1
Ty{Adt|Array|Slice|RawPtr|Ref|FnDef|FnPtr|Dynamic|Closure|Generator|GeneratorWitness|Never|Tuple|Projection|Anon|Infer|Error}
2018-08-14Rollup merge of #53274 - bjorn3:remove_statics_field, r=nagisakennytm-5/+0
Remove statics field from CodegenCx It doesnt seem to be used anywhere.
2018-08-11Remove statics field from CodegenCxbjorn3-5/+0
2018-08-10Introduce SmallCStr and use it where applicable.Michael Woerister-5/+5
2018-08-07Annotate functions in LLVM with target-cpu, same as Clang does.Michael Woerister-0/+3
2018-08-04Normalize DebugInfoLevel to standard styleMark Rousskov-3/+3
2018-08-04Normalize variants of CrateType to standard styleMark Rousskov-1/+1
This is a clippy-breaking change.
2018-07-30rustc_codegen_llvm: fix tidy errors.Irina Popa-1/+5
2018-07-30rustc_codegen_llvm: use safe references for Value.Irina Popa-21/+21
2018-07-30rustc_codegen_llvm: use safe references for Type.Irina Popa-18/+18
2018-07-30rustc_codegen_llvm: use safe references for Context and Module.Irina Popa-59/+51
2018-07-30rustc_codegen_llvm: move from empty enums to extern types.Irina Popa-6/+5
2018-07-16Revert "Clean up LLVM module naming (just use CodegenUnit names)."Michael Woerister-2/+3
This reverts commit f6894ebe664d111259a91a2b5fcc1236ca413436.
2018-07-11Clean up LLVM module naming (just use CodegenUnit names).Michael Woerister-3/+2
2018-05-24add simd float intrinsics and gather/scattergnzlbg-0/+117
2018-05-17Rename trans to codegen everywhere.Irina Popa-0/+666