about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/attributes.rs
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-397/+0
2020-07-17Generating the coverage mapRich Kadel-0/+3
rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example: $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main 1| 1|pub fn will_be_called() { 2| 1| println!("called"); 3| 1|} 4| | 5| 0|pub fn will_not_be_called() { 6| 0| println!("should not have been called"); 7| 0|} 8| | 9| 1|fn main() { 10| 1| let less = 1; 11| 1| let more = 100; 12| 1| 13| 1| if less < more { 14| 1| will_be_called(); 15| 1| } else { 16| 1| will_not_be_called(); 17| 1| } 18| 1|}
2020-07-10Avoid "whitelist"Tamir Duberstein-4/+4
Other terms are more inclusive and precise.
2020-07-05Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.Eduard-Mihai Burtescu-2/+2
2020-06-14Diagnose use of incompatible sanitizersTomasz Miąsko-25/+20
Emit an error when incompatible sanitizer are configured through command line options. Previously the last one configured prevailed and others were silently ignored. Additionally use a set to represent configured sanitizers, making it possible to enable multiple sanitizers at once. At least in principle, since currently all of them are considered to be incompatible with others.
2020-05-22Rollup merge of #72309 - petrochenkov:linkunspec, r=matthewjasperRalf Jung-2/+2
Some renaming and minor refactoring for `NativeLibraryKind`
2020-05-20Rename some types describing native librariesVadim Petrochenkov-2/+2
NativeLibrary(Kind) -> NativeLib(Kind) NativeStatic -> StaticBundle NativeStaticNobundle -> StaticNoBundle NativeFramework -> Framework NativeRawDylib -> RawDylib NativeUnknown -> Unspecified
2020-05-20Implement `#[ffi_const]` and `#[ffi_pure]` function attributesMatthias Schiffer-0/+6
Introduce function attribute corresponding to the `const`/`pure` attributes supported by GCC, clang and other compilers. Based on the work of gnzlbg <gonzalobg88@gmail.com>.
2020-05-04Add Option to Force Unwind TablesSam Elliott-4/+1
When panic != unwind, `nounwind` is added to all functions for a target. This can cause issues when a panic happens with RUST_BACKTRACE=1, as there needs to be a way to reconstruct the backtrace. There are three possible sources of this information: forcing frame pointers (for which an option exists already), debug info (for which an option exists), or unwind tables. Especially for embedded devices, forcing frame pointers can have code size overheads (RISC-V sees ~10% overheads, ARM sees ~2-3% overheads). In code, it can be the case that debug info is not kept, so it is useful to provide this third option, unwind tables, that users can use to reconstruct the call stack. Reconstructing this stack is harder than with frame pointers, but it is still possible. This commit adds a compiler option which allows a user to force the addition of unwind tables. Unwind tables cannot be disabled on targets that require them for correctness, or when using `-C panic=unwind`.
2020-05-01Auto merge of #70674 - cjgillot:query-arena-all, r=matthewjasperbors-10/+7
Have the per-query caches store the results on arenas This PR leverages the cache for each query to serve as storage area for the query results. It introduces a new cache `ArenaCache`, which moves the result to an arena, and only stores the reference in the hash map. This allows to remove a sizeable part of the usage of the global `TyCtxt` arena. I only migrated queries that already used arenas before.
2020-04-29Remove Session::no_landing_pads()Amanieu d'Antras-1/+4
2020-04-28Move a few queries to using an arena.Camille GILLOT-1/+1
2020-04-28Use the query system to allocate.Camille GILLOT-9/+6
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-1/+1
2020-04-14Update the minimum external LLVM to 8Josh Stone-15/+6
LLVM 8 was released on March 20, 2019, over a year ago.
2020-03-31Address review feedbackWesley Wiser-16/+2
2020-03-30Add `can_unwind` field to `FnAbi`Wesley Wiser-41/+1
This is a pure refactoring with no behavior changes.
2020-03-30rustc -> rustc_middle part 3 (rustfmt)Mazdak Farrokhzad-4/+4
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-4/+4
2020-03-29reduce rustc_attr usage in placesMazdak Farrokhzad-1/+1
2020-03-16use direct imports for `rustc::{lint, session}`.Mazdak Farrokhzad-2/+2
2020-02-05Apply LLVM sanitize attributes to generated entry wrapperTomasz Miąsko-20/+26
2020-02-05Selectively disable sanitizer instrumentationTomasz Miąsko-0/+20
Add `no_sanitize` attribute that allows to opt out from sanitizer instrumentation in an annotated function.
2020-02-01Move builtin attribute logic to new rustc_attr crate.Mazdak Farrokhzad-1/+1
For now, this is all the crate contains, but more attribute logic & types will be moved there over time.
2020-01-23Clarify some methods around instance instantiation via comments and clearer ↵Michael Woerister-1/+1
names.
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-1/+1
2020-01-04extract rustc::middle::codegen_fn_attrsMazdak Farrokhzad-1/+1
2019-12-30Use function attribute "frame-pointer" instead of "no-frame-pointer-elim"Fangrui Song-6/+15
LLVM 8 (D56351) introduced "frame-pointer". In LLVM 10 (D71863), "no-frame-pointer-elim"/"no-frame-pointer-elim-non-leaf" will be ignored.
2019-12-22Format the worldMark Rousskov-108/+116
2019-12-20Rollup merge of #67363 - alexcrichton:wasm-import-modules, r=eddybMazdak Farrokhzad-0/+11
Fix handling of wasm import modules and names The WebAssembly targets of rustc have weird issues around name mangling and import the same name from different modules. This all largely stems from the fact that we're using literal symbol names in LLVM IR to represent what a function is called when it's imported, and we're not using the wasm-specific `wasm-import-name` attribute. This in turn leads to two issues: * If, in the same codegen unit, the same FFI symbol is referenced twice then rustc, when translating to LLVM IR, will only reference one symbol from the first wasm module referenced. * There's also a bug in LLD [1] where even if two codegen units reference different modules, having the same symbol names means that LLD coalesces the symbols and only refers to one wasm module. Put another way, all our imported wasm symbols from the environment are keyed off their LLVM IR symbol name, which has lots of collisions today. This commit fixes the issue by implementing two changes: 1. All wasm symbols with `#[link(wasm_import_module = "...")]` are mangled by default in LLVM IR. This means they're all given unique names. 2. Symbols then use the `wasm-import-name` attribute to ensure that the WebAssembly file uses the correct import name. When put together this should ensure we don't trip over the LLD bug [1] and we also codegen IR correctly always referencing the right symbols with the right import module/name pairs. Closes #50021 Closes #56309 Closes #63562 [1]: https://bugs.llvm.org/show_bug.cgi?id=44316
2019-12-16Fix handling of wasm import modules and namesAlex Crichton-0/+11
The WebAssembly targets of rustc have weird issues around name mangling and import the same name from different modules. This all largely stems from the fact that we're using literal symbol names in LLVM IR to represent what a function is called when it's imported, and we're not using the wasm-specific `wasm-import-name` attribute. This in turn leads to two issues: * If, in the same codegen unit, the same FFI symbol is referenced twice then rustc, when translating to LLVM IR, will only reference one symbol from the first wasm module referenced. * There's also a bug in LLD [1] where even if two codegen units reference different modules, having the same symbol names means that LLD coalesces the symbols and only refers to one wasm module. Put another way, all our imported wasm symbols from the environment are keyed off their LLVM IR symbol name, which has lots of collisions today. This commit fixes the issue by implementing two changes: 1. All wasm symbols with `#[link(wasm_import_module = "...")]` are mangled by default in LLVM IR. This means they're all given unique names. 2. Symbols then use the `wasm-import-name` attribute to ensure that the WebAssembly file uses the correct import name. When put together this should ensure we don't trip over the LLD bug [1] and we also codegen IR correctly always referencing the right symbols with the right import module/name pairs. Closes #50021 Closes #56309 Closes #63562 [1]: https://bugs.llvm.org/show_bug.cgi?id=44316
2019-12-11rustc: Link LLVM directly into rustc againAlex Crichton-0/+1
This commit builds on #65501 continue to simplify the build system and compiler now that we no longer have multiple LLVM backends to ship by default. Here this switches the compiler back to what it once was long long ago, which is linking LLVM directly to the compiler rather than dynamically loading it at runtime. The `codegen-backends` directory of the sysroot no longer exists and all relevant support in the build system is removed. Note that `rustc` still supports a dynamically loaded codegen backend as it did previously, it just no longer supports dynamically loaded codegen backends in its own sysroot. Additionally as part of this the `librustc_codegen_llvm` crate now once again explicitly depends on all of its crates instead of implicitly loading them through the sysroot. This involved filling out its `Cargo.toml` and deleting all the now-unnecessary `extern crate` annotations in the header of the crate. (this in turn required adding a number of imports for names of macros too). The end results of this change are: * Rustbuild's build process for the compiler as all the "oh don't forget the codegen backend" checks can be easily removed. * Building `rustc_codegen_llvm` is much simpler since it's simply another compiler crate. * Managing the dependencies of `rustc_codegen_llvm` is much simpler since it's "just another `Cargo.toml` to edit" * The build process should be a smidge faster because there's more parallelism in the main rustc build step rather than splitting `librustc_codegen_llvm` out to its own step. * The compiler is expected to be slightly faster by default because the codegen backend does not need to be dynamically loaded. * Disabling LLVM as part of rustbuild is still supported, supporting multiple codegen backends is still supported, and dynamic loading of a codegen backend is still supported.
2019-12-06Use `to_option` in various placesvarkor-5/+1
2019-12-03rustc_target: add abi::call::Conv::Rust distinct from Conv::C.Eduard-Mihai Burtescu-6/+5
2019-12-03rustc_codegen_llvm: privatize as much of attributes::* as possible.Eduard-Mihai Burtescu-4/+4
2019-12-03rustc_codegen_llvm: take an Instance in attributes::from_fn_attrs.Eduard-Mihai Burtescu-16/+20
2019-12-03rustc_codegen_ssa: take a FnAbi instead of a FnSig in declare_fn.Eduard-Mihai Burtescu-4/+3
2019-11-02Simplify various `Symbol` use points.Nicholas Nethercote-1/+1
Including removing a bunch of unnecessary `.as_str()` calls, and a bunch of unnecessary sigils.
2019-10-12some typographyRalf Jung-2/+2
2019-10-12remove old branch of unwind logicRalf Jung-21/+1
2019-10-12Auto merge of #65020 - ↵bors-13/+39
pnkfelix:targetted-fix-for-always-marking-rust-abi-unwind-issue-64655, r=alexcrichton Always mark rust and rust-call abi's as unwind PR #63909 identified a bug that had been injected by PR #55982. As discussed on https://github.com/rust-lang/rust/issues/64655#issuecomment-537517428 , we started marking extern items as nounwind, *even* extern items that said they were using "Rust" or "rust-call" ABI. This is a more targeted variant of PR #63909 that fixes the above bug. Fix #64655 ---- I personally suspect we will want PR #63909 to land in the long-term But: * it is not certain that PR #63909 *will* land, * more importantly, PR #63909 almost certainly will not be backported to beta/stable. The identified bug was more severe than I think anyone realized (apart from perhaps @gnzlbg, as noted [here](https://github.com/rust-lang/rust/pull/63909#issuecomment-524818838)). Thus, I was motivated to write this PR, which fixes *just* the issue with extern rust/rust-call functions, and deliberately avoids injecting further deviation from current behavior (you can see further notes on this in the comments of the code added here).
2019-10-04Disable stack probe when thread sanitizer is enabledTomasz Miąsko-4/+6
When thread sanitizer instrumentation is enabled during compilation of stack probe function, the function will be miscompiled and trigger segmentation fault at runtime. Disable stack probes when tsan is enabled.
2019-10-03Update attributes.rsFelix S Klock II-4/+5
Some comment refinements inspired by review feedback.
2019-10-03Apply suggestions from code reviewFelix S Klock II-2/+2
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com> Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-10-02Fix missing calls to drop on unwind with lto=fat; issue 64655.Felix S. Klock II-13/+38
2019-07-09Translate target features for LLVM 9Nikita Popov-0/+24
2019-06-21Stabilize profile-guided optimization.Michael Woerister-2/+2
2019-06-14Unify all uses of 'gcx and 'tcx.Eduard-Mihai Burtescu-1/+1
2019-06-12rustc: replace `TyCtxt<'tcx, 'gcx, 'tcx>` with `TyCtxt<'gcx, 'tcx>`.Eduard-Mihai Burtescu-1/+1
2019-05-23Update wasm_import_module_map and target_features_whitelistJohn Kåre Alsaker-4/+3