about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2022-11-09Missing lifetime parameter and formattingSLASHLogin-5/+2
2022-11-09Change String in structs to &'a strSLASHLogin-6/+6
2022-11-09FormattingSLASHLogin-6/+14
2022-11-09Port unknown feature diagnostic to the new frameworkSLASHLogin-17/+37
2022-11-08Rollup merge of #103353 - wesleywiser:fix_lld_thinlto_msvc, r=michaelwoeristerManish Goregaokar-1/+3
Fix Access Violation when using lld & ThinLTO on windows-msvc 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. Fixes #81408
2022-11-08prevent uninitialized access in black_box for zero-sized-typesKrasimir Georgiev-3/+12
2022-11-08llvm: dwo only emitted when object code emittedDavid Wood-3/+13
`CompiledModule` should not think a DWARF object was emitted when a bitcode-only compilation has happened, this can confuse archive file creation (which expects to create an archive containing non-existent dwo files). Signed-off-by: David Wood <david.wood@huawei.com>
2022-11-07Rollup merge of #104066 - TimNN:riscv-layout, r=nikicYuki Okushi-0/+4
LLVM 16: Update RISCV data layout The RISCV data layout was changed in https://github.com/llvm/llvm-project/commit/974e2e690b4024c2677dde26cc76ec31e0047c1d. This updates all `riscv64*` targets, though I don't really know what the difference between the `gc` and `imac` ones is. Passes `x test codegen` at LLVM head and with the currently bundled LLVM version. Without this patch, some tests fail with: > error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:192:13: data-layout for target `riscv64gc-unknown-none-elf`, `e-m:e-p:64:64-i64:64-i128:128-n64-S128`, differs from LLVM target's `riscv64` default layout, `e-m:e-p:64:64-i64:64-i128:128-n32:64-S128
2022-11-06LLVM 16: Update RISCV data layoutTim Neumann-0/+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-06Add type_array to BaseTypeMethodsAyush Singh-4/+4
Moved type_array function to rustc_codegen_ssa::BaseTypeMethods trait. This allows using normal alloca function to create arrays as suggested in https://github.com/rust-lang/rust/pull/104022. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-05Rollup merge of #103977 - TimNN:memory-effects, r=nikicMatthias Krüger-7/+23
LLVM 16: Switch to using MemoryEffects This adapts the compiler to the changes required by https://github.com/llvm/llvm-project/commit/304f1d59ca41872c094def3aee0a8689df6aa398. AFAICT, `WriteOnly` isn't used by the compiler, all `ReadNone` uses were migrated and the remaining use of `ReadOnly` is only for function parameters. To simplify the FFI, this PR uses an enum to represent `MemoryEffects` across the FFI boundary, which then gets mapped to the matching static factory method when constructing the attribute. Fixes #103961. `@rustbot` label +llvm-main r? `@nikic`
2022-11-04LLVM 16: Switch to using MemoryEffectsTim Neumann-7/+23
2022-11-04Rollup merge of #103897 - Amanieu:llvm-58384, r=davidtwcoMatthias Krüger-3/+54
asm: Work around LLVM bug on AArch64 Upstream issue: https://github.com/llvm/llvm-project/issues/58384 LLVM gets confused if we assign a 32-bit value to a 64-bit register, so pass the 32-bit register name to LLVM in that case.
2022-11-04Auto merge of #103098 - Amanieu:asm-tied-fixed, r=bjorn3bors-2/+11
asm: Match clang behavior for inlateout fixed register operands We have 2 options for representing LLVM constraints for `inlateout` operands on a fixed register (e.g. `r0`): `={r0},0` or `={r0},{r0}`. This PR changes the behavior to the latter, which matches the behavior of Clang since https://reviews.llvm.org/D87279.
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-11-02asm: Work around LLVM bug on AArch64Amanieu d'Antras-3/+54
Upstream issue: https://github.com/llvm/llvm-project/issues/58384 LLVM gets confused if we assign a 32-bit value to a 64-bit register, so pass the 32-bit register name to LLVM in that case.
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-5/+4
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-30Auto merge of #103299 - nikic:usub-overflow, r=wesleywiserbors-5/+8
Don't use usub.with.overflow intrinsic The canonical form of a usub.with.overflow check in LLVM are separate sub + icmp instructions, rather than a usub.with.overflow intrinsic. Using usub.with.overflow will generally result in worse optimization potential. The backend will attempt to form usub.with.overflow when it comes to actual instruction selection. This is not fully reliable, but I believe this is a better tradeoff than using the intrinsic in IR. Fixes #103285.
2022-10-24Support raw-dylib functions being used inside inlined functionsDaniel Paoliello-2/+5
2022-10-23Introduce dedicated `-Zdylib-lto` flag for enabling LTO on `dylib`sJakub Beránek-1/+15
2022-10-23Allow LTO for dylibsbjorn3-13/+4
2022-10-20Don't use usub.with.overflow intrinsicNikita Popov-5/+8
The canonical form of a usub.with.overflow check in LLVM are separate sub + icmp instructions, rather than a usub.with.overflow intrinsic. Using usub.with.overflow will generally result in worse optimization potential. The backend will attempt to form usub.with.overflow when it comes to actual instruction selection. This is not fully reliable, but I believe this is a better tradeoff than using the intrinsic in IR. Fixes #103285.
2022-10-19Get rid of native_library projection queriesnils-2/+6
They don't seem particularly useful as I don't expect native libraries to change frequently.
2022-10-15asm: Match clang behavior for inlateout fixed register operandsAmanieu d'Antras-2/+11
We have 2 options for representing LLVM constraints for `inlateout` operands on a fixed register (e.g. `r0`): `={r0},0` or `={r0},{r0}`. This PR changes the behavior to the latter, which matches the behavior of Clang since https://reviews.llvm.org/D87279.
2022-10-14Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8KiDylan DPC-1/+1
More dupe word typos I only picked those changes (from the regex search) that I am pretty certain doesn't change meaning and is just a typo fix. Do correct me if any fix is undesirable and I can revert those. Thanks.
2022-10-14Rollup merge of #103015 - whentojump:patch, r=compiler-errorsDylan DPC-1/+1
fix a typo
2022-10-14more dupe word typosRageking8-1/+1
2022-10-13Add links to relevant pages to find constraint informationGuillaume Gomez-0/+4
2022-10-14fix a typowtj-1/+1
2022-10-09Pass 128-bit C-style enum enumerator values to LLVMbeetrees-12/+9
2022-10-06Rollup merge of #102725 - nnethercote:rm-Z-time, r=davidtwcoMatthias Krüger-1/+1
Remove `-Ztime` Because it has a lot of overlap with `-Ztime-passes` but is generally less useful. Plus some related cleanups. Best reviewed one commit at a time. r? `@davidtwco`
2022-10-06Remove `-Ztime` option.Nicholas Nethercote-1/+1
The compiler currently has `-Ztime` and `-Ztime-passes`. I've used `-Ztime-passes` for years but only recently learned about `-Ztime`. What's the difference? Let's look at the `-Zhelp` output: ``` -Z time=val -- measure time of rustc processes (default: no) -Z time-passes=val -- measure time of each rustc pass (default: no) ``` The `-Ztime-passes` description is clear, but the `-Ztime` one is less so. Sounds like it measures the time for the entire process? No. The real difference is that `-Ztime-passes` prints out info about passes, and `-Ztime` does the same, but only for a subset of those passes. More specifically, there is a distinction in the profiling code between a "verbose generic activity" and an "extra verbose generic activity". `-Ztime-passes` prints both kinds, while `-Ztime` only prints the first one. (It took me a close reading of the source code to determine this difference.) In practice this distinction has low value. Perhaps in the past the "extra verbose" output was more voluminous, but now that we only print stats for a pass if it exceeds 5ms or alters the RSS, `-Ztime-passes` is less spammy. Also, a lot of the "extra verbose" cases are for individual lint passes, and you need to also use `-Zno-interleave-lints` to see those anyway. Therefore, this commit removes `-Ztime` and the associated machinery. One thing to note is that the existing "extra verbose" activities all have an extra string argument, so the commit adds the ability to accept an extra argument to the "verbose" activities.
2022-10-06Auto merge of #99324 - reez12g:issue-99144, r=jyn514bors-1/+0
Enable doctests in compiler/ crates Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-05Auto merge of #98736 - alex:lipo-magic, r=bjorn3bors-3/+65
resolve error when attempting to link a universal library on macOS Previously attempting to link universal libraries into libraries (but not binaries) would produce an error that "File too small to be an archive". This works around this by invoking `lipo -thin` to extract a library for the target platform when passed a univeral library. Fixes #55235 It's worth acknowledging that this implementation is kind of a horrible hack. Unfortunately I don't know how to do anything better, hopefully this PR will be a jumping off point.
2022-10-04resolve error when attempting to link a universal library on macOSAlex Gaynor-3/+65
Previously attempting to link universal libraries into libraries (but not binaries) would produce an error that "File too small to be an archive". This works around this by using `object` to extract a library for the target platform when passed a univeral library. Fixes #55235
2022-10-03Auto merge of #102551 - bjorn3:cg_ssa_cleanup, r=davidtwcobors-66/+65
Some more cleanup for rustc_codegen_ssa With the aim to make non-LLVM like backends, like Cranelift, easier to support using cg_ssa.
2022-10-02Remove type argument of array_alloca and rename to byte_array_allocabjorn3-2/+3
2022-10-02Remove dynamic_alloca from BuilderMethodsbjorn3-5/+1
2022-10-02Auto merge of #102424 - sunfishcode:sunfishcode/hidden-main, r=nagisabors-1/+11
Declare `main` as visibility hidden on targets that default to hidden. On targets with `default_hidden_visibility` set, which is currrently just WebAssembly, declare the generated `main` function with visibility hidden. This makes it consistent with clang's WebAssembly target, where `main` is just a user function that gets the same visibility as any other user function, which is hidden on WebAssembly unless explicitly overridden. This will help simplify use cases which in the future may want to automatically wasm-export all visibility-"default" symbols. `main` isn't intended to be wasm-exported, and marking it hidden prevents it from being wasm-exported in that scenario.
2022-10-01Merge apply_attrs_callsite into call and invokebjorn3-28/+51
Some codegen backends are not able to apply callsite attrs after the fact.
2022-10-01Remove unused target_cpu and tune_cpu methods from ExtraBackendMethodsbjorn3-6/+0
2022-10-01Remove several unused methods from MiscMethodsbjorn3-24/+10
2022-10-01Remove unused Context assoc type from WriteBackendMethodsbjorn3-1/+0
2022-09-29Adjust the s390x data layout for LLVM 16Josh Stone-0/+5
LLVM [D131158] changed the SystemZ data layout to always set 64-bit vector alignment, which used to be conditional on the "vector" feature. [D131158]: https://reviews.llvm.org/D131158
2022-09-29Remove from compiler/ cratesreez12g-1/+0
2022-09-28Change `declare_cfn` to use the C visibility for all C ABI functions.Dan Gohman-36/+15
2022-09-28Use the existing `set_visibility` function.Dan Gohman-7/+1
2022-09-28Declare `main` as visibility hidden on targets that default to hidden.Dan Gohman-9/+46
On targets with `default_hidden_visibility` set, which is currrently just WebAssembly, declare the generated `main` function with visibility hidden. This makes it consistent with clang's WebAssembly target, where `main` is just a user function that gets the same visibility as any other user function, which is hidden on WebAssembly unless explicitly overridden. This will help simplify use cases which in the future may want to automatically wasm-export all visibility-"default" symbols. `main` isn't intended to be wasm-exported, and marking it hidden prevents it from being wasm-exported in that scenario.