@@ -87,7 +87,9 @@ bindPolymorphicArgumentsFromComponentIndices(IRGenFunction &IGF,
8787 requirements.size () * IGF.IGM .getPointerSize ().getValue ());
8888
8989 auto genericArgsOffset = IGF.Builder .CreateSub (size, genericArgsSize);
90- args = IGF.Builder .CreateInBoundsGEP (args, genericArgsOffset);
90+ args = IGF.Builder .CreateInBoundsGEP (
91+ args->getType ()->getScalarType ()->getPointerElementType (), args,
92+ genericArgsOffset);
9193 }
9294 bindFromGenericRequirementsBuffer (IGF, requirements,
9395 Address (args, IGF.IGM .getPointerAlignment ()),
@@ -414,7 +416,10 @@ getWitnessTableForComputedComponent(IRGenModule &IGM,
414416 } else {
415417 offset = llvm::ConstantInt::get (IGM.SizeTy , 0 );
416418 }
417- auto elt = IGF.Builder .CreateInBoundsGEP (componentArgsBuf, offset);
419+ auto elt = IGF.Builder .CreateInBoundsGEP (componentArgsBuf->getType ()
420+ ->getScalarType ()
421+ ->getPointerElementType (),
422+ componentArgsBuf, offset);
418423 auto eltAddr = ti.getAddressForPointer (
419424 IGF.Builder .CreateBitCast (elt, ti.getStorageType ()->getPointerTo ()));
420425 ti.destroy (IGF, eltAddr, ty,
@@ -466,8 +471,12 @@ getWitnessTableForComputedComponent(IRGenModule &IGM,
466471 } else {
467472 offset = llvm::ConstantInt::get (IGM.SizeTy , 0 );
468473 }
469- auto sourceElt = IGF.Builder .CreateInBoundsGEP (sourceArgsBuf, offset);
470- auto destElt = IGF.Builder .CreateInBoundsGEP (destArgsBuf, offset);
474+ auto sourceElt = IGF.Builder .CreateInBoundsGEP (
475+ sourceArgsBuf->getType ()->getScalarType ()->getPointerElementType (),
476+ sourceArgsBuf, offset);
477+ auto destElt = IGF.Builder .CreateInBoundsGEP (
478+ destArgsBuf->getType ()->getScalarType ()->getPointerElementType (),
479+ destArgsBuf, offset);
471480 auto sourceEltAddr = ti.getAddressForPointer (
472481 IGF.Builder .CreateBitCast (sourceElt,
473482 ti.getStorageType ()->getPointerTo ()));
@@ -487,10 +496,14 @@ getWitnessTableForComputedComponent(IRGenModule &IGM,
487496 auto notAlignMask = IGF.Builder .CreateNot (envAlignMask);
488497 offset = IGF.Builder .CreateAdd (offset, envAlignMask);
489498 offset = IGF.Builder .CreateAnd (offset, notAlignMask);
490-
491- auto sourceEnv = IGF.Builder .CreateInBoundsGEP (sourceArgsBuf, offset);
492- auto destEnv = IGF.Builder .CreateInBoundsGEP (destArgsBuf, offset);
493-
499+
500+ auto sourceEnv = IGF.Builder .CreateInBoundsGEP (
501+ sourceArgsBuf->getType ()->getScalarType ()->getPointerElementType (),
502+ sourceArgsBuf, offset);
503+ auto destEnv = IGF.Builder .CreateInBoundsGEP (
504+ destArgsBuf->getType ()->getScalarType ()->getPointerElementType (),
505+ destArgsBuf, offset);
506+
494507 auto align = IGM.getPointerAlignment ().getValue ();
495508 IGF.Builder .CreateMemCpy (destEnv, llvm::MaybeAlign (align), sourceEnv,
496509 llvm::MaybeAlign (align),
@@ -601,8 +614,10 @@ getInitializerForComputedComponent(IRGenModule &IGM,
601614 offset = IGF.Builder .CreateAdd (offset, alignMask);
602615 offset = IGF.Builder .CreateAnd (offset, notAlignMask);
603616 }
604-
605- auto ptr = IGF.Builder .CreateInBoundsGEP (src, offset);
617+
618+ auto ptr = IGF.Builder .CreateInBoundsGEP (
619+ src->getType ()->getScalarType ()->getPointerElementType (), src,
620+ offset);
606621 auto addr = ti.getAddressForPointer (IGF.Builder .CreateBitCast (
607622 ptr, ti.getStorageType ()->getPointerTo ()));
608623 srcAddresses.push_back (addr);
@@ -630,8 +645,10 @@ getInitializerForComputedComponent(IRGenModule &IGM,
630645 offset = IGF.Builder .CreateAdd (offset, alignMask);
631646 offset = IGF.Builder .CreateAnd (offset, notAlignMask);
632647 }
633-
634- auto ptr = IGF.Builder .CreateInBoundsGEP (dest, offset);
648+
649+ auto ptr = IGF.Builder .CreateInBoundsGEP (
650+ dest->getType ()->getScalarType ()->getPointerElementType (), dest,
651+ offset);
635652 auto destAddr = ti.getAddressForPointer (IGF.Builder .CreateBitCast (
636653 ptr, ti.getStorageType ()->getPointerTo ()));
637654
@@ -660,7 +677,9 @@ getInitializerForComputedComponent(IRGenModule &IGM,
660677 auto notGenericEnvAlignMask = IGF.Builder .CreateNot (genericEnvAlignMask);
661678 offset = IGF.Builder .CreateAdd (offset, genericEnvAlignMask);
662679 offset = IGF.Builder .CreateAnd (offset, notGenericEnvAlignMask);
663- destGenericEnv = IGF.Builder .CreateInBoundsGEP (dest, offset);
680+ destGenericEnv = IGF.Builder .CreateInBoundsGEP (
681+ dest->getType ()->getScalarType ()->getPointerElementType (), dest,
682+ offset);
664683 }
665684
666685 auto align = IGM.getPointerAlignment ().getValue ();
0 commit comments