Commit Graph

67 Commits

Author SHA1 Message Date
Zalathar c3071590ab Clean up FFI calls for operand bundles 2024-10-30 13:26:24 +11:00
Zalathar 4bd84b23a8 Use a type-safe helper to cast &str and &[u8] to *const c_char 2024-10-28 21:31:32 +11:00
Zalathar 983d258be3 Use safe wrappers get_linkage and set_linkage 2024-10-26 20:20:18 +11:00
DianQK 1efffe720d LLVMConstInt only allows integer types 2024-10-12 23:02:15 +08:00
Jubilee Young 1379ef592a compiler: Factor rustc_target::abi out of cg_llvm 2024-10-08 18:24:56 -07:00
bors 4cbfcf1b7f Auto merge of #130389 - Luv-Ray:LLVMMDNodeInContext2, r=nikic
llvm: replace some deprecated functions

`LLVMMDStringInContext` and `LLVMMDNodeInContext` are deprecated, replace them with `LLVMMDStringInContext2` and `LLVMMDNodeInContext2`.
Also replace `Value` with `Metadata` in some function signatures for better consistency.
2024-09-24 12:07:48 +00:00
Michael Goulet 702a644b74 Check vtable projections for validity in miri 2024-09-23 19:38:26 -04:00
Nicholas Nethercote bfef2611d9 Reorder ConstMethods.
It's crazy to have the integer methods in something close to random
order.

The reordering makes the gaps clear: `const_i64`, `const_i128`,
`const_isize`, and `const_u16`. I guess they just aren't needed.
2024-09-19 20:10:42 +10:00
Luv-Ray b7c5656713 replace some deprecated functions 2024-09-19 09:39:28 +08:00
Nicholas Nethercote a8d22eb39e Rename supertraits of CodegenMethods.
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-17 10:24:43 +10:00
Nicholas Nethercote 61627438eb Add warn(unreachable_pub) to rustc_codegen_llvm. 2024-08-16 08:46:57 +10:00
Guillaume Gomez aea5087964 Rollup merge of #128537 - Jamesbarford:118980-const-vector, r=RalfJung,nikic
const vector passed through to codegen

This allows constant vectors using a repr(simd) type to be propagated
through to the backend by reusing the functionality used to do a similar
thing for the simd_shuffle intrinsic

#118209

r​? RalfJung
2024-08-12 17:09:15 +02:00
James Barford-Evans 27ca35aa1b const vector passed to codegen 2024-08-08 11:15:03 +01:00
bjorn3 bb764bd406 Move is_mingw_gnu_toolchain and i686_decorated_name to cg_ssa 2024-07-30 10:30:09 +00:00
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Ralf Jung 41b98da42d Miri function identity hack: account for possible inlining 2024-07-02 21:05:30 +02:00
bjorn3 98e8601ac3 Remove const_bitcast from ConstMethods 2024-06-21 19:26:07 +00:00
Ralf Jung 3c57ea0df7 ScalarInt: size mismatches are a bug, do not delay the panic 2024-06-10 13:43:16 +02:00
Nicholas Nethercote 8e94226e61 Remove #[macro_use] extern crate tracing from rustc_codegen_llvm. 2024-05-23 18:02:40 +10:00
Mark Rousskov 649e80184b Codegen ZSTs without an allocation
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-04-16 21:13:21 -04:00
Scott McMurray 3da115a93b Add+Use mir::BinOp::Cmp 2024-03-23 23:23:41 -07:00
erer1243 3af28f0b70 Fix 32-bit overflows in LLVM composite constants 2024-03-10 17:54:55 -04:00
Ralf Jung cb86303342 ctfe interpreter: extend provenance so that it can track whether a pointer is immutable 2023-12-07 17:46:36 +01:00
Thom Chiovoloni 268f5c57b9 Ensure strings created with const_str get the unnamed_addr attribute 2023-11-15 07:56:40 +00:00
bors abd3637e42 Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3
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-08-01 19:44:17 +00:00
Matthias Krüger 3ce90b1649 inline format!() args up to and including rustc_codegen_llvm 2023-07-30 14:22:50 +02:00
Erik Desjardins 04303cfb3a cg_ssa: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:20 -04:00
Erik Desjardins b6540777fe cg_llvm: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:17 -04:00
Jubilee Young 0726c7826b Reuse LLVMConstInBoundsGEP2
We have had LLVM 14 as our minimum for a bit now.
2023-07-10 00:20:56 -07:00
DonoughLiu 204bfb6a8c Support 128-bit enum variant in debuginfo codegen 2023-06-10 03:39:24 +08:00
Oli Scherer 164d041e30 Stop creating intermediate places just to immediate convert them to operands 2023-05-26 15:01:29 +00:00
Ben Kimock 0445fbdd83 Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
Matthias Krüger 5a07e33d2c use and_then/flat_map for map().flatten() 2023-04-01 23:50:45 +02:00
Nikita Popov 30331828cb Use poison instead of undef
In cases where it is legal, we should prefer poison values over
undef values.

