about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/consts.rs
AgeCommit message (Collapse)AuthorLines
2024-09-19Reduce visibility.Nicholas Nethercote-1/+1
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-09-05Rollup merge of #128820 - LYF1999:yf/dev, r=nikicMatthias Krüger-1/+1
fix: get llvm type of global val using `LLVMTypeOf` on a global var always return ptr. so create a new function to access the value type of a global
2024-09-04Remove macOS 10.10 dynamic linker bug workaroundbeetrees-52/+0
2024-08-27Rollup merge of #126013 - nnethercote:unreachable_pub, r=UrgauMatthias Krüger-1/+1
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal. There are plenty more crates to do but this seems like enough for a first PR. r? `@compiler-errors`
2024-08-20Avoid extra `cast()`s after `CStr::as_ptr()`Josh Stone-1/+1
These used to be `&str` literals that did need a pointer cast, but that became a no-op after switching to `c""` literals in #118566.
2024-08-16Add `warn(unreachable_pub)` to `rustc_codegen_llvm`.Nicholas Nethercote-1/+1
2024-08-09fix: get llvm type of global valyifei-1/+1
2024-07-30Move is_mingw_gnu_toolchain and i686_decorated_name to cg_ssabjorn3-2/+3
2024-07-29Reformat `use` declarations.Nicholas Nethercote-11/+12
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-20compiler: Never debug_assert in codegenJubilee Young-1/+1
The gains in performance are not worth the costs in correctness. This is partly because the gains are zero and the costs are unknown.
2024-07-19Rollup merge of #121533 - ratmice:wasm_init_fini_array, r=nnethercoteTrevor Gross-2/+8
Handle .init_array link_section specially on wasm Given that wasm-ld now has support for [.init_array](https://github.com/llvm/llvm-project/blob/8f2bd8ae68883592a333f4bdbed9798d66e68630/llvm/lib/MC/WasmObjectWriter.cpp#L1852), it appears we can easily implement that section by falling through to the normal path rather than taking the typical custom_section path for wasm. The wasm-ld appears to have a bunch of limitations. Only one static with the `link_section` in a crate or else you hit the fatal error in the link above "only one .init_array section fragment supported". They do not get merged. You can still call multiple constructors by setting it to an array. ``` unsafe extern "C" fn ctor() { println!("foo"); } #[used] #[link_section = ".init_array"] static FOO: [unsafe extern "C" fn(); 2] = [ctor, ctor]; ``` Another issue appears to be that if crate *A* depends on crate *B*, but *A* doesn't call any symbols from *B* and *B* doesn't `#[export_name = ...]` any symbols, then crate *B*'s constructor will not be called. The workaround to this is to provide an exported symbol in crate *B*.
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_codegen_llvm`.Nicholas Nethercote-0/+1
2024-04-22Rollup merge of #124178 - GuillaumeGomez:llvm-backend, r=oli-obkGuillaume Gomez-3/+4
[cleanup] [llvm backend] Prevent creating the same `Instance::mono` multiple times Just a little thing I came across while going through the code. r? ```@oli-obk```
2024-04-19Prevent creating the same `Instance::mono` multiple timesGuillaume Gomez-3/+4
2024-04-16Codegen ZSTs without an allocationMark Rousskov-2/+16
This makes sure that &[] is just as efficient as indirecting through unsafe code (from_raw_parts). No new stable guarantee is intended about whether or not we do this, this is just an optimization. Co-authored-by: Ralf Jung <post@ralfj.de>
2024-03-12Some comment nitsOli Scherer-3/+2
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-3/+18
2024-03-12Make some functions private that are only ever used in the same moduleOli Scherer-1/+1
2024-03-12Stop requiring a type when codegenning types. We can get all the type info ↵Oli Scherer-10/+3
we need from the `ConstAllocation`
2024-03-12Check whether a static is mutable instead of passing it downOli Scherer-5/+5
2024-03-12Swap the order of a piece of code to make follow up diffs simplerOli Scherer-2/+2
2024-03-12Use information from allocation instead of from the static's typeOli Scherer-2/+6
2024-03-12Move `codegen_static` function body to an inherent method in preparation of ↵Oli Scherer-23/+27
splitting it. This should make the diff easier to read, as this commit does no functional changes at all.
2024-03-12Reduce some duplicate work that is being done around staticsOli Scherer-8/+18
2024-03-12Share the llvm type computation between both arms of a conditionOli Scherer-5/+4
2024-02-23Handle .init_array link_section specially on wasmmatt rice-2/+8
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-3/+3
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-14Auto merge of #118566 - klensy:cstr-new, r=WaffleLapkinbors-4/+3
use c literals in compiler and library Relands refreshed https://github.com/rust-lang/rust/pull/111647
2023-12-07ctfe interpreter: extend provenance so that it can track whether a pointer ↵Ralf Jung-6/+3
is immutable
2023-12-03compiler: replace cstr macro with c str literals in compiler and few other c ↵klensy-4/+3
str replacements
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-03consts: remove dead code around `i1` constant valuesAugie Fackler-9/+1
`LLVMConstZext` recently got deleted, and it turns out (thanks to @nikic for knowing!) that this is dead code. Tests all pass for me without this logic, and per nikic: > We always generate constants in "relocatable bag of bytes" > representation, so you're never going to get a plain bool. So this should be a safe thing to do. r? @nikic @rustbot label: +llvm-main
2023-10-13Format all the let chains in compilerMichael Goulet-3/+10
2023-08-01Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3bors-13/+7
cleanup: remove pointee types This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after #114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.) I initially hoped this would provide some minor perf win, but in https://github.com/rust-lang/rust/pull/105412#issuecomment-1341224450 it had very little impact, so this is only valuable as a cleanup. As a followup, this will enable #96242 to be resolved. r? `@ghost` `@rustbot` label S-blocked
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-2/+1
2023-07-29cg_ssa: remove pointee types and pointercast/bitcast-of-ptrErik Desjardins-4/+0
2023-07-29cg_llvm: remove pointee types and pointercast/bitcast-of-ptrErik Desjardins-9/+7
2023-07-05Revert "use new c literals instead of cstr! macro"León Orell Valerian Liehr-3/+4
This reverts commit a17561ffc90c900cb7d0e96b00c6381244764ef7.
2023-06-02Rollup merge of #111647 - klensy:cstr, r=oli-obkMatthias Krüger-4/+3
use c literals in compiler and library Use c literals #108801 in compiler and library currently blocked on: * <strike>rustfmt: don't know how to format c literals</strike> nope, nightly one works. * <strike>bootstrap</strike> r? `@ghost` `@rustbot` blocked
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-5/+14
2023-05-31use new c literals instead of cstr! macroklensy-4/+3
2023-04-05reviewklensy-10/+7
2023-02-16fix some lines, and do a consistency fixTshepang Mbambo-2/+2
2023-02-10Update the minimum external LLVM to 14Josh Stone-8/+1
2023-01-25create and use GlobalAlloc::address_spaceErik Desjardins-10/+3
2023-01-22abi: add `AddressSpace` field to `Primitive::Pointer`Erik Desjardins-1/+1
...and remove it from `PointeeInfo`, which isn't meant for this. There are still various places (marked with FIXMEs) that assume all pointers have the same size and alignment. Fixing this requires parsing non-default address spaces in the data layout string, which will be done in a followup.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-2/+2
2022-12-05Move linkage type check to HIR analysis and fix semantics issues.Peter Collingbourne-14/+4
This ensures that the error is printed even for unused variables, as well as unifying the handling between the LLVM and GCC backends. This also fixes unusual behavior around exported Rust-defined variables with linkage attributes. With the previous behavior, it appears to be impossible to define such a variable such that it can actually be imported and used by another crate. This is because on the importing side, the variable is required to be a pointer, but on the exporting side, the type checker rejects static variables of pointer type because they do not implement `Sync`. Even if it were possible to import such a type, it appears that code generation on the importing side would add an unexpected additional level of pointer indirection, which would break type safety. This highlighted that the semantics of linkage on Rust-defined variables is different to linkage on foreign items. As such, we now model the difference with two different codegen attributes: linkage for Rust-defined variables, and import_linkage for foreign items. This change gives semantics to the test src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs which was previously expected to fail to compile. Therefore, convert it into a test that is expected to successfully compile. The update to the GCC backend is speculative and untested.
2022-11-29codegen-llvm: never combine DSOLocal and DllImportDavid Rheinsberg-6/+10
Prevent DllImport from being attached to DSOLocal definitions in the LLVM IR. The combination makes no sense, since definitions local to the compilation unit will never be imported from external objects. Additionally, LLVM will refuse the IR if it encounters the combination (introduced in [1]): if (GV.hasDLLImportStorageClass()) Assert(!GV.isDSOLocal(), "GlobalValue with DLLImport Storage is dso_local!", &GV); Right now, codegen-llvm will only apply DllImport to constants and rely on call-stubs for functions. Hence, we simply extend the codegen of constants to skip DllImport for any local definitions. This was discovered when switching the EFI targets to the static relocation model [2]. With this fixed, we can start another attempt at this. [1] https://smlnj-gitlab.cs.uchicago.edu/manticore/llvm/commit/509132b368efed10bbdad825403f45e9cf1d6e38 [2] https://github.com/rust-lang/rust/issues/101656