Skip to content

Commit 6ed121a

Browse files
authored
Rollup merge of rust-lang#113523 - workingjubilee:reuse-const-inbounds-gep2, r=cuviper
Reuse LLVMConstInBoundsGEP2 We have had LLVM 14 as our minimum for a bit now.
2 parents a3029e2 + 0726c78 commit 6ed121a

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

compiler/rustc_codegen_llvm/src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
290290
}
291291
};
292292
let llval = unsafe {
293-
llvm::LLVMRustConstInBoundsGEP2(
293+
llvm::LLVMConstInBoundsGEP2(
294294
self.type_i8(),
295295
self.const_bitcast(base_addr, self.type_i8p_ext(base_addr_space)),
296296
&self.const_usize(offset.bytes()),
@@ -320,7 +320,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
320320

321321
fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
322322
unsafe {
323-
llvm::LLVMRustConstInBoundsGEP2(
323+
llvm::LLVMConstInBoundsGEP2(
324324
self.type_i8(),
325325
self.const_bitcast(base_addr, self.type_i8p()),
326326
&self.const_usize(offset.bytes()),

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ extern "C" {
11551155
pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
11561156

11571157
// Constant expressions
1158-
pub fn LLVMRustConstInBoundsGEP2<'a>(
1158+
pub fn LLVMConstInBoundsGEP2<'a>(
11591159
ty: &'a Type,
11601160
ConstantVal: &'a Value,
11611161
ConstantIndices: *const &'a Value,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -1616,17 +1616,6 @@ extern "C" void LLVMRustSetLinkage(LLVMValueRef V,
16161616
LLVMSetLinkage(V, fromRust(RustLinkage));
16171617
}
16181618

1619-
// FIXME: replace with LLVMConstInBoundsGEP2 when bumped minimal version to llvm-14
1620-
extern "C" LLVMValueRef LLVMRustConstInBoundsGEP2(LLVMTypeRef Ty,
1621-
LLVMValueRef ConstantVal,
1622-
LLVMValueRef *ConstantIndices,
1623-
unsigned NumIndices) {
1624-
ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1625-
NumIndices);
1626-
Constant *Val = unwrap<Constant>(ConstantVal);
1627-
return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
1628-
}
1629-
16301619
extern "C" bool LLVMRustConstIntGetZExtValue(LLVMValueRef CV, uint64_t *value) {
16311620
auto C = unwrap<llvm::ConstantInt>(CV);
16321621
if (C->getBitWidth() > 64)

0 commit comments

Comments
 (0)