Skip to content

Commit 7d4e0ed

Browse files
committed
[SYCL] Minor fixes in LowerWGScope
Signed-off-by: Artur Gainullin <[email protected]>
1 parent 3b7fdf4 commit 7d4e0ed

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/SYCLLowerIR/LowerWGScope.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,7 @@ static void copyBetweenPrivateAndShadow(Value *L, GlobalVariable *Shadow,
389389
Module &M = *Shadow->getParent();
390390
LocAlign = M.getDataLayout().getValueOrABITypeAlignment(
391391
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();
395393
}
396394
}
397395

@@ -722,8 +720,8 @@ static void sharePFWGPrivateObjects(Function &F, const Triple &TT) {
722720
Builder.SetInsertPoint(&LeaderBB->front());
723721

724722
// 2) create the shared copy - "shadow" - for current arg
725-
GlobalVariable *Shadow;
726-
Value *RepVal;
723+
GlobalVariable *Shadow = nullptr;
724+
Value *RepVal = nullptr;
727725
if (Arg.hasByValAttr()) {
728726
assert(Arg.getType()->getPointerAddressSpace() ==
729727
asUInt(spirv::AddrSpace::Private));
@@ -754,6 +752,9 @@ static void sharePFWGPrivateObjects(Function &F, const Triple &TT) {
754752
Builder.CreatePointerBitCastOrAddrSpaceCast(Shadow, Arg.getType());
755753
}
756754

755+
if (!Shadow || !RepVal)
756+
continue;
757+
757758
// 3) replace argument with shadow in all uses
758759
for (auto *U : Arg.users())
759760
U->replaceUsesOfWith(&Arg, RepVal);

0 commit comments

Comments
 (0)