Skip to content

Commit

Permalink
Fix getWithSamePointeeType deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Jan 27, 2024
1 parent cb4ea8f commit 328ca1a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static Value *decay_derived(jl_codectx_t &ctx, Value *V)
if (cast<PointerType>(T)->getAddressSpace() == AddressSpace::Derived)
return V;
// Once llvm deletes pointer element types, we won't need it here any more either.
Type *NewT = PointerType::getWithSamePointeeType(cast<PointerType>(T), AddressSpace::Derived);
Type *NewT = PointerType::get(T, AddressSpace::Derived);
return ctx.builder.CreateAddrSpaceCast(V, NewT);
}

Expand All @@ -70,7 +70,7 @@ static Value *maybe_decay_tracked(jl_codectx_t &ctx, Value *V)
Type *T = V->getType();
if (cast<PointerType>(T)->getAddressSpace() != AddressSpace::Tracked)
return V;
Type *NewT = PointerType::getWithSamePointeeType(cast<PointerType>(T), AddressSpace::Derived);
Type *NewT = PointerType::get(T, AddressSpace::Derived);
return ctx.builder.CreateAddrSpaceCast(V, NewT);
}

Expand Down Expand Up @@ -554,7 +554,7 @@ static Value *emit_bitcast(jl_codectx_t &ctx, Value *v, Type *jl_value)
if (isa<PointerType>(jl_value) &&
v->getType()->getPointerAddressSpace() != jl_value->getPointerAddressSpace()) {
// Cast to the proper address space
Type *jl_value_addr = PointerType::getWithSamePointeeType(cast<PointerType>(jl_value), v->getType()->getPointerAddressSpace());
Type *jl_value_addr = PointerType::get(jl_value, v->getType()->getPointerAddressSpace());
++EmittedPointerBitcast;
return ctx.builder.CreateBitCast(v, jl_value_addr);
}
Expand Down Expand Up @@ -3282,7 +3282,7 @@ static void recursively_adjust_ptr_type(llvm::Value *Val, unsigned FromAS, unsig
for (auto *User : Val->users()) {
if (isa<GetElementPtrInst>(User)) {
GetElementPtrInst *Inst = cast<GetElementPtrInst>(User);
Inst->mutateType(PointerType::getWithSamePointeeType(cast<PointerType>(Inst->getType()), ToAS));
Inst->mutateType(PointerType::get(Inst->getType(), ToAS));
recursively_adjust_ptr_type(Inst, FromAS, ToAS);
}
else if (isa<IntrinsicInst>(User)) {
Expand All @@ -3291,7 +3291,7 @@ static void recursively_adjust_ptr_type(llvm::Value *Val, unsigned FromAS, unsig
}
else if (isa<BitCastInst>(User)) {
BitCastInst *Inst = cast<BitCastInst>(User);
Inst->mutateType(PointerType::getWithSamePointeeType(cast<PointerType>(Inst->getType()), ToAS));
Inst->mutateType(PointerType::get(Inst->getType(), ToAS));
recursively_adjust_ptr_type(Inst, FromAS, ToAS);
}
}
Expand Down Expand Up @@ -3338,7 +3338,7 @@ static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &vinfo, bool is_promotab
Value *decayed = decay_derived(ctx, box);
AllocaInst *originalAlloca = cast<AllocaInst>(vinfo.V);
box->takeName(originalAlloca);
decayed = maybe_bitcast(ctx, decayed, PointerType::getWithSamePointeeType(originalAlloca->getType(), AddressSpace::Derived));
decayed = maybe_bitcast(ctx, decayed, PointerType::get(originalAlloca->getType(), AddressSpace::Derived));
// Warning: Very illegal IR here temporarily
originalAlloca->mutateType(decayed->getType());
recursively_adjust_ptr_type(originalAlloca, 0, AddressSpace::Derived);
Expand Down
4 changes: 2 additions & 2 deletions src/llvm-alloc-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ void Optimizer::moveToStack(CallInst *orig_inst, size_t sz, bool has_ref, AllocF
user->replaceUsesOfWith(orig_i, replace);
}
else if (isa<AddrSpaceCastInst>(user) || isa<BitCastInst>(user)) {
auto cast_t = PointerType::getWithSamePointeeType(cast<PointerType>(user->getType()), new_i->getType()->getPointerAddressSpace());
auto cast_t = PointerType::get(user->getType(), new_i->getType()->getPointerAddressSpace());
auto replace_i = new_i;
Type *new_t = new_i->getType();
if (cast_t != new_t) {
Expand Down Expand Up @@ -1067,7 +1067,7 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
store_ty = T_pjlvalue;
}
else {
store_ty = PointerType::getWithSamePointeeType(T_pjlvalue, cast<PointerType>(store_ty)->getAddressSpace());
store_ty = PointerType::get(T_pjlvalue, cast<PointerType>(store_ty)->getAddressSpace());
store_val = builder.CreateBitCast(store_val, store_ty);
}
if (cast<PointerType>(store_ty)->getAddressSpace() != AddressSpace::Tracked)
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-codegen-shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static inline llvm::Value *emit_bitcast_with_builder(llvm::IRBuilder<> &builder,
if (isa<PointerType>(jl_value) &&
v->getType()->getPointerAddressSpace() != jl_value->getPointerAddressSpace()) {
// Cast to the proper address space
Type *jl_value_addr = PointerType::getWithSamePointeeType(cast<PointerType>(jl_value), v->getType()->getPointerAddressSpace());
Type *jl_value_addr = PointerType::get(jl_value, v->getType()->getPointerAddressSpace());
return builder.CreateBitCast(v, jl_value_addr);
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/llvm-propagate-addrspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ Value *PropagateJuliaAddrspacesVisitor::LiftPointer(Module *M, Value *V, Instruc
Instruction *InstV = cast<Instruction>(V);
Instruction *NewV = InstV->clone();
ToInsert.push_back(std::make_pair(NewV, InstV));
Type *NewRetTy = PointerType::getWithSamePointeeType(cast<PointerType>(InstV->getType()), allocaAddressSpace);
Type *NewRetTy = PointerType::get(InstV->getType(), allocaAddressSpace);
NewV->mutateType(NewRetTy);
LiftingMap[InstV] = NewV;
ToRevisit.push_back(NewV);
}
}
auto CollapseCastsAndLift = [&](Value *CurrentV, Instruction *InsertPt) -> Value * {
PointerType *TargetType = PointerType::getWithSamePointeeType(cast<PointerType>(CurrentV->getType()), allocaAddressSpace);
PointerType *TargetType = PointerType::get(CurrentV->getType(), allocaAddressSpace);
while (!LiftingMap.count(CurrentV)) {
if (isa<BitCastInst>(CurrentV))
CurrentV = cast<BitCastInst>(CurrentV)->getOperand(0);
Expand Down

0 comments on commit 328ca1a

Please sign in to comment.