diff options
| author | Nikita Popov <npopov@redhat.com> | 2025-02-19 10:55:36 +0100 |
|---|---|---|
| committer | Nikita Popov <npopov@redhat.com> | 2025-02-19 11:32:32 +0100 |
| commit | 5e9d8a7d55fbf1771d1b83ff2f15bdc75c9216d8 (patch) | |
| tree | 470a7bf6a0a980e3fd126e79340f42eb6f9e32f3 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 3b022d8ceea570db9730be34d964f0cc663a567f (diff) | |
| download | rust-5e9d8a7d55fbf1771d1b83ff2f15bdc75c9216d8.tar.gz rust-5e9d8a7d55fbf1771d1b83ff2f15bdc75c9216d8.zip | |
Switch to the LLVMBuildGEPWithNoWrapFlags API
This API allows us to set the nuw flag as well.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index b8cef6a7e25..aea2a8dd097 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -1767,6 +1767,24 @@ extern "C" LLVMValueRef LLVMRustBuildMaxNum(LLVMBuilderRef B, LLVMValueRef LHS, return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS), unwrap(RHS))); } +#if LLVM_VERSION_LT(19, 0) +enum { + LLVMGEPFlagInBounds = (1 << 0), + LLVMGEPFlagNUSW = (1 << 1), + LLVMGEPFlagNUW = (1 << 2), +}; +extern "C" LLVMValueRef +LLVMBuildGEPWithNoWrapFlags(LLVMBuilderRef B, LLVMTypeRef Ty, + LLVMValueRef Pointer, LLVMValueRef *Indices, + unsigned NumIndices, const char *Name, + unsigned NoWrapFlags) { + if (NoWrapFlags & LLVMGEPFlagInBounds) + return LLVMBuildInBoundsGEP2(B, Ty, Pointer, Indices, NumIndices, Name); + else + return LLVMBuildGEP2(B, Ty, Pointer, Indices, NumIndices, Name); +} +#endif + // Transfers ownership of DiagnosticHandler unique_ptr to the caller. extern "C" DiagnosticHandler * LLVMRustContextGetDiagnosticHandler(LLVMContextRef C) { |
