diff options
| author | bors <bors@rust-lang.org> | 2024-10-12 18:28:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-12 18:28:39 +0000 |
| commit | 6b9676b45431a1e531b9c5f7bd289fc36a312749 (patch) | |
| tree | 120343c0e48a35d8989ec3e33b73a2ca535deda5 /compiler/rustc_codegen_llvm/src | |
| parent | e200c7f2e1a1ec7691a24539cf191f4c4d9d2a2c (diff) | |
| parent | 1b98ae02d8b15025e1662966a53169316c2fcd21 (diff) | |
| download | rust-6b9676b45431a1e531b9c5f7bd289fc36a312749.tar.gz rust-6b9676b45431a1e531b9c5f7bd289fc36a312749.zip | |
Auto merge of #131612 - tgross35:rollup-zy3yg4p, r=tgross35
Rollup of 7 pull requests Successful merges: - #130870 (Add suggestion for removing invalid path sep `::` in fn def) - #130954 (Stabilize const `ptr::write*` and `mem::replace`) - #131233 (std: fix stdout-before-main) - #131590 (yeet some clones) - #131596 (mark InterpResult as must_use) - #131597 (Take a display name for `tool_check_step!`) - #131605 (`LLVMConstInt` only allows integer types) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/common.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index 4ca19ab2f12..0ced37b53a8 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -5,6 +5,7 @@ use rustc_abi as abi; use rustc_abi::Primitive::Pointer; use rustc_abi::{AddressSpace, HasDataLayout}; use rustc_ast::Mutability; +use rustc_codegen_ssa::common::TypeKind; use rustc_codegen_ssa::traits::*; use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher}; use rustc_hir::def_id::DefId; @@ -146,6 +147,10 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> { } fn const_int(&self, t: &'ll Type, i: i64) -> &'ll Value { + debug_assert!( + self.type_kind(t) == TypeKind::Integer, + "only allows integer types in const_int" + ); unsafe { llvm::LLVMConstInt(t, i as u64, True) } } @@ -176,10 +181,18 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> { } fn const_uint(&self, t: &'ll Type, i: u64) -> &'ll Value { + debug_assert!( + self.type_kind(t) == TypeKind::Integer, + "only allows integer types in const_uint" + ); unsafe { llvm::LLVMConstInt(t, i, False) } } fn const_uint_big(&self, t: &'ll Type, u: u128) -> &'ll Value { + debug_assert!( + self.type_kind(t) == TypeKind::Integer, + "only allows integer types in const_uint_big" + ); unsafe { let words = [u as u64, (u >> 64) as u64]; llvm::LLVMConstIntOfArbitraryPrecision(t, 2, words.as_ptr()) |
