Fix deprectaion warning on CreateGEP(Value *, ArrayRef<Value *>, const Twine &) (#608)
This variant of CreateGEP() is already removed in LLVM 14.
This commit is contained in:
@@ -65,18 +65,21 @@ Value* geper::operator()(Value *ptr, Value* off, const std::string& name){
|
|||||||
if(auto* gep = dyn_cast<GetElementPtrInst>(ptr))
|
if(auto* gep = dyn_cast<GetElementPtrInst>(ptr))
|
||||||
if(ConstantInt* cst1 = dyn_cast<ConstantInt>(gep->idx_begin()))
|
if(ConstantInt* cst1 = dyn_cast<ConstantInt>(gep->idx_begin()))
|
||||||
if(ConstantInt* cst2 = dyn_cast<ConstantInt>(off)){
|
if(ConstantInt* cst2 = dyn_cast<ConstantInt>(off)){
|
||||||
return (*builder_)->CreateGEP(gep->getPointerOperand(),
|
return (*builder_)->CreateGEP(gep->getPointerOperand()->getType()->getScalarType()->getPointerElementType(),
|
||||||
(*builder_)->CreateAdd(cst1, cst2));
|
gep->getPointerOperand(), (*builder_)->CreateAdd(cst1, cst2));
|
||||||
}
|
}
|
||||||
// ptr + (off + cst) -> (ptr + off) + cst
|
// ptr + (off + cst) -> (ptr + off) + cst
|
||||||
if(auto* bin = dyn_cast<BinaryOperator>(off))
|
if(auto* bin = dyn_cast<BinaryOperator>(off))
|
||||||
if(bin->getOpcode() == llvm::BinaryOperator::BinaryOps::Add)
|
if(bin->getOpcode() == llvm::BinaryOperator::BinaryOps::Add)
|
||||||
if(ConstantInt* cst = dyn_cast<ConstantInt>(bin->getOperand(1))){
|
if(ConstantInt* cst = dyn_cast<ConstantInt>(bin->getOperand(1))){
|
||||||
return (*builder_)->CreateGEP((*builder_)->CreateGEP(ptr, bin->getOperand(0)),
|
Value *gep = (*builder_)->CreateGEP(ptr->getType()->getScalarType()->getPointerElementType(),
|
||||||
bin->getOperand(1));
|
ptr, bin->getOperand(0));
|
||||||
|
return (*builder_)->CreateGEP(gep->getType()->getScalarType()->getPointerElementType(),
|
||||||
|
gep, bin->getOperand(1));
|
||||||
}
|
}
|
||||||
// default
|
// default
|
||||||
return (*builder_)->CreateGEP(ptr, off, name);
|
return (*builder_)->CreateGEP(ptr->getType()->getScalarType()->getPointerElementType(),
|
||||||
|
ptr, off, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Value* geper::operator()(Type *ty, Value *ptr, std::vector<Value *> vals, const std::string &name) {
|
//Value* geper::operator()(Type *ty, Value *ptr, std::vector<Value *> vals, const std::string &name) {
|
||||||
|
Reference in New Issue
Block a user