summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2020-06-01Auto merge of #71192 - oli-obk:eager_alloc_id_canonicalization, r=wesleywiserbors-0/+1
Make TLS accesses explicit in MIR r? @rust-lang/wg-mir-opt cc @RalfJung @vakaras for miri thread locals cc @bjorn3 for cranelift fixes #70685
2020-05-30Rollup merge of #72666 - ivanloz:profile_emit_flag, r=matthewjasperRalf Jung-4/+4
Add -Z profile-emit=<path> for Gcov gcda output. Adds a -Z flag to control the file path that the Gcov gcda output is written to during runtime. This flag expects a path and filename, e.g. -Z profile-emit=gcov/out/lib.gcda. This works similar to GCC/Clang's -fprofile-dir flag which allows control over the output path for gcda coverage files.
2020-05-30Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkovRalf Jung-17/+75
Improve inline asm error diagnostics Previously we were just using the raw LLVM error output (with line, caret, etc) as the diagnostic message, which ends up looking rather out of place with our existing diagnostics. The new diagnostics properly format the diagnostics and also take advantage of LLVM's per-line `srcloc` attribute to map an error in inline assembly directly to the relevant line of source code. Incidentally also fixes #71639 by disabling `srcloc` metadata during LTO builds since we don't know what crate it might have come from. We can only resolve `srcloc`s from the currently crate since it indexes into the source map for the current crate. Fixes #72664 Fixes #71639 r? @petrochenkov ### Old style ```rust #![feature(llvm_asm)] fn main() { unsafe { let _x: i32; llvm_asm!( "mov $0, $1 invalid_instruction $0, $1 mov $0, $1" : "=&r" (_x) : "r" (0) :: "intel" ); } } ``` ``` error: <inline asm>:3:14: error: invalid instruction mnemonic 'invalid_instruction' invalid_instruction ecx, eax ^~~~~~~~~~~~~~~~~~~ --> src/main.rs:6:9 | 6 | / llvm_asm!( 7 | | "mov $0, $1 8 | | invalid_instruction $0, $1 9 | | mov $0, $1" ... | 12 | | :: "intel" 13 | | ); | |__________^ ``` ### New style ```rust #![feature(asm)] fn main() { unsafe { asm!( "mov {0}, {1} invalid_instruction {0}, {1} mov {0}, {1}", out(reg) _, in(reg) 0i64, ); } } ``` ``` error: invalid instruction mnemonic 'invalid_instruction' --> test.rs:7:14 | 7 | invalid_instruction {0}, {1} | ^ | note: instantiated into assembly here --> <inline asm>:3:14 | 3 | invalid_instruction rax, rcx | ^^^^^^^^^^^^^^^^^^^ ```
2020-05-30Make TLS accesses explicit in MIROliver Scherer-0/+1
2020-05-29Improve inline asm error diagnosticsAmanieu d'Antras-17/+75
2020-05-27Add -Z profile-emit=<path> for Gcov gcda output.Ivan Lozano-4/+4
Adds a -Z flag to control the file path that the Gcov gcda output is written to during runtime. This flag expects a path and filename, e.g. -Z profile-emit=gcov/out/lib.gcda. This works similar to GCC/Clang's -fprofile-dir flag which allows control over the output path for gcda coverage files.
2020-05-24Minor fixes, as requested in PR reviewMichal Sudwoj-4/+0
2020-05-24NVPTX support for new asm!Michal Sudwoj-0/+12
2020-05-22Use `OnceCell` instead of `Once`Dylan MacKenzie-1/+1
2020-05-22Rollup merge of #72435 - petrochenkov:cratetypesopt, r=Mark-SimulacrumRalf Jung-41/+9
rustllvm: Fix warnings about unused function parameters And then perform corresponding cleanups on Rust side. Fixes https://github.com/rust-lang/rust/issues/72427
2020-05-22Rollup merge of #72376 - wesleywiser:record_cgu_name, r=Mark-SimulacrumRalf Jung-1/+1
[self-profling] Record the cgu name when doing codegen for a module
2020-05-22Rollup merge of #72438 - vertexclique:vcq/aarch64-tme-features, r=AmanieuRalf Jung-0/+1
Enable ARM TME (Transactional Memory Extensions) Enables ARM TME coming up with LLVM 10. Related ARM TME intrinsics are included by the merge of #67900. Enables: https://github.com/rust-lang/stdarch/pull/855
2020-05-22Rollup merge of #72309 - petrochenkov:linkunspec, r=matthewjasperRalf Jung-2/+2
Some renaming and minor refactoring for `NativeLibraryKind`
2020-05-21Enable ARM TME (Transactional Memory Extensions)Mahmut Bulut-0/+1
2020-05-21rustllvm: Fix warnings about unused function parametersVadim Petrochenkov-41/+9
2020-05-21Auto merge of #71718 - NeoRaider:ffi_const_pure, r=Amanieubors-0/+6
Experimentally add `ffi_const` and `ffi_pure` extern fn attributes Add FFI function attributes corresponding to clang/gcc/... `const` and `pure`. Rebased version of #58327 by @gnzlbg with the following changes: - Switched back from the `c_ffi_const` and `c_ffi_pure` naming to `ffi_const` and `ffi_pure`, as I agree with https://github.com/rust-lang/rust/pull/58327#issuecomment-462718772 and this nicely aligns with `ffi_returns_twice` - (Hopefully) took care of all of @hanna-kruppe's change requests in the original PR r? @hanna-kruppe
2020-05-21Rollup merge of #72397 - petrochenkov:tiny, r=AmanieuRalf Jung-1/+1
llvm: Expose tiny code model to users This model is relevant to embedded AArch64 targets and was added to LLVM relatively recently (https://reviews.llvm.org/D49673, mid 2018), so rustc frontend didn't provide access to it with `-C code-model`. The gcc analogue is [`-mcmodel=tiny`](https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html). (This is one of the options that are passed directly to LLVM without being interpreted by rustc.) Follow up to https://github.com/rust-lang/rust/pull/72248.
2020-05-21Auto merge of #70705 - lcnr:generic_discriminant, r=nikomatsakisbors-3/+9
Use `T`'s discriminant type in `mem::Discriminant<T>` instead of `u64`. fixes #70509 Adds the lang-item `discriminant_kind`. Updates the function signature of `intrinsics::discriminant_value`. Adds the *probably permanently unstable* trait `DiscriminantKind`. `mem::Discriminant` should now be smaller in some cases. r? @ghost
2020-05-20llvm: Expose tiny code model to usersVadim Petrochenkov-1/+1
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-20[self-profling] Record the cgu name when doing codegen for a moduleWesley Wiser-1/+1
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-19update codegen of `discriminant_value`Bastian Kauschke-3/+9
2020-05-18Move InlineAsmTemplatePiece and InlineAsmOptions to librustc_astAmanieu d'Antras-0/+1
2020-05-18Implement att_syntax optionAmanieu d'Antras-1/+5
2020-05-18Work around more LLVM limitationsAmanieu d'Antras-1/+76
2020-05-18Add support for high byte registers on x86Amanieu d'Antras-0/+3
2020-05-18Implement asm! codegenAmanieu d'Antras-15/+465
2020-05-18Add RISC-V target featuresAmanieu d'Antras-0/+11
2020-05-17Auto merge of #72248 - petrochenkov:codemodel, r=Amanieubors-26/+15
Cleanup and document `-C code-model` r? @Amanieu
2020-05-16rustc_target: Stop using "string typing" for code modelsVadim Petrochenkov-26/+15
Introduce `enum CodeModel` instead.
2020-05-14Consistently use LLVM lifetime markers during codegenTomasz Miąsko-11/+5
Ensure that inliner inserts lifetime markers if they have been emitted during codegen. Otherwise if allocas from inlined functions are merged together, lifetime markers from one function might invalidate load & stores performed by the other one.
2020-05-09Rollup merge of #71555 - cjgillot:nameless, r=matthewjasperRalf Jung-6/+4
Remove ast::{Ident, Name} reexports. The reexport of `Symbol` into `Name` confused me.
2020-05-09Rollup merge of #71508 - oli-obk:alloc_map_unlock, r=RalfJungRalf Jung-6/+4
Simplify the `tcx.alloc_map` API This PR changes all functions that require manually locking the `alloc_map` to functions on `TyCtxt` that lock the map internally. In the same step we make the `TyCtxt::alloc_map` field private. r? @RalfJung
2020-05-09Rollup merge of #71234 - maurer:init-array, r=cuviperRalf Jung-0/+9
rustllvm: Use .init_array rather than .ctors LLVM TargetMachines default to using the (now-legacy) .ctors representation of init functions. Mixing .ctors and .init_array representations can cause issues when linking with lld. This happens in practice for: * Our profiling runtime which is currently implicitly built with .init_array since it is built by clang, which sets this field. * External C/C++ code that may be linked into the same process. Fixes: #71233
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-6/+4
2020-05-08Create a convenience wrapper for `get_global_alloc(id).unwrap()`Oliver Scherer-5/+4
2020-05-08Simplify the `tcx.alloc_map` APIOliver Scherer-2/+1
2020-05-08Simplify bitcode embedding - either None or FullTom Karpiniec-5/+3
2020-05-07Provide configurable LLVM cmdline section via target specTom Karpiniec-6/+8
The App Store performs certain sanity checks on bitcode, including that an acceptable set of command line arguments was used when compiling a given module. For Rust code to be distributed on the app store with bitcode rustc must pretend to have the same command line arguments.
2020-05-05Rollup merge of #69984 - lenary:lenary/force-uwtables, r=hanna-kruppeDylan DPC-5/+2
Add Option to Force Unwind Tables 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 production 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 came up in discussion on #69890, and turned out to be a fairly simple addition. r? @hanna-kruppe
2020-05-04Correctly handle UEFI targets as Windows-like when emitting sections for ↵Isaac Woods-1/+3
LLVM bitcode
2020-05-04Add Option to Force Unwind TablesSam Elliott-5/+2
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-02Rollup merge of #71787 - tshepang:rustdoc-warnings, r=varkorDylan DPC-3/+4
fix rustdoc warnings
2020-05-02cleanup: `config::CrateType` -> `CrateType`Vadim Petrochenkov-11/+9
2020-05-02fix rustdoc warningsTshepang Lekhonkhobe-3/+4
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-30Add a convenience function for testing whether a static is `#[thread_local]`Oliver Scherer-0/+1
2020-04-30Auto merge of #70175 - Amanieu:remove_nlp, r=pnkfelixbors-2/+6
Remove -Z no-landing-pads flag Since #67502, `-Z no-landing-pads` will cause all attempted unwinds to abort since we don't generate a `try` / `catch`. This previously worked because `__rust_try` was located in libpanic_unwind which is always compiled with `-C panic=unwind`, but `__rust_try` is now directly inline into the crate that uses `catch_unwind`. As such, `-Z no-landing-pads` is now mostly useless and people should use `-C panic=abort` instead.
2020-04-29Auto merge of #71528 - alexcrichton:no-more-bitcode, r=nnethercotebors-177/+90
Store LLVM bitcode in object files, not compressed This commit is an attempted resurrection of #70458 where LLVM bitcode emitted by rustc into rlibs is stored into object file sections rather than in a separate file. The main rationale for doing this is that when rustc emits bitcode it will no longer use a custom compression scheme which makes it both easier to interoperate with existing tools and also cuts down on compile time since this compression isn't happening. The blocker for this in #70458 turned out to be that native linkers didn't handle the new sections well, causing the sections to either trigger bugs in the linker or actually end up in the final linked artifact. This commit attempts to address these issues by ensuring that native linkers ignore the new sections by inserting custom flags with module-level inline assembly. Note that this does not currently change the API of the compiler at all. The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate whether the bitcode should be present in the object file or not. Finally, note that an important consequence of this commit, which is also one of its primary purposes, is to enable rustc's `-Clto` bitcode loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here is that when you're building with LTO Cargo will tell rustc to skip codegen of all intermediate crates and only generate LLVM IR. Today rustc will generate both object code and LLVM IR, but the object code is later simply thrown away, wastefully.