@@ -389,9 +389,7 @@ static void copyBetweenPrivateAndShadow(Value *L, GlobalVariable *Shadow,
389
389
Module &M = *Shadow->getParent ();
390
390
LocAlign = M.getDataLayout ().getValueOrABITypeAlignment (
391
391
MaybeAlign (cast<Argument>(L)->getParamAlignment ()), Ty);
392
- auto PtrTy = dyn_cast<PointerType>(cast<Argument>(L)->getType ());
393
- assert (PtrTy && " Expected pointer type" );
394
- T = PtrTy->getElementType ();
392
+ T = cast<Argument>(L)->getType ()->getPointerElementType ();
395
393
}
396
394
}
397
395
@@ -722,8 +720,8 @@ static void sharePFWGPrivateObjects(Function &F, const Triple &TT) {
722
720
Builder.SetInsertPoint (&LeaderBB->front ());
723
721
724
722
// 2) create the shared copy - "shadow" - for current arg
725
- GlobalVariable *Shadow;
726
- Value *RepVal;
723
+ GlobalVariable *Shadow = nullptr ;
724
+ Value *RepVal = nullptr ;
727
725
if (Arg.hasByValAttr ()) {
728
726
assert (Arg.getType ()->getPointerAddressSpace () ==
729
727
asUInt (spirv::AddrSpace::Private));
@@ -754,6 +752,9 @@ static void sharePFWGPrivateObjects(Function &F, const Triple &TT) {
754
752
Builder.CreatePointerBitCastOrAddrSpaceCast (Shadow, Arg.getType ());
755
753
}
756
754
755
+ if (!Shadow || !RepVal)
756
+ continue ;
757
+
757
758
// 3) replace argument with shadow in all uses
758
759
for (auto *U : Arg.users ())
759
760
U->replaceUsesOfWith (&Arg, RepVal);
0 commit comments