Skip to content

Commit 4f80c0b

Browse files
wpangfxbot
authored andcommitted
Fix assertions in GAS and private memory resolution
Change-Id: I91556a7a9c89e020cc672c76bcb8861c0461c7fb
1 parent e0c3163 commit 4f80c0b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

IGC/Compiler/CISACodeGen/ResolveGAS.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -432,21 +432,16 @@ bool GASPropagator::visitPHINode(PHINode &PN) {
432432
}
433433

434434
// Propagate this phi node.
435+
PHINode *NewPN = PHINode::Create(NonGASTy, e, "", &PN);
435436
for (unsigned i = 0; i != e; ++i)
436-
PN.setIncomingValue(i, NewIncomingValues[i]);
437-
PN.mutateType(NonGASTy);
437+
NewPN->addIncoming(NewIncomingValues[i], PN.getIncomingBlock(i));
438+
NewPN->takeName(&PN);
438439

439-
// Create additional cast to enable further propagation.
440440
BuilderType::InsertPointGuard Guard(*IRB);
441441
IRB->SetInsertPoint(PN.getParent()->getFirstNonPHI());
442-
Value *NewPtr = IRB->CreateAddrSpaceCast(&PN, GASTy);
443-
for (auto UI = PN.use_begin(), UE = PN.use_end(); UI != UE; /*EMPTY*/) {
444-
Use &U = *UI++;
445-
if (U.getUser() == NewPtr)
446-
continue;
447-
U.set(NewPtr);
448-
}
449-
442+
Value *NewPtr = IRB->CreateAddrSpaceCast(NewPN, GASTy);
443+
PN.replaceAllUsesWith(NewPtr);
444+
PN.eraseFromParent();
450445
return true;
451446
}
452447

IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,11 @@ bool PrivateMemoryResolution::resolveAllocaInstuctions(bool stackCall)
832832
uint64_t tmpAllocaSize = bufferSize;
833833
while (pTmpType != pTypeOfAccessedObject)
834834
{
835+
if (pTmpType->isStructTy() && pTmpType->getStructNumElements() == 1)
836+
{
837+
pTmpType = pTmpType->getStructElementType(0);
838+
}
839+
835840
if (pTmpType->isArrayTy())
836841
{
837842
tmpAllocaSize *= pTmpType->getArrayNumElements();

0 commit comments

Comments
 (0)