This replaces undef with poison for aggregate construction and
for uninhabited types. There are more places where we can likely
use poison, but I wanted to stay conservative to start with.

In particular the aggregate case is important for newer LLVM
versions, which are not able to handle an undef base value during
early optimization due to poison-propagation concerns.
2023-03-16 15:07:04 +01:00
John Kåre Alsaker a913a2bca9 Name LLVM anonymous constants by a hash of their contents 2023-02-25 08:53:41 +01:00
Erik Desjardins 009192b01b abi: add AddressSpace field to Primitive::Pointer
...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-22 23:41:39 -05:00
Tomasz Miąsko 7279106166 Introduce a fallible variant of LLVMConstIntGetZExtValue
which verifies that a constant bit width is within 64 bits or fails.
2022-09-09 15:54:14 +02:00
Oli Scherer 9c4fb018ca Remove dead broken code from const zst handling in backends 2022-09-06 14:09:49 +00:00
Oli Scherer ee3c835018 Always import all tracing macros for the entire crate instead of piecemeal by module 2022-09-01 14:54:27 +00:00
Daniel Paoliello cc49c3e582 Implementation of import_name_type 2022-08-26 09:15:35 -07:00
Ralf Jung adf6d37d83 slightly cleaner, if more verbose, vtable handling in codegen backends 2022-07-20 17:12:07 -04:00
Ralf Jung 3dad266f40 consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable) 2022-07-20 17:12:07 -04:00
Ralf Jung da5e4d73f1 add a Vtable kind of symbolic allocations 2022-07-20 16:57:31 -04:00
Ralf Jung a422b42159 don't allow ZST in ScalarInt
There are several indications that we should not ZST as a ScalarInt:
- We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it.
  `ValTree::zst()` used the former, but the latter could possibly arise as well.
- Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`.
- LLVM codegen already had to special-case ZST ScalarInt.

So instead add new ZST variants to those types that did not have other variants
which could be used for this purpose.
2022-07-09 07:27:29 -04:00
bors 1dcff2d507 Auto merge of #98638 - bjorn3:less_string_interning, r=tmiasko
Use less string interning

This removes string interning in a couple of places where doing so won't result in perf improvements. I also switched one place to use pre-interned symbols.
2022-07-08 10:03:27 +00:00
Krasimir Georgiev a3a88c73f1 llvm-wrapper: adapt for LLVMConstExtractValue removal 2022-06-30 12:47:34 +00:00
bjorn3 f6484fa9b5 Avoid unnecessary string interning for const_str 2022-06-28 18:38:36 +00:00
Oli Scherer d32ce37a17 Mark scalar layout unions so that backends that do not support partially initialized scalars can special case them. 2022-04-05 13:18:21 +00:00
David Morrison aa67016624 make memcmp return a value of c_int_width instead of i32 2022-04-02 17:21:08 -07:00
bors 3d1eaf4b62 Auto merge of #94638 - erikdesjardins:noextranull, r=nagisa
cleanup: remove unused ability to have LLVM null-terminate const strings

(and the copied function in rustc_codegen_gcc)

Noticed this while writing https://github.com/rust-lang/rust/pull/94450#issuecomment-1059687348.

r? `@nagisa`
2022-03-07 02:07:36 +00:00