diff options
| author | Ralf Jung <post@ralfj.de> | 2024-08-14 07:43:52 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-08-14 07:43:52 +0200 |
| commit | b65cdffbe49acde5cf9d63bd1946a9bd75f32306 (patch) | |
| tree | 68cc4698a35667faea73f554e0af16d9260fb50e /compiler/rustc_codegen_llvm/src/llvm/mod.rs | |
| parent | ef91e65644fca1aa68482d7738078f709f323e8b (diff) | |
| parent | 8b990e35f423907d22cb7f386d40acc1599377ad (diff) | |
| download | rust-b65cdffbe49acde5cf9d63bd1946a9bd75f32306.tar.gz rust-b65cdffbe49acde5cf9d63bd1946a9bd75f32306.zip | |
Merge from rustc
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm/mod.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm/mod.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index 72691907c0d..d0db350a149 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -8,7 +8,7 @@ use std::string::FromUtf8Error; use libc::c_uint; use rustc_data_structures::small_c_str::SmallCStr; use rustc_llvm::RustString; -use rustc_target::abi::Align; +use rustc_target::abi::{Align, Size, WrappingRange}; pub use self::AtomicRmwBinOp::*; pub use self::CallConv::*; @@ -105,6 +105,21 @@ pub fn CreateAllocKindAttr(llcx: &Context, kind_arg: AllocKindFlags) -> &Attribu unsafe { LLVMRustCreateAllocKindAttr(llcx, kind_arg.bits()) } } +pub fn CreateRangeAttr(llcx: &Context, size: Size, range: WrappingRange) -> &Attribute { + let lower = range.start; + let upper = range.end.wrapping_add(1); + let lower_words = [lower as u64, (lower >> 64) as u64]; + let upper_words = [upper as u64, (upper >> 64) as u64]; + unsafe { + LLVMRustCreateRangeAttribute( + llcx, + size.bits().try_into().unwrap(), + lower_words.as_ptr(), + upper_words.as_ptr(), + ) + } +} + #[derive(Copy, Clone)] pub enum AttributePlace { ReturnValue, |
