about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/consts.rs
AgeCommit message (Collapse)AuthorLines
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
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
2022-11-15Auto merge of #104054 - RalfJung:byte-provenance, r=oli-obkbors-7/+5
interpret: support for per-byte provenance Also factors the provenance map into its own module. The third commit does the same for the init mask. I can move it in a separate PR if you prefer. Fixes https://github.com/rust-lang/miri/issues/2181 r? `@oli-obk`
2022-11-09Reuse SymbolAlreadyDefinedSLASHLogin-5/+5
2022-11-09Port LinkageConstOrMutType errorSLASHLogin-8/+3
2022-11-09Port InvalidMinimumAlignmentSLASHLogin-1/+4
2022-11-06move InitMask to its own moduleRalf Jung-3/+1
2022-11-06interpret: support for per-byte provenanceRalf Jung-4/+4
2022-11-03Fix Access Violation when using lld & ThinLTO on windows-msvcWesley Wiser-1/+3
Users report an AV at runtime of the compiled binary when using lld and ThinLTO on windows-msvc. The AV occurs when accessing a static value which is defined in one crate but used in another. Based on the disassembly of the cross-crate use, it appears that the use is not correctly linked with the definition and is instead assigned a garbage pointer value. If we look at the symbol tables for each crates' obj file, we can see what is happening: *lib.obj*: ``` COFF SYMBOL TABLE ... 00E 00000000 SECT2 notype External | _ZN10reproducer7memrchr2FN17h612b61ca0e168901E ... ``` *bin.obj*: ``` COFF SYMBOL TABLE ... 010 00000000 UNDEF notype External | __imp__ZN10reproducer7memrchr2FN17h612b61ca0e168901E ... ``` The use of the symbol has the "import" style symbol name but the declaration doesn't generate any symbol with the same name. As a result, linking the files generates a warning from lld: > rust-lld: warning: bin.obj: locally defined symbol imported: reproducer::memrchr::FN::h612b61ca0e168901 (defined in lib.obj) [LNK4217] and the symbol reference remains undefined at runtime leading to the AV. To fix this, we just need to detect that we are performing ThinLTO (and thus, static linking) and omit the `dllimport` attribute on the extern item in LLVM IR.
2022-10-19Get rid of native_library projection queriesnils-1/+4
They don't seem particularly useful as I don't expect native libraries to change frequently.
2022-09-27rustc_typeck to rustc_hir_analysislcnr-1/+1
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-08-27interpret: rename relocation → provenanceRalf Jung-11/+11
2022-08-26Implementation of import_name_typeDaniel Paoliello-4/+8
2022-07-22Auto merge of #99420 - RalfJung:vtable, r=oli-obkbors-1/+3
make vtable pointers entirely opaque This implements the scheme discussed in https://github.com/rust-lang/unsafe-code-guidelines/issues/338: vtable pointers should be considered entirely opaque and not even readable by Rust code, similar to function pointers. - We have a new kind of `GlobalAlloc` that symbolically refers to a vtable. - Miri uses that kind of allocation when generating a vtable. - The codegen backends, upon encountering such an allocation, call `vtable_allocation` to obtain an actually dataful allocation for this vtable. - We need new intrinsics to obtain the size and align from a vtable (for some `ptr::metadata` APIs), since direct accesses are UB now. I had to touch quite a bit of code that I am not very familiar with, so some of this might not make much sense... r? `@oli-obk`