about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/attributes.rs
AgeCommit message (Collapse)AuthorLines
2019-05-13Pass a `Symbol` to `check_name`, `emit_feature_err`, and related functions.Nicholas Nethercote-2/+2
2019-04-11Clean up handling of -Zpgo-gen commandline option.Michael Woerister-1/+1
2019-03-30Use CStringYuki OKUSHI-5/+3
2019-03-30Use target_mcountYuki OKUSHI-24/+4
2019-03-29Use platform dependent mcount functionYuki OKUSHI-1/+29
2019-02-25librustc_codegen_llvm: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-3/+3
2019-02-23Implement ffi_returns_twice attributegnzlbg-0/+3
2019-02-18librustc_codegen_llvm => 2018Taiki Endo-7/+7
2019-01-25Resolve breakageSimonas Kazlauskas-18/+23
2019-01-24Support revisions for codegen testsSimonas Kazlauskas-3/+3
`compile-flags: -Copt-level` will avoid adding -O. Similarly for -g and -Cdebuglevel.
2019-01-24Implement optimize(size) and optimize(speed)Simonas Kazlauskas-9/+35
2018-12-30Add `-Z instrument-mcount`Jun Wu-0/+13
This flag inserts `mcount` function call to the beginning of every function after inline processing. So tracing tools like uftrace [1] (or ftrace for Linux kernel modules) have a chance to examine function calls. It is similar to the `-pg` flag provided by gcc or clang, but without generating a `__gmon_start__` function for executables. If a program runs without being traced, no `gmon.out` will be written to disk. Under the hood, it simply adds `"instrument-function-entry-inlined"="mcount"` attribute to every function. The `post-inline-ee-instrument` LLVM pass does the actual job. [1]: https://github.com/namhyung/uftrace
2018-12-25Remove licensesMark Rousskov-9/+0
2018-12-14Rollup merge of #56609 - michaelwoerister:unconditional-target-cpu-attr, ↵kennytm-7/+3
r=alexcrichton Unconditionally emit the target-cpu LLVM attribute. This PR makes `rustc` always emit the `target-cpu` LLVM attribute for functions. The goal is to allow for cross-language inlining of functions defined in `libstd`. So far `libstd` functions were the only function without a `target-cpu` attribute, so in whole-crate-graph cross-lang LTO scenarios they were not eligible for inlining into foreign code. r? @alexcrichton
2018-12-12rustc: Switch `extern` functions to abort by default on panicAlex Crichton-23/+34
This was intended to land way back in 1.24, but it was backed out due to breakage which has long since been fixed. An unstable `#[unwind]` attribute can be used to tweak the behavior here, but this is currently simply switching rustc's internal default to abort-by-default if an `extern` function panics, making our codegen sound primarily (as currently you can produce UB with safe code) Closes #52652
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-2/+2
2018-12-07Unconditionally emit the target-cpu LLVM attribute.Michael Woerister-7/+3
2018-11-16[eddyb] rustc_codegen_ssa: rename `interfaces` to `traits`.Eduard-Mihai Burtescu-1/+1
2018-11-16Finished moving backend-agnostic code to rustc_codegen_ssaDenis Merigoux-1/+1
2018-11-16Generalized mir::codegen_mir (and all subsequent functions)Denis Merigoux-0/+1
2018-11-16Removed genericity over Value in various functionsDenis Merigoux-1/+1
Prelude to using associated types in traits rather than type parameters
2018-11-16Generalized base.rs#call_memcpy and everything that it usesDenis Merigoux-1/+1
Generalized operand.rs#nontemporal_store and fixed tidy issues Generalized operand.rs#nontemporal_store's implem even more With a BuilderMethod trait implemented by Builder for LLVM Cleaned builder.rs : no more code duplication, no more ValueTrait Full traitification of builder.rs
2018-10-20Auto merge of #55014 - ljedrz:lazyboye_unwraps, r=matthewjasperbors-1/+1
Prefer unwrap_or_else to unwrap_or in case of function calls/allocations The contents of `unwrap_or` are evaluated eagerly, so it's not a good pick in case of function calls and allocations. This PR also changes a few `unwrap_or`s with `unwrap_or_default`. An added bonus is that in some cases this change also reveals if the object it's called on is an `Option` or a `Result` (based on whether the closure takes an argument).
2018-10-19Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hackOliver Scherer-1/+1
2018-10-19Prefer unwrap_or_else to unwrap_or in case of function calls/allocationsljedrz-1/+1
2018-10-11Auto merge of #54592 - GabrielMajeri:no-plt, r=nagisabors-0/+9
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/+9
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: improve common patternsljedrz-3/+2
2018-10-08codegen_llvm: improve allocationsljedrz-7/+9
2018-09-12Rollup merge of #52514 - DiamondLovesYou:amdgpu-fixes, r=eddybkennytm-3/+8
Fix a few AMDGPU related issues * AMDGPU ignores `noinline` and sadly doesn't clear the attribute when it slaps `alwaysinline` on everything, * an AMDGPU related load bit range metadata assertion, * I didn't enable the `amdgpu` component in the `librustc_llvm` build script, * Add AMDGPU call abi info.
2018-08-28Fix warnings about the `native` target-cpuAlex Crichton-1/+2
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-23AMDGPU ignores `noinline` when it slaps `alwaysinline` everywhere.Richard Diamond-3/+8
Allow target specs to disable that attribute.
2018-08-16Set more llvm function attributes for __rust_tryAlex Crichton-12/+40
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-10Introduce SmallCStr and use it where applicable.Michael Woerister-1/+1
2018-08-10Introduce const_cstr!() macro and use it where applicable.Michael Woerister-9/+5
2018-08-07Annotate functions in LLVM with target-cpu, same as Clang does.Michael Woerister-0/+18
2018-07-30rustc_codegen_llvm: use safe references for Value.Irina Popa-9/+11
2018-07-18rustc: Stabilize #[wasm_import_module] as #[link(...)]Alex Crichton-6/+15
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-10Upgrade to LLVM's master branch (LLVM 7)Alex Crichton-30/+1
This commit upgrades the main LLVM submodule to LLVM's current master branch. The LLD submodule is updated in tandem as well as compiler-builtins. Along the way support was also added for LLVM 7's new features. This primarily includes the support for custom section concatenation natively in LLD so we now add wasm custom sections in LLVM IR rather than having custom support in rustc itself for doing so. Some other miscellaneous changes are: * We now pass `--gc-sections` to `wasm-ld` * The optimization level is now passed to `wasm-ld` * A `--stack-first` option is passed to LLD to have stack overflow always cause a trap instead of corrupting static data * The wasm target for LLVM switched to `wasm32-unknown-unknown`. * The syntax for aligned pointers has changed in LLVM IR and tests are updated to reflect this. * The `thumbv6m-none-eabi` target is disabled due to an [LLVM bug][llbug] Nowadays we've been mostly only upgrading whenever there's a major release of LLVM but enough changes have been happening on the wasm target that there's been growing motivation for quite some time now to upgrade out version of LLD. To upgrade LLD, however, we need to upgrade LLVM to avoid needing to build yet another version of LLVM on the builders. The revision of LLVM in use here is arbitrarily chosen. We will likely need to continue to update it over time if and when we discover bugs. Once LLVM 7 is fully released we can switch to that channel as well. [llbug]: https://bugs.llvm.org/show_bug.cgi?id=37382
2018-06-20Disable probestack when GCOV profiling is being usedMarco Castelluccio-0/+5
2018-06-14rustc: rename ty::maps to ty::query.Eduard-Mihai Burtescu-1/+1
2018-05-24std: Ensure OOM is classified as `nounwind`Alex Crichton-5/+24
OOM can't unwind today, and historically it's been optimized as if it can't unwind. This accidentally regressed with recent changes to the OOM handler, so this commit adds in a codegen test to assert that everything gets optimized away after the OOM function is approrpiately classified as nounwind Closes #50925
2018-05-17Rename trans to codegen everywhere.Irina Popa-0/+259