about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/mono_item.rs
AgeCommit message (Collapse)AuthorLines
2025-08-24Replace the `llvm::Bool` typedef with a proper newtypeZalathar-1/+1
2025-08-13Port the `#[linkage]` attribute to the new attribute systemSasha Pourcelot-1/+2
2025-07-18Rollup merge of #143293 - folkertdev:naked-function-kcfi, r=compiler-errorsMatthias Krüger-2/+2
fix `-Zsanitizer=kcfi` on `#[naked]` functions fixes https://github.com/rust-lang/rust/issues/143266 With `-Zsanitizer=kcfi`, indirect calls happen via generated intermediate shim that forwards the call. The generated shim preserves the attributes of the original, including `#[unsafe(naked)]`. The shim is not a naked function though, and violates its invariants (like having a body that consists of a single `naked_asm!` call). My fix here is to match on the `InstanceKind`, and only use `codegen_naked_asm` when the instance is not a `ReifyShim`. That does beg the question whether there are other `InstanceKind`s that could come up. As far as I can tell the answer is no: calling via `dyn` seems to work find, and `#[track_caller]` is disallowed in combination with `#[naked]`. r? codegen ````@rustbot```` label +A-naked cc ````@maurer```` ````@rcvalle````
2025-07-16use `codegen_instance_attrs` where an instance is (easily) availableFolkert de Vries-2/+2
2025-07-14Shrink some `unsafe` blocks in cg_llvmOli Scherer-2/+2
2025-05-28Make predefine methods take &mut selfbjorn3-2/+2
2025-03-25Rename `is_like_osx` to `is_like_darwin`Mads Marquart-1/+1
2025-02-20Merge two operations that were always performed togetherOli Scherer-13/+12
2025-02-07Remove Linkage::Privatebjorn3-4/+1
This is the same as Linkage::Internal except that it doesn't emit any symbol. Some backends may not support it and it isn't all that useful anyway.
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-6/+3
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-10-26Use safe wrappers `get_visibility` and `set_visibility`Zalathar-13/+7
2024-10-26Use safe wrappers `get_linkage` and `set_linkage`Zalathar-3/+3
2024-10-19cg_llvm: Reuse LLVM-C Comdat supportJubilee Young-1/+3
Migrate `llvm::set_comdat` and `llvm::SetUniqueComdat` to LLVM-C FFI. Note, now we can call `llvm::set_comdat` only when the target actually supports adding comdat. As this has no convenient LLVM-C API, we implement this as `TargetOptions::supports_comdat`. Co-authored-by: Stuart Cook <Zalathar@users.noreply.github.com>
2024-09-19Reformat some comments.Nicholas Nethercote-2/+2
So they are less than 100 chars.
2024-09-17Rename supertraits of `CodegenMethods`.Nicholas Nethercote-1/+1
Supertraits of `BuilderMethods` are all called `XyzBuilderMethods`. Supertraits of `CodegenMethods` are all called `XyzMethods`. This commit changes the latter to `XyzCodegenMethods`, for consistency.
2024-08-07codegen: better centralize function attribute computationRalf Jung-3/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-6/+5
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-16Fix unsafe_op_in_unsafe_fn in compilerMichael Goulet-4/+4
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_codegen_llvm`.Nicholas Nethercote-0/+1
2024-03-12Some comment nitsOli Scherer-1/+1
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-1/+10
2024-01-16Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`WANG Rui-10/+15
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-0/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-10-22use visibility to check unused imports and delete some stmtsbohan-1/+0
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-1/+1
Removes a piece of mutable state. Follow up to #114578.
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-1/+1
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-2/+1
2023-05-09CFI: Fix SIGILL reached via trait objectsRamon de C Valle-1/+1
Fix #106547 by transforming the concrete self into a reference to a trait object before emitting type metadata identifiers for trait methods.
2023-04-27rename `needs_infer` to `has_infer`Boxy-1/+1
2023-02-22Remove type-traversal trait aliasesAlan Egerton-1/+1
2022-11-09Fix diag() and formattingSLASHLogin-1/+3
2022-11-09Port `symbol_already_defined` errorSLASHLogin-4/+1
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-07-06Update TypeVisitor pathsAlan Egerton-1/+1
2021-12-16Remove `in_band_lifetimes` from `rustc_codegen_llvm`LegionMammal978-2/+2
See #91867 for more information.
2021-10-01Fix clippy lintsGuillaume Gomez-7/+3
2021-10-01Rollup merge of #88820 - hlopko:add_pie_relocation_model, r=petrochenkovManish Goregaokar-0/+6
Add `pie` as another `relocation-model` value MCP: https://github.com/rust-lang/compiler-team/issues/461
2021-10-01Add `pie` as another `relocation-model` valueMarcel Hlopko-0/+6
2021-09-18Querify `fn_abi_of_{fn_ptr,instance}`.Eduard-Mihai Burtescu-1/+1
2021-09-18ty::layout: replicate `layout_of` setup for `fn_abi_of_{fn_ptr,instance}`.Eduard-Mihai Burtescu-3/+2
2021-09-02rustc_target: move `LayoutOf` to `ty::layout`.Eduard-Mihai Burtescu-2/+1
2021-08-20Stop emitting the `dso_local` LLVM attribute for external symbols under the ↵Patrick Walton-0/+5
static relocation model on macOS. This matches Clang's behavior: https://github.com/llvm/llvm-project/blob/973cb2c326be9f256da0897c4d2ef117dc22761d/clang/lib/CodeGen/CodeGenModule.cpp#L1038-L1040 Even if `dso_local` were properly supported in this way on macOS, it seems incorrect to add this annotation as liberally as we did. The `dso_local` annotation is for symbols that ultimately end up in the same linkage unit, but we were adding this annotation even for `static` values inside `extern` blocks marked with `#[link(type="framework")]`, which should be considered dynamically linked. Note that Clang likewise avoids emitting `dso_local` for `dllimport` symbols: https://github.com/llvm/llvm-project/blob/973cb2c326be9f256da0897c4d2ef117dc22761d/clang/lib/CodeGen/CodeGenModule.cpp#L1005-L1007 This issue caused breakage in the `ring` crate, which links to a symbol defined in `Security.framework` that ultimately resolves to address `0x0`: https://github.com/briansmith/ring/blob/b94d61e044b42827fefd71d5f61e8c58a7659870/src/rand.rs#L390 For this symbol, the use of `dso_local` causes LLVM to emit a relocation of type `X86_64_RELOC_SIGNED`, which is a 32-bit signed PC-relative offset. If the binary is large enough, `0x0` might be out of range, and the link will fail. Avoiding `dso_local` causes LLVM to use the GOT instead, emitting a relocation of type `X86_64_RELOC_GOT_LOAD`, which will properly handle the large offset and cause the link to succeed. As a side note, the static relocation model is effectively deprecated for security reasons on macOS, as it prohibits PIE. It's also completely unsupported on Apple Silicon, so I don't think it's worth going to the effort of properly supporting this model on that platform.
2021-05-28Fix static relocation model for PowerPC64Boris-Chengbiao Zhou-11/+31
We now also use `should_assume_dso_local()` for declarations and port two additional cases from clang: - Exclude PPC64 [1] - Exclude thread-local variables [2] [1]: https://github.com/llvm/llvm-project/blob/033138ea452f5f493fb5095e5963419905ad12e1/clang/lib/CodeGen/CodeGenModule.cpp#L1038-L1040 [2]: https://github.com/llvm/llvm-project/blob/033138ea452f5f493fb5095e5963419905ad12e1/clang/lib/CodeGen/CodeGenModule.cpp#L1048-L1050
2021-04-03Manually set dso_local when its valid to do soSimonas Kazlauskas-0/+41
This should have no real effect in most cases, as e.g. `hidden` visibility already implies `dso_local` (or at least LLVM IR does not preserve the `dso_local` setting if the item is already `hidden`), but it should fix `-Crelocation-model=static` and improve codegen in executables. Note that this PR does not exhaustively port the logic in [clang]. Only the obviously correct portion and what is necessary to fix a regression from LLVM 12 that relates to `-Crelocation_model=static`. Fixes #83335 [clang]: https://github.com/llvm/llvm-project/blob/3001d080c813da20b329303bf8f45451480e5905/clang/lib/CodeGen/CodeGenModule.cpp#L945-L1039
2020-08-30mv compiler to compiler/mark-0/+84