Commit Graph

39 Commits

Author SHA1 Message Date
bjorn3 df4b228c71 Merge const_data_from_alloc into static_addr_of
In Cranelift a Value can't hold arbitrarily sized values.
2026-02-25 11:11:06 +00:00
bjorn3 e33e56225c Merge typeid_metadata into type_checked_load
This allows removing the Metadata associated type from BackendTypes.
2026-02-24 10:36:50 +00:00
León Orell Valerian Liehr 26f3337d4e Remove DynKind 2025-09-17 04:46:46 +02:00
Oli Scherer 7f95f04267 Eliminate all direct uses of LLVMMDStringInContext2 2025-07-14 08:27:08 +00:00
Edoardo Marangoni 93f1201c06 compiler: Parse p- specs in datalayout string, allow definition of custom default data address space 2025-07-07 09:04:53 +02:00
Michael Goulet 29c3babd7c Rename unpack to kind 2025-05-27 11:14:45 +00:00
Michael Goulet d98b99af56 More assertions, tests, and miri coverage 2025-01-30 17:44:28 +00:00
Michael Goulet 9dc41a048d Use ExistentialTraitRef throughout codegen 2025-01-30 15:34:00 +00:00
Michael Goulet fdc4bd22b7 Do not treat vtable supertraits as distinct when bound with different bound vars 2025-01-30 15:33:58 +00:00
Jubilee Young b895bf4fdc compiler: Directly use rustc_abi in codegen 2024-11-03 12:30:32 -08:00
Luv-Ray 16093faea8 fix ices on vfe about principal trait 2024-09-23 15:25:52 +08:00
Nicholas Nethercote bdacdfe95f Minimize visibilities.
This makes it much clearer which things are used outside the crate.
2024-09-17 16:24:33 +10: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
bjorn3 e9ea578147 Move vcall_visibility_metadata optimization hint out of a debuginfo generation method 2024-06-21 19:26:06 +00:00
Mark Rousskov 4c002fce9d Omit non-needs_drop drop_in_place in vtables
This replaces the drop_in_place reference with null in vtables. On
librustc_driver.so, this drops about ~17k dynamic relocations from the
output, since many vtables can now be placed in read-only memory, rather
than having a relocated pointer included.

This makes a tradeoff by adding a null check at vtable call sites.
That's hard to avoid without changing the vtable format (e.g., to use a
pc-relative relocation instead of an absolute address, and avoid the
dynamic relocation that way). But it seems likely that the check is
cheap at runtime.
2024-05-27 16:26:56 -04:00
Nicholas Nethercote 8ae0694fcb Remove #[macro_use] extern crate tracing from rustc_codegen_ssa. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote 99e036bd21 Remove extern crate rustc_middle from numerous crates. 2024-04-29 14:50:45 +10:00
Erik Desjardins a7cd803d02 use ptradd for vtable indexing
Like field offsets, these are always constant.
2024-03-10 22:47:30 -04:00
Erik Desjardins 04303cfb3a cg_ssa: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:20 -04:00
Mahdi Dibaiee e55583c4b8 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Ramon de C Valle 004aa15b47 Add cross-language LLVM CFI support to the Rust compiler
This commit adds cross-language LLVM Control Flow Integrity (CFI)
support to the Rust compiler by adding the
`-Zsanitizer-cfi-normalize-integers` option to be used with Clang
`-fsanitize-cfi-icall-normalize-integers` for normalizing integer types
(see https://reviews.llvm.org/D139395).

It provides forward-edge control flow protection for C or C++ and Rust
-compiled code "mixed binaries" (i.e., for when C or C++ and Rust
-compiled code share the same virtual address space). For more
information about LLVM CFI and cross-language LLVM CFI support for the
Rust compiler, see design document in the tracking issue #89653.

Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and
-Zsanitizer-cfi-normalize-integers, and requires proper (i.e.,
non-rustc) LTO (i.e., -Clinker-plugin-lto).
2023-05-03 22:41:29 +00:00
Maybe Waffle 3f15521396 Add GenericArgKind::as_{type,const,region} 2023-04-19 14:54:31 +00:00
Jeremy Stucki 3dde32ca97 rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
bjorn3 b2e0db93e7 Directly return loaded value from type_checked_load 2022-12-03 18:27:43 +00:00
Eric Holk c5441acf67 Call destructors when dyn* object goes out of scope 2022-09-12 16:55:57 -07:00
Eric Holk 6c01273a15 Plumb dyn trait representation through ty::Dynamic 2022-09-12 16:55:55 -07:00
Michael Goulet 72fe79244d Simplify get_trait_ref a bit 2022-08-29 04:19:14 +00:00
Ralf Jung 3dad266f40 consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable) 2022-07-20 17:12:07 -04:00
Joshua Nelson 3c9765cff1 Rename debugging_opts to unstable_opts
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
flip1995 e1c1d0f8c2 Add llvm.type.checked.load intrinsic
Add the intrinsic

declare {i8*, i1} @llvm.type.checked.load(i8* %ptr, i32 %offset, metadata %type)

This is used in the VFE optimization when lowering loading functions
from vtables to LLVM IR. The `metadata` is used to map the function to
all vtables this function could belong to. This ensures that functions
from vtables that might be used somewhere won't get removed.
2022-06-14 14:50:52 +02:00
Michael Woerister 584855e03d debuginfo: Refactor debuginfo generation for types -- Rename DebugInfoMethods::create_vtable_metadata() to DebugInfoMethods::create_vtable_debuginfo() 2022-03-14 17:25:24 +01:00
bors 9a757817c3 Auto merge of #89597 - michaelwoerister:improve-vtable-debuginfo, r=wesleywiser
Create more accurate debuginfo for vtables.

Before this PR all vtables would have the same name (`"vtable"`) in debuginfo. Now they get an unambiguous name that identifies the implementing type and the trait that is being implemented.

This is only one of several possible improvements:
- This PR describes vtables as arrays of `*const u8` pointers. It would nice to describe them as structs where function pointer is represented by a field with a name indicative of the method it maps to. However, this requires coming up with a naming scheme that avoids clashes between methods with the same name (which is possible if the vtable contains multiple traits).
- The PR does not update the debuginfo we generate for the vtable-pointer field in a fat `dyn` pointer. Right now there does not seem to be an easy way of getting ahold of a vtable-layout without also knowing the concrete self-type of a trait object.

r? `@wesleywiser`
2021-10-11 04:31:47 +00:00
Michael Woerister 61c5a6d644 Create more accurate debuginfo for vtables.
Before this commit all vtables would have the same name "vtable" in
debuginfo. Now they get a name that identifies the implementing type
and the trait that is being implemented.
2021-10-08 10:33:47 +02:00
Michael Woerister b7cc99142a Turn tcx.vtable_allocation() into a query. 2021-10-07 20:03:00 +02:00
Tomasz Miąsko 77e5e17231 Prepare inbounds_gep for opaque pointers
Implement inbounds_gep using LLVMBuildInBoundsGEP2 which takes an
explicit type argument instead of deriving it from a pointer type.
2021-08-04 15:51:30 +02:00
Nikita Popov 4560efe46c Pass type when creating load
This makes load generation compatible with opaque pointers.

The generation of nontemporal copies still accesses the pointer
element type, as fixing this requires more movement.
2021-07-09 22:14:44 +02:00
Charles Lew d3ff497bec Update other codegens to use tcx managed vtable allocations. 2021-06-28 19:39:48 +08:00
Charles Lew a86d3a7e45 Refactor to make interpreter and codegen backend neutral to vtable internal representation. 2021-06-15 01:59:00 +08:00
mark 9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00