diff options
| author | bors <bors@rust-lang.org> | 2024-08-12 10:20:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-12 10:20:00 +0000 |
| commit | e08b80c0fb7667bdcd040761891701e576c42ec8 (patch) | |
| tree | 41829149ea710de2b1887e98c1b1358559fba03f /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 1d8f135b20fac63c493d5963ce02963b46ca0986 (diff) | |
| parent | cfadfabfcd9644628422396fcc8a67244df435c1 (diff) | |
| download | rust-e08b80c0fb7667bdcd040761891701e576c42ec8.tar.gz rust-e08b80c0fb7667bdcd040761891701e576c42ec8.zip | |
Auto merge of #128371 - andjo403:rangeAttribute, r=nikic
Add range attribute to scalar function results and arguments as LLVM 19 adds the range attribute this starts to use it for better optimization. hade been interesting to see a perf run with the https://github.com/rust-lang/rust/pull/127513 closes https://github.com/rust-lang/rust/issues/50156 cc https://github.com/rust-lang/rust/issues/49572 shall be fixed but not possible to see as there is asserts that already trigger the optimization.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 2ff7335a0fc..79a68b2ff0e 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -397,6 +397,18 @@ LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) { std::nullopt)); } +extern "C" LLVMAttributeRef +LLVMRustCreateRangeAttribute(LLVMContextRef C, unsigned NumBits, + const uint64_t LowerWords[], + const uint64_t UpperWords[]) { +#if LLVM_VERSION_GE(19, 0) + return LLVMCreateConstantRangeAttribute(C, Attribute::Range, NumBits, + LowerWords, UpperWords); +#else + report_fatal_error("LLVM 19.0 is required for Range Attribute"); +#endif +} + // These values **must** match ffi::AllocKindFlags. // It _happens_ to match the LLVM values of llvm::AllocFnKind, // but that's happenstance and we do explicit conversions before |
