summary refs log tree commit diff
path: root/compiler/rustc_smir/src
AgeCommit message (Collapse)AuthorLines
2024-03-14preserve span when evaluating mir::ConstOperandRalf Jung-1/+1
2024-03-14Rollup merge of #122405 - celinval:smir-new-const, r=oli-obkMatthias Krüger-7/+51
Add methods to create StableMIR constant I've been experimenting with transforming the StableMIR to instrument the code with potential UB checks. The modified body will only be used by our analysis tool, however, constants in StableMIR must be backed by rustc constants. Thus, I'm adding a few functions to build constants, such as building string and other primitives. One question I have is whether we should create a global allocation instead for strings. r? ``````@oli-obk``````
2024-03-13Rollup merge of #122203 - adpaco-aws:smir-intrinsic-name, r=celinvalMatthias Krüger-0/+10
Add `intrinsic_name` to get plain intrinsic name Add an `intrinsic_name` API to retrieve the plain intrinsic name. The plain name does not include type arguments (as `trimmed_name` does), which is more convenient to match with intrinsic symbols.
2024-03-12Add `intrinsic_name` to get plain intrinsic nameAdrian Palacios-0/+10
2024-03-12Add methods to create constantsCelina G. Val-7/+51
I've been experimenting with transforming the StableMIR to instrument the code with potential UB checks. The modified body will only be used by our analysis tool, however, constants in StableMIR must be backed by rustc constants. Thus, I'm adding a few functions to build constants, such as building string and other primitives.
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-2/+2
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-1/+7
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-3/+5
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-01Add support to new float typesCelina G. Val-4/+7
2024-03-01Implement missing ABI structures in StableMIRCelina G. Val-7/+59
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-0/+2
Make changes necessary to support these types in the compiler.
2024-02-25remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsicsRalf Jung-2/+0
2024-02-24Implement asm goto in MIR and MIR loweringGary Guo-1/+2
2024-02-24Change InlineAsm to allow multiple targets insteadGary Guo-2/+3
2024-02-23compiler: clippy::complexity fixesMatthias Krüger-2/+1
2024-02-17Merge `CompilerError::CompilationFailed` and `CompilerError::ICE`.Nicholas Nethercote-2/+8
`CompilerError` has `CompilationFailed` and `ICE` variants, which seems reasonable at first. But the way it identifies them is flawed: - If compilation errors out, i.e. `RunCompiler::run` returns an `Err`, it uses `CompilationFailed`, which is reasonable. - If compilation panics with `FatalError`, it catches the panic and uses `ICE`. This is sometimes right, because ICEs do cause `FatalError` panics, but sometimes wrong, because certain compiler errors also cause `FatalError` panics. (The compiler/rustdoc/clippy/whatever just catches the `FatalError` with `catch_with_exit_code` in `main`.) In other words, certain non-ICE compilation failures get miscategorized as ICEs. It's not possible to reliably distinguish the two cases, so this commit merges them. It also renames the combined variant as just `Failed`, to better match the existing `Interrupted` and `Skipped` variants. Here is an example of a non-ICE failure that causes a `FatalError` panic, from `tests/ui/recursion_limit/issue-105700.rs`: ``` #![recursion_limit="4"] #![invalid_attribute] #![invalid_attribute] #![invalid_attribute] #![invalid_attribute] #![invalid_attribute] //~^ERROR recursion limit reached while expanding fn main() {{}} ```
2024-02-15Rollup merge of #120982 - momvart:smir-61-foreign_kind, r=oli-obkMatthias Krüger-33/+105
Add APIs for fetching foreign items Closes https://github.com/rust-lang/project-stable-mir/issues/61
2024-02-14Rewrite foreign item kind query using `DefKind`Mohammad Omidvar-21/+13
2024-02-12Add APIs for fetching foreign items including foreign modules, their ABIs, ↵Mohammad Omidvar-33/+113
and their items
2024-02-12Dejargnonize substShoyu Vanilla-1/+1
2024-02-08Add a new debug_assertions instrinsic (compiler)Ben Kimock-0/+1
And in clippy
2024-02-06Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closureMichael Goulet-1/+1
2024-02-06Bless tests, add commentsMichael Goulet-2/+2
2024-02-06Construct body for by-move coroutine closure outputMichael Goulet-0/+1
2024-02-06Build a shim to call async closures with different AsyncFn trait kindsMichael Goulet-0/+1
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-0/+4
2024-01-30Remove the `abi_amdgpu_kernel` featureclubby789-3/+0
2024-01-22Do not normalize closure signature when building FnOnce shimMichael Goulet-1/+4
2024-01-19Use the new `with_tables` everywhereOli Scherer-145/+127
2024-01-19Ensure internal function is safeCelina G. Val-198/+294
The internal function was unsound, it could cause UB in rare cases where the user inadvertly stored the returned object in a location that could outlive the TyCtxt. In order to make it safe, we now take a type context as an argument to the internal fn, and we ensure that interned items are lifted using the provided context. Thus, this change ensures that the compiler can properly enforce that the object does not outlive the type context it was lifted to.
2024-01-19Fix `Stable` trait and its impls to work with the new `with_tables`Oli Scherer-129/+136
2024-01-19Fix a soundness bug in `with_tables`.Oli Scherer-2/+2
We were able to uplift any value from `Tables` to `'static`, which is unsound.
2024-01-18Rollup merge of #119833 - celinval:smir-accept-closures, r=oli-obkMatthias Krüger-16/+106
Make tcx optional from StableMIR run macro and extend it to accept closures Change `run` macro to avoid sometimes unnecessary dependency on `TyCtxt`, and introduce `run_with_tcx` to capture use cases where `tcx` is required. Additionally, extend both macros to accept closures that may capture variables. I've also modified the `internal()` method to make it safer, by accepting the type context to force the `'tcx` lifetime to match the context lifetime. These are non-backward compatible changes, but they only affect internal APIs which are provided today as helper functions until we have a stable API to start the compiler.
2024-01-17Revert changes to internal method for nowCelina G. Val-29/+4
- Move fix to a separate PR
2024-01-16Remove tcx function and make `internal` fn saferCelina G. Val-28/+55
I added `tcx` argument to `internal` to force 'tcx to be the same lifetime as TyCtxt. The only other solution I could think is to change this function to be `unsafe`.
2024-01-16Remove tcx from SMIR run macro and accept closuresCelina G. Val-17/+105
Simplify the `run` macro to avoid sometimes unnecessary dependency on `TyCtxt`. Instead, users can use the new internal method `tcx()`. Additionally, extend the macro to accept closures that may capture variables. These are non-backward compatible changes, but they only affect internal APIs which are provided today as helper functions until we have a stable API to start the compiler.
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-1/+1
To enable improved accuracy of diagnostics in upcoming commits.
2024-01-11Rollup merge of #119790 - celinval:smir-all-traits, r=oli-obkMatthias Krüger-4/+27
Fix all_trait* methods to return all traits available in StableMIR Also provide a mechanism to retrieve traits and implementations for a given crate. This fixes https://github.com/rust-lang/project-stable-mir/issues/37
2024-01-10Simplify some redundant namesMichael Goulet-8/+6
2024-01-09Fix all_trait* methods to return all trait availableCelina G. Val-4/+27
Also provide a mechanism to retrieve traits and implementations for a given crate.
2023-12-28Movability doesn't need to be a query anymoreMichael Goulet-2/+2
2023-12-28Restore movability to SMIRMichael Goulet-1/+3
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-9/+5
2023-12-25Only regular coroutines have movabilityMichael Goulet-2/+4
2023-12-22Split coroutine desugaring kind from sourceMichael Goulet-7/+16
2023-12-20Rollup merge of #119141 - celinval:smir-instance-args, r=compiler-errorsMatthias Krüger-0/+6
Add method to get instance instantiation arguments Add a method to get the instance instantiation arguments, and include that information in the instance debug.
2023-12-20Add method to get instance instantiation argumentsCelina G. Val-0/+6
2023-12-20Add `ItemKind::Ctor` to stable mirCelina G. Val-9/+7
2023-12-20Fix crash for `CrateItem::kind()` with constructorsCelina G. Val-5/+8
Change how we classify item kind for DefKind::Ctor
2023-12-20Rollup merge of #119094 - celinval:smir-layout, r=compiler-errorsMatthias Krüger-21/+344
Add function ABI and type layout to StableMIR This change introduces a new module to StableMIR named `abi` with information from `rustc_target::abi` and `rustc_abi`, that allow users to retrieve more low level information required to perform bit-precise analysis. The layout of a type can be retrieved via `Ty::layout`, and the instance ABI can be retrieved via `Instance::fn_abi()`. To properly handle errors while retrieve layout information, we had to implement a few layout related traits. r? ```@compiler-errors```