summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/back
AgeCommit message (Collapse)AuthorLines
2025-03-25Reduce visibility of most items in `rustc_codegen_llvm`Daniel Paoliello-1/+1
2025-03-01Auto merge of #133250 - DianQK:embed-bitcode-pgo, r=nikicbors-55/+98
The embedded bitcode should always be prepared for LTO/ThinLTO Fixes #115344. Fixes #117220. There are currently two methods for generating bitcode that used for LTO. One method involves using `-C linker-plugin-lto` to emit object files as bitcode, which is the typical setting used by cargo. The other method is through `-C embed-bitcode=yes`. When using with `-C embed-bitcode=yes -C lto=no`, we run a complete non-LTO LLVM pipeline to obtain bitcode, then the bitcode is used for LTO. We run the Call Graph Profile Pass twice on the same module. This PR is doing something similar to LLVM's `buildFatLTODefaultPipeline`, obtaining the bitcode for embedding after running `buildThinLTOPreLinkDefaultPipeline`. r? nikic
2025-02-28Rollup merge of #137017 - bjorn3:ignore_invalid_bitcode, r=oli-obk许杰友 Jieyou Xu (Joe)-3/+22
Don't error when adding a staticlib with bitcode files compiled by newer LLVM cc https://github.com/rust-lang/rust/issues/128955#issuecomment-2657811196
2025-02-26Restore usage of io::Errorbjorn3-4/+7
2025-02-24codegen_llvm: avoid `Deref` impls w/ extern typeDavid Wood-11/+12
`rustc_codegen_llvm` relied on `Deref` impls where `Deref::Target` was or contained an extern type - in my experimental implementation of rust-lang/rfcs#3729, this isn't possible as the `Target` associated type's `?Sized` bound cannot be relaxed backwards compatibly (unless we come up with some way of doing this). In later pull requests with the rust-lang/rfcs#3729 implementation, breakage like this could only occur for nightly users relying on the `extern_types` feature. Upstreaming this to avoid needing to keep carrying this patch locally, and I think it'll necessarily need to change eventually.
2025-02-23Save pre-link bitcode to `ModuleCodegen`DianQK-15/+10
2025-02-23Add `new_regular` and `new_allocator` to `ModuleCodegen`DianQK-10/+3
2025-02-23The embedded bitcode should always be prepared for LTO/ThinLTODianQK-44/+99
2025-02-21update autodiff flagsManuel Drehwald-23/+62
2025-02-21clean up autodiff code/commentsManuel Drehwald-10/+5
2025-02-20Merge two operations that were always performed togetherOli Scherer-1/+1
2025-02-14Don't error when adding a staticlib with bitcode files compiled by newer LLVMbjorn3-6/+22
2025-02-13Make `-O` mean `-C opt-level=3`clubby789-2/+2
2025-02-12Rollup merge of #135549 - oli-obk:push-tmxtpnrloyqu, r=compiler-errorsMatthias Krüger-131/+92
Document some safety constraints and use more safe wrappers Lots of unsafe codegen_llvm code has safe wrappers already, so I used some of them and added some where applicable. I stopped here because this diff is large enough and should probably be reviewed independently of other changes.
2025-02-11Document some safety constraints and use more safe wrappersOli Scherer-43/+32
2025-02-11Add a safe wrapper for `WriteBitcodeToFile`Oli Scherer-8/+10
2025-02-11Remove an unsafe closure invariant by inlining the closure wrapper into the ↵Oli Scherer-80/+50
called function
2025-02-11Rollup merge of #136721 - dpaoliello:cleanllvm2, r=ZalatharJacob Pratt-3/+3
cg_llvm: Reduce visibility of some items outside the `llvm` module Next piece of #135502 This reduces the visibility of items (other than those in the `llvm` module) so that dead code analysis will correctly identify unused items.
2025-02-10rustc_codegen_llvm: Mark items as pub(crate) outside of the llvm moduleDaniel Paoliello-3/+3
2025-02-10move second opt run to lto phase and cleanup codeManuel Drehwald-18/+48
2025-02-07fix non-enzyme buildsManuel Drehwald-1/+3
2025-01-22rustc_codegen_llvm: remove outdated asm-to-obj codegen noteKen Matsui-6/+3
Remove comment about missing integrated assembler handling, which was removed in commit 02840ca.
2025-01-13Rollup merge of #133752 - klensy:cp, r=davidtwcoMatthias Krüger-7/+3
replace copypasted ModuleLlvm::parse replaced code same as in https://github.com/rust-lang/rust/blob/bd36e69d2533ee750e2d805915b8ca88d2825e0f/compiler/rustc_codegen_llvm/src/lib.rs#L426-L445 except before error message was emitted via `write::llvm_err`, which returned other error kind, but it still ok?
2025-01-07llvm: Ignore error value that is always falseMatthew Maurer-5/+1
See llvm/llvm-project#121851 For LLVM 20+, this function (`renameModuleForThinLTO`) has no return value. For prior versions of LLVM, this never failed, but had a signature which allowed an error value people were handling.
2025-01-01upstream rustc_codegen_llvm changes for enzyme/autodiffManuel Drehwald-7/+55
2024-12-30add llvm_floatabi field to target spec that controls FloatABITypeRalf Jung-4/+12
2024-12-30rustc_llvm: expose FloatABIType target machine parameterRalf Jung-7/+7
2024-12-29make -Csoft-float have an effect on all ARM targetsRalf Jung-1/+1
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-12Auto merge of #129181 - beetrees:asm-spans, r=pnkfelix,compiler-errorsbors-6/+17
Pass end position of span through inline ASM cookie Before this PR, only the start position of the span was passed though the inline ASM cookie to diagnostics. LLVM 19 has full support for 64-bit inline ASM cookies; this PR uses that to pass the end position of the span in the upper 32 bits, meaning inline ASM diagnostics now point at the entire line the error occurred on, not just the first character of it.
2024-12-02Use c"lit" for CStrings without unwrapKornel-2/+2
2024-12-02replace copypasted ModuleLlvm::parseklensy-7/+3
2024-11-26Respect verify-llvm-ir option in the backendNikita Popov-0/+4
We are currently unconditionally verifying the LLVM IR in the backend (twice), ignoring the value of the verify-llvm-ir option.
2024-11-26Pass end position of span through inline ASM cookiebeetrees-6/+17
2024-11-24embed-bitcode is no longer used in iOSDianQK-18/+1
2024-11-03Reduce dependence on the target namebjorn3-20/+9
The target name can be anything with custom target specs. Matching on fields inside the target spec is much more robust than matching on the target name.
2024-11-02Rename target triple to target tuple in many places in the compilerNoratrieb-3/+3
This changes the naming to the new naming, used by `--print target-tuple`. It does not change all locations, but many.
2024-11-02Rollup merge of #131037 - madsmtm:move-llvm-target-versioning, r=petrochenkovMatthias Krüger-1/+2
Move versioned Apple LLVM targets from `rustc_target` to `rustc_codegen_ssa` Fully specified LLVM targets contain the OS version on macOS/iOS/tvOS/watchOS/visionOS, and this version depends on the deployment target environment variables like `MACOSX_DEPLOYMENT_TARGET`, `IPHONEOS_DEPLOYMENT_TARGET` etc. We would like to move this to later in the compilation pipeline, both because it feels impure to access environment variables when fetching target information, but mostly because we need access to more information from https://github.com/rust-lang/rust/pull/130883 to do https://github.com/rust-lang/rust/issues/118204. See also https://github.com/rust-lang/rust/pull/129342#issuecomment-2335156119 for some discussion. The first and second commit does the actual refactor, it should be a non-functional change, the third commit adds diagnostics for invalid deployment targets, which are now possible to do because we have access to the session. Tested with the same commands as in https://github.com/rust-lang/rust/pull/130435. r? ``````@petrochenkov``````
2024-11-01Move versioned LLVM target creation to rustc_codegen_ssaMads Marquart-1/+2
The OS version depends on the deployment target environment variables, the access of which we want to move to later in the compilation pipeline that has access to more information, for example `env_depinfo`.
2024-10-31Remove support for `-Zprofile` (gcov-style coverage instrumentation)Zalathar-1/+0
2024-10-30Consistently use safe wrapper function `set_section`Zalathar-10/+9
2024-10-29Rollup merge of #132319 - Zalathar:add-module-flag, r=jieyouxuMatthias Krüger-18/+3
cg_llvm: Clean up FFI calls for setting module flags This is a combination of several inter-related changes to how module flags are set: - Remove some unnecessary code for setting an `"LTOPostLink"` flag, which has been obsolete since LLVM 17. - Define our own enum instead of relying on enum values defined by LLVM's unstable C++ API. - Use safe wrapper functions to set module flags, instead of direct `unsafe` calls. - Consistently pass pointer/length strings instead of C strings. - Remove or shrink some `unsafe` blocks.
2024-10-29Don't set unnecessary module flag "LTOPostLink"Zalathar-18/+3
This module flag was an internal detail of LLVM's optimization passes, and all code involving it was removed in LLVM 17. <https://github.com/llvm/llvm-project/commit/200cc952a28a73687ba24d5334415df6332f2d5b>
2024-10-29Rollup merge of #132216 - klensy:c_uint, r=cuviperJubilee-2/+2
correct LLVMRustCreateThinLTOData arg types `LLVMRustCreateThinLTOData` defined in rust as ```rust pub fn LLVMRustCreateThinLTOData( Modules: *const ThinLTOModule, NumModules: c_uint, PreservedSymbols: *const *const c_char, PreservedSymbolsLen: c_uint, ) -> Option<&'static mut ThinLTOData>; ``` but in cpp as ```cpp extern "C" LLVMRustThinLTOData * LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules, const char **preserved_symbols, int num_symbols) { ``` (note `c_unit` vs `int` types). Let it be actually `size_t`. Also fixes return type of `LLVMRustDIBuilderCreateOpLLVMFragment` to uint64_t as other similar functions around, which should be correct, i assume.
2024-10-29Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillotJubilee-1/+1
compiler: apply clippy::clone_on_ref_ptr for CI Apply lint https://rust-lang.github.io/rust-clippy/master/index.html#/clone_on_ref_ptr for compiler, also see https://github.com/rust-lang/rust/pull/131225#discussion_r1790109443. Some Arc's can be misplaced with Lrc's, sorry. https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/enable.20more.20clippy.20lints.20for.20compiler.20.28and.5Cor.20std.29
2024-10-29correct LLVMRustCreateThinLTOData arg typesklensy-2/+2
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-1/+1
2024-10-28Use a type-safe helper to cast `&str` and `&[u8]` to `*const c_char`Zalathar-6/+8
2024-10-26Use safe wrappers `get_linkage` and `set_linkage`Zalathar-4/+4
2024-09-26Use `&raw` in the compilerJosh Stone-1/+1
Like #130865 did for the standard library, we can use `&raw` in the compiler now that stage0 supports it. Also like the other issue, I did not make any doc or test changes at this time.