diff --git a/src/ccall.cpp b/src/ccall.cpp index cc5ae11eea5dda..84317c61f55550 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -2086,7 +2086,7 @@ jl_cgval_t function_sig_t::emit_a_ccall( if (!isa(llvmf) || cast(llvmf)->isIntrinsic() || cast(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) { diff --git a/src/codegen.cpp b/src/codegen.cpp index 65ea216e19dd1f..94cb126bc27350 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -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); diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp index 61953473cd2c3b..b60a0857dbf093 100644 --- a/src/jitlayers.cpp +++ b/src/jitlayers.cpp @@ -2126,7 +2126,7 @@ void jl_merge_module(orc::ThreadSafeModule &destTSM, orc::ThreadSafeModule srcTS // Init.push_back(cast_or_null(Op)); // for (auto &Op : sCA->operands()) // Init.push_back(cast_or_null(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), "", diff --git a/src/llvm-alloc-opt.cpp b/src/llvm-alloc-opt.cpp index c99a94c1404906..f2b1bff8fe67ee 100644 --- a/src/llvm-alloc-opt.cpp +++ b/src/llvm-alloc-opt.cpp @@ -649,7 +649,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(prolog_builder.CreateBitCast(buff, Type::getInt8PtrTy(prolog_builder.getContext()))); + ptr = cast(prolog_builder.CreateBitCast(buff, PointerType::getUnqual(prolog_builder.getContext()))); } else { Type *buffty; @@ -659,7 +659,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(prolog_builder.CreateBitCast(buff, Type::getInt8PtrTy(prolog_builder.getContext(), buff->getType()->getPointerAddressSpace()))); + ptr = cast(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 @@ -960,7 +960,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)); @@ -1020,7 +1020,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()); } @@ -1144,7 +1144,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); @@ -1268,8 +1268,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; } diff --git a/src/llvm-codegen-shared.h b/src/llvm-codegen-shared.h index e8ca62f5196426..9d8bec725f30df 100644 --- a/src/llvm-codegen-shared.h +++ b/src/llvm-codegen-shared.h @@ -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(offset), "gc_state"); if (old_state == nullptr) { diff --git a/src/llvm-julia-licm.cpp b/src/llvm-julia-licm.cpp index e76beaa3df44f3..65cd4ad541fee1 100644 --- a/src/llvm-julia-licm.cpp +++ b/src/llvm-julia-licm.cpp @@ -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); diff --git a/src/llvm-late-gc-lowering.cpp b/src/llvm-late-gc-lowering.cpp index 55efa37fccf0b0..f46cb4a4b7b7f2 100644 --- a/src/llvm-late-gc-lowering.cpp +++ b/src/llvm-late-gc-lowering.cpp @@ -510,7 +510,7 @@ static std::pair 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; } @@ -545,12 +545,12 @@ static std::pair 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(CurrentV->getType())) { if (!isSpecialPtr(VTy2->getElementType())) { - CurrentV = ConstantPointerNull::get(Type::getInt8PtrTy(V->getContext())); + CurrentV = ConstantPointerNull::get(PointerType::getUnqual(V->getContext())); fld_idx = -1; } } @@ -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, { diff --git a/src/llvm-lower-handlers.cpp b/src/llvm-lower-handlers.cpp index 35ce322ad3a719..13fd0f18a164fe 100644 --- a/src/llvm-lower-handlers.cpp +++ b/src/llvm-lower-handlers.cpp @@ -116,7 +116,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 }); @@ -179,7 +179,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 { diff --git a/src/llvm-pass-helpers.cpp b/src/llvm-pass-helpers.cpp index f217d27035200b..72aef680fbfd9d 100644 --- a/src/llvm-pass-helpers.cpp +++ b/src/llvm-pass-helpers.cpp @@ -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), @@ -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); @@ -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); @@ -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), diff --git a/src/llvm-ptls.cpp b/src/llvm-ptls.cpp index b2f58ca79f1c39..416f1442e39223 100644 --- a/src/llvm-ptls.cpp +++ b/src/llvm-ptls.cpp @@ -95,12 +95,12 @@ Instruction *LowerPTLS::emit_pgcstack_tp(Value *offset, Instruction *insertBefor if (offset) { SmallVector 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"); @@ -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"); }