@@ -60,11 +60,7 @@ static Value *decay_derived(jl_codectx_t &ctx, Value *V)
6060 if (T->getPointerAddressSpace () == AddressSpace::Derived)
6161 return V;
6262 // Once llvm deletes pointer element types, we won't need it here any more either.
63- #if JL_LLVM_VERSION >= 170000
6463 Type *NewT = PointerType::get (T, AddressSpace::Derived);
65- #else
66- Type *NewT = PointerType::getWithSamePointeeType (cast<PointerType>(T), AddressSpace::Derived);
67- #endif
6864 return ctx.builder .CreateAddrSpaceCast (V, NewT);
6965}
7066
@@ -74,11 +70,7 @@ static Value *maybe_decay_tracked(jl_codectx_t &ctx, Value *V)
7470 Type *T = V->getType ();
7571 if (T->getPointerAddressSpace () != AddressSpace::Tracked)
7672 return V;
77- #if JL_LLVM_VERSION >= 170000
7873 Type *NewT = PointerType::get (T, AddressSpace::Derived);
79- #else
80- Type *NewT = PointerType::getWithSamePointeeType (cast<PointerType>(T), AddressSpace::Derived);
81- #endif
8274 return ctx.builder .CreateAddrSpaceCast (V, NewT);
8375}
8476
@@ -1010,54 +1002,6 @@ static void emit_memcpy_llvm(jl_codectx_t &ctx, Value *dst, jl_aliasinfo_t const
10101002{
10111003 if (sz == 0 )
10121004 return ;
1013- #if JL_LLVM_VERSION < 170000
1014- // If the types are small and simple, use load and store directly.
1015- // Going through memcpy can cause LLVM (e.g. SROA) to create bitcasts between float and int
1016- // that interferes with other optimizations.
1017- // TODO: Restore this for opaque pointers? Needs extra type information from the caller.
1018- if (ctx.builder .getContext ().supportsTypedPointers () && sz <= 64 ) {
1019- // The size limit is arbitrary but since we mainly care about floating points and
1020- // machine size vectors this should be enough.
1021- const DataLayout &DL = jl_Module->getDataLayout ();
1022- auto srcty = cast<PointerType>(src->getType ());
1023- // TODO unsafe nonopaque pointer
1024- auto srcel = srcty->getNonOpaquePointerElementType ();
1025- auto dstty = cast<PointerType>(dst->getType ());
1026- // TODO unsafe nonopaque pointer
1027- auto dstel = dstty->getNonOpaquePointerElementType ();
1028- while (srcel->isArrayTy () && srcel->getArrayNumElements () == 1 ) {
1029- src = ctx.builder .CreateConstInBoundsGEP2_32 (srcel, src, 0 , 0 );
1030- srcel = srcel->getArrayElementType ();
1031- srcty = srcel->getPointerTo ();
1032- }
1033- while (dstel->isArrayTy () && dstel->getArrayNumElements () == 1 ) {
1034- dst = ctx.builder .CreateConstInBoundsGEP2_32 (dstel, dst, 0 , 0 );
1035- dstel = dstel->getArrayElementType ();
1036- dstty = dstel->getPointerTo ();
1037- }
1038-
1039- llvm::Type *directel = nullptr ;
1040- if (srcel->isSized () && srcel->isSingleValueType () && DL.getTypeStoreSize (srcel) == sz) {
1041- directel = srcel;
1042- dst = emit_bitcast (ctx, dst, srcty);
1043- }
1044- else if (dstel->isSized () && dstel->isSingleValueType () &&
1045- DL.getTypeStoreSize (dstel) == sz) {
1046- directel = dstel;
1047- src = emit_bitcast (ctx, src, dstty);
1048- }
1049- if (directel) {
1050- if (isa<Instruction>(src) && !src->hasName ())
1051- setName (ctx.emission_context , src, " memcpy_refined_src" );
1052- if (isa<Instruction>(dst) && !dst->hasName ())
1053- setName (ctx.emission_context , dst, " memcpy_refined_dst" );
1054- auto val = src_ai.decorateInst (ctx.builder .CreateAlignedLoad (directel, src, MaybeAlign (align_src), is_volatile));
1055- dst_ai.decorateInst (ctx.builder .CreateAlignedStore (val, dst, align_dst, is_volatile));
1056- ++SkippedMemcpys;
1057- return ;
1058- }
1059- }
1060- #endif
10611005 ++EmittedMemcpys;
10621006
10631007 // the memcpy intrinsic does not allow to specify different alias tags
@@ -1940,7 +1884,7 @@ static std::pair<Value*, bool> emit_isa(jl_codectx_t &ctx, const jl_cgval_t &x,
19401884 // actual `isa` calls, this optimization should already have been performed upstream
19411885 // anyway, but having this optimization in codegen might still be beneficial for
19421886 // `typeassert`s if we can make it correct.
1943- Optional <bool > known_isa;
1887+ std::optional <bool > known_isa;
19441888 jl_value_t *intersected_type = type;
19451889 if (x.constant )
19461890 known_isa = jl_isa (x.constant , type);
@@ -3786,11 +3730,7 @@ static void recursively_adjust_ptr_type(llvm::Value *Val, unsigned FromAS, unsig
37863730 for (auto *User : Val->users ()) {
37873731 if (isa<GetElementPtrInst>(User)) {
37883732 GetElementPtrInst *Inst = cast<GetElementPtrInst>(User);
3789- #if JL_LLVM_VERSION >= 170000
37903733 Inst->mutateType (PointerType::get (Inst->getType (), ToAS));
3791- #else
3792- Inst->mutateType (PointerType::getWithSamePointeeType (cast<PointerType>(Inst->getType ()), ToAS));
3793- #endif
37943734 recursively_adjust_ptr_type (Inst, FromAS, ToAS);
37953735 }
37963736 else if (isa<IntrinsicInst>(User)) {
@@ -3799,11 +3739,7 @@ static void recursively_adjust_ptr_type(llvm::Value *Val, unsigned FromAS, unsig
37993739 }
38003740 else if (isa<BitCastInst>(User)) {
38013741 BitCastInst *Inst = cast<BitCastInst>(User);
3802- #if JL_LLVM_VERSION >= 170000
38033742 Inst->mutateType (PointerType::get (Inst->getType (), ToAS));
3804- #else
3805- Inst->mutateType (PointerType::getWithSamePointeeType (cast<PointerType>(Inst->getType ()), ToAS));
3806- #endif
38073743 recursively_adjust_ptr_type (Inst, FromAS, ToAS);
38083744 }
38093745 }
0 commit comments