Skip to content

Commit

Permalink
Update getInt8PtrTy
Browse files Browse the repository at this point in the history
  • Loading branch information
Zentrik committed Apr 21, 2024
1 parent 45ab39a commit 49cf318
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ jl_cgval_t function_sig_t::emit_a_ccall(
if (!isa<Function>(llvmf) || cast<Function>(llvmf)->isIntrinsic() || cast<Function>(llvmf)->getFunctionType() != functype)
llvmf = NULL;
}
else if (f_name.startswith("llvm.")) {
else if (f_name.starts_with("llvm.")) {
// compute and verify auto-mangling for intrinsic name
auto ID = Function::lookupIntrinsicID(f_name);
if (ID != Intrinsic::not_intrinsic) {
Expand Down
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ auto getCharTy(LLVMContext &ctxt) {
return getInt32Ty(ctxt);
}
auto getInt8PtrTy(LLVMContext &ctxt) {
return Type::getInt8PtrTy(ctxt);
return PointerType::getUnqual(ctxt);
}
auto getInt16PtrTy(LLVMContext &ctxt) {
return Type::getInt16PtrTy(ctxt);
Expand Down
2 changes: 1 addition & 1 deletion src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,7 @@ void jl_merge_module(orc::ThreadSafeModule &destTSM, orc::ThreadSafeModule srcTS
// Init.push_back(cast_or_null<Constant>(Op));
// for (auto &Op : sCA->operands())
// Init.push_back(cast_or_null<Constant>(Op));
// Type *Int8PtrTy = Type::getInt8PtrTy(dest.getContext());
// Type *Int8PtrTy = PointerType::getUnqual(dest.getContext());
// ArrayType *ATy = ArrayType::get(Int8PtrTy, Init.size());
// GlobalVariable *GV = new GlobalVariable(dest, ATy, dG->isConstant(),
// GlobalValue::AppendingLinkage, ConstantArray::get(ATy, Init), "",
Expand Down
14 changes: 7 additions & 7 deletions src/llvm-alloc-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ void Optimizer::moveToStack(CallInst *orig_inst, size_t sz, bool has_ref, AllocF
auto asize = ConstantInt::get(Type::getInt64Ty(prolog_builder.getContext()), sz / DL.getTypeAllocSize(pass.T_prjlvalue));
buff = prolog_builder.CreateAlloca(pass.T_prjlvalue, asize);
buff->setAlignment(Align(align));
ptr = cast<Instruction>(prolog_builder.CreateBitCast(buff, Type::getInt8PtrTy(prolog_builder.getContext())));
ptr = cast<Instruction>(prolog_builder.CreateBitCast(buff, PointerType::getUnqual(prolog_builder.getContext())));
}
else {
Type *buffty;
Expand All @@ -657,7 +657,7 @@ void Optimizer::moveToStack(CallInst *orig_inst, size_t sz, bool has_ref, AllocF
buffty = ArrayType::get(Type::getInt8Ty(pass.getLLVMContext()), sz);
buff = prolog_builder.CreateAlloca(buffty);
buff->setAlignment(Align(align));
ptr = cast<Instruction>(prolog_builder.CreateBitCast(buff, Type::getInt8PtrTy(prolog_builder.getContext(), buff->getType()->getPointerAddressSpace())));
ptr = cast<Instruction>(prolog_builder.CreateBitCast(buff, PointerType::get(prolog_builder.getContext(), buff->getType()->getPointerAddressSpace())));
}
insertLifetime(ptr, ConstantInt::get(Type::getInt64Ty(prolog_builder.getContext()), sz), orig_inst);
if (sz != 0 && !has_ref) { // TODO: fix has_ref case too
Expand Down Expand Up @@ -958,7 +958,7 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
}
slot.slot = prolog_builder.CreateAlloca(allocty);
IRBuilder<> builder(orig_inst);
insertLifetime(prolog_builder.CreateBitCast(slot.slot, Type::getInt8PtrTy(prolog_builder.getContext())),
insertLifetime(prolog_builder.CreateBitCast(slot.slot, PointerType::getUnqual(prolog_builder.getContext())),
ConstantInt::get(Type::getInt64Ty(prolog_builder.getContext()), field.size), orig_inst);
initializeAlloca(builder, slot.slot, use_info.allockind);
slots.push_back(std::move(slot));
Expand Down Expand Up @@ -1018,7 +1018,7 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
}
}
else {
addr = builder.CreateBitCast(slot.slot, Type::getInt8PtrTy(builder.getContext()));
addr = builder.CreateBitCast(slot.slot, PointerType::getUnqual(builder.getContext()));
addr = builder.CreateConstInBoundsGEP1_32(Type::getInt8Ty(builder.getContext()), addr, offset);
addr = builder.CreateBitCast(addr, elty->getPointerTo());
}
Expand Down Expand Up @@ -1142,7 +1142,7 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
store->setOrdering(AtomicOrdering::NotAtomic);
continue;
}
auto ptr8 = builder.CreateBitCast(slot.slot, Type::getInt8PtrTy(builder.getContext()));
auto ptr8 = builder.CreateBitCast(slot.slot, PointerType::getUnqual(builder.getContext()));
if (offset > slot.offset)
ptr8 = builder.CreateConstInBoundsGEP1_32(Type::getInt8Ty(builder.getContext()), ptr8,
offset - slot.offset);
Expand Down Expand Up @@ -1266,8 +1266,8 @@ bool AllocOpt::doInitialization(Module &M)

DL = &M.getDataLayout();

lifetime_start = Intrinsic::getDeclaration(&M, Intrinsic::lifetime_start, { Type::getInt8PtrTy(M.getContext(), DL->getAllocaAddrSpace()) });
lifetime_end = Intrinsic::getDeclaration(&M, Intrinsic::lifetime_end, { Type::getInt8PtrTy(M.getContext(), DL->getAllocaAddrSpace()) });
lifetime_start = Intrinsic::getDeclaration(&M, Intrinsic::lifetime_start, { PointerType::get(M.getContext(), DL->getAllocaAddrSpace()) });
lifetime_end = Intrinsic::getDeclaration(&M, Intrinsic::lifetime_end, { PointerType::get(M.getContext(), DL->getAllocaAddrSpace()) });

return true;
}
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 @@ -291,7 +291,7 @@ static inline llvm::Value *emit_gc_state_set(llvm::IRBuilder<> &builder, llvm::T
{
using namespace llvm;
Type *T_int8 = state->getType();
llvm::Value *ptls_i8 = emit_bitcast_with_builder(builder, ptls, builder.getInt8PtrTy());
llvm::Value *ptls_i8 = emit_bitcast_with_builder(builder, ptls, builder.getPtrTy());
Constant *offset = ConstantInt::getSigned(builder.getInt32Ty(), offsetof(jl_tls_states_t, gc_state));
Value *gc_state = builder.CreateInBoundsGEP(T_int8, ptls_i8, ArrayRef<Value*>(offset), "gc_state");
if (old_state == nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-julia-licm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ struct JuliaLICM : public JuliaPassContext {
moveInstructionBefore(*call, *preheader->getTerminator(), MSSAU, SE);
IRBuilder<> builder(preheader->getTerminator());
builder.SetCurrentDebugLocation(call->getDebugLoc());
auto obj_i8 = builder.CreateBitCast(call, Type::getInt8PtrTy(call->getContext(), call->getType()->getPointerAddressSpace()));
auto obj_i8 = builder.CreateBitCast(call, PointerType::get(call->getContext(), call->getType()->getPointerAddressSpace()));
// Note that this alignment is assuming the GC allocates at least pointer-aligned memory
auto align = Align(DL.getPointerSize(0));
auto clear_obj = builder.CreateMemSet(obj_i8, ConstantInt::get(Type::getInt8Ty(call->getContext()), 0), call->getArgOperand(1), align);
Expand Down
8 changes: 4 additions & 4 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ static std::pair<Value*,int> FindBaseValue(const State &S, Value *V, bool UseCac
// This could really be anything, but it's not loaded
// from a tracked pointer, so it doesn't matter what
// it is--just pick something simple.
CurrentV = ConstantPointerNull::get(Type::getInt8PtrTy(V->getContext()));
CurrentV = ConstantPointerNull::get(PointerType::getUnqual(V->getContext()));
}
continue;
}
Expand Down Expand Up @@ -545,12 +545,12 @@ static std::pair<Value*,int> FindBaseValue(const State &S, Value *V, bool UseCac
if (II->getIntrinsicID() == Intrinsic::masked_load) {
fld_idx = -1;
if (!isSpecialPtr(CurrentV->getType())) {
CurrentV = ConstantPointerNull::get(Type::getInt8PtrTy(V->getContext()));
CurrentV = ConstantPointerNull::get(PointerType::getUnqual(V->getContext()));
}
} else {
if (auto VTy2 = dyn_cast<VectorType>(CurrentV->getType())) {
if (!isSpecialPtr(VTy2->getElementType())) {
CurrentV = ConstantPointerNull::get(Type::getInt8PtrTy(V->getContext()));
CurrentV = ConstantPointerNull::get(PointerType::getUnqual(V->getContext()));
fld_idx = -1;
}
}
Expand Down Expand Up @@ -2439,7 +2439,7 @@ bool LateLowerGCFrame::CleanupIR(Function &F, State *S, bool *CFGModified) {
// gc_alloc_obj, and will redundantly set the tag.)
auto allocBytesIntrinsic = getOrDeclare(jl_intrinsics::GCAllocBytes);
auto ptlsLoad = get_current_ptls_from_task(builder, T_size, CI->getArgOperand(0), tbaa_gcframe);
auto ptls = builder.CreateBitCast(ptlsLoad, Type::getInt8PtrTy(builder.getContext()));
auto ptls = builder.CreateBitCast(ptlsLoad, PointerType::getUnqual(builder.getContext()));
auto newI = builder.CreateCall(
allocBytesIntrinsic,
{
Expand Down
4 changes: 2 additions & 2 deletions src/llvm-lower-handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static bool lowerExcHandlers(Function &F) {
Function *jlenter_func = M.getFunction(XSTR(jl_enter_handler));
Function *setjmp_func = M.getFunction(jl_setjmp_name);

auto T_pint8 = Type::getInt8PtrTy(M.getContext(), 0);
auto T_pint8 = PointerType::get(M.getContext(), 0);
Function *lifetime_start = Intrinsic::getDeclaration(&M, Intrinsic::lifetime_start, { T_pint8 });
Function *lifetime_end = Intrinsic::getDeclaration(&M, Intrinsic::lifetime_end, { T_pint8 });

Expand Down Expand Up @@ -178,7 +178,7 @@ static bool lowerExcHandlers(Function &F) {
auto *buff = new AllocaInst(Type::getInt8Ty(F.getContext()), allocaAddressSpace,
handler_sz, Align(16), "", firstInst);
if (allocaAddressSpace) {
AddrSpaceCastInst *buff_casted = new AddrSpaceCastInst(buff, Type::getInt8PtrTy(F.getContext(), AddressSpace::Generic));
AddrSpaceCastInst *buff_casted = new AddrSpaceCastInst(buff, PointerType::get(F.getContext(), AddressSpace::Generic));
buff_casted->insertAfter(buff);
buffs.push_back(buff_casted);
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/llvm-pass-helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace jl_intrinsics {
auto intrinsic = Function::Create(
FunctionType::get(
T_prjlvalue,
{ Type::getInt8PtrTy(ctx),
{ PointerType::getUnqual(ctx),
T_size,
T_size }, // type
false),
Expand Down Expand Up @@ -272,7 +272,7 @@ namespace jl_well_known {
auto bigAllocFunc = Function::Create(
FunctionType::get(
T_prjlvalue,
{ Type::getInt8PtrTy(ctx), T_size , T_size},
{ PointerType::getUnqual(ctx), T_size , T_size},
false),
Function::ExternalLinkage,
GC_BIG_ALLOC_NAME);
Expand All @@ -288,7 +288,7 @@ namespace jl_well_known {
auto poolAllocFunc = Function::Create(
FunctionType::get(
T_prjlvalue,
{ Type::getInt8PtrTy(ctx), Type::getInt32Ty(ctx), Type::getInt32Ty(ctx), T_size },
{ PointerType::getUnqual(ctx), Type::getInt32Ty(ctx), Type::getInt32Ty(ctx), T_size },
false),
Function::ExternalLinkage,
GC_POOL_ALLOC_NAME);
Expand Down Expand Up @@ -324,7 +324,7 @@ namespace jl_well_known {
auto allocTypedFunc = Function::Create(
FunctionType::get(
T_prjlvalue,
{ Type::getInt8PtrTy(ctx),
{ PointerType::getUnqual(ctx),
T_size,
T_size }, // type
false),
Expand Down
6 changes: 3 additions & 3 deletions src/llvm-ptls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ Instruction *LowerPTLS::emit_pgcstack_tp(Value *offset, Instruction *insertBefor
if (offset) {
SmallVector<Type*, 0> args(0);
args.push_back(offset->getType());
auto tp = InlineAsm::get(FunctionType::get(Type::getInt8PtrTy(builder.getContext()), args, false),
auto tp = InlineAsm::get(FunctionType::get(PointerType::getUnqual(builder.getContext()), args, false),
dyn_asm_str, "=&r,r,~{dirflag},~{fpsr},~{flags}", false);
tls = builder.CreateCall(tp, {offset}, "pgcstack");
}
else {
auto tp = InlineAsm::get(FunctionType::get(Type::getInt8PtrTy(insertBefore->getContext()), false),
auto tp = InlineAsm::get(FunctionType::get(PointerType::getUnqual(insertBefore->getContext()), false),
const_asm_str.c_str(), "=r,~{dirflag},~{fpsr},~{flags}",
false);
tls = builder.CreateCall(tp, {}, "tls_pgcstack");
Expand All @@ -126,7 +126,7 @@ Instruction *LowerPTLS::emit_pgcstack_tp(Value *offset, Instruction *insertBefor
}
if (!offset)
offset = ConstantInt::getSigned(T_size, jl_tls_offset);
auto tp = InlineAsm::get(FunctionType::get(Type::getInt8PtrTy(builder.getContext()), false), asm_str, "=r", false);
auto tp = InlineAsm::get(FunctionType::get(PointerType::getUnqual(builder.getContext()), false), asm_str, "=r", false);
tls = builder.CreateCall(tp, {}, "thread_ptr");
tls = builder.CreateGEP(Type::getInt8Ty(builder.getContext()), tls, {offset}, "tls_ppgcstack");
}
Expand Down

0 comments on commit 49cf318

Please sign in to comment.