Skip to content

Commit bc9a467

Browse files
piotrkiraigcbot
authored andcommitted
Check if value stored at BLOCK_INDEX_INVOKR_FUNC is NULL
FixAddressSpace for PHINode
1 parent ea5ab51 commit bc9a467

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

IGC/Compiler/CISACodeGen/ResolveGAS.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,13 +1245,8 @@ void LowerGPCallArg::FixAddressSpaceInAllUses(Value* ptr, uint newAS, uint oldAS
12451245
continue;
12461246
}
12471247

1248-
if (BitCastInst* bitCastInst = dyn_cast<BitCastInst>(inst))
1249-
{
1250-
instType = dyn_cast<PointerType>(bitCastInst->getType());
1251-
}
1252-
else if (GetElementPtrInst* gepInst = dyn_cast<GetElementPtrInst>(inst))
1253-
{
1254-
instType = dyn_cast<PointerType>(gepInst->getType());
1248+
if (isa<BitCastInst>(inst) || isa<GetElementPtrInst>(inst) || isa<PHINode>(inst)) {
1249+
instType = dyn_cast<PointerType>(inst->getType());
12551250
}
12561251

12571252
if (instType && instType->getAddressSpace() == oldAS)

IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ namespace //Anonymous
15701570
{
15711571
if (auto blockDescrStruct = StructValue::get(callInst->getArgOperand(blockArgIdx)->stripPointerCasts()))
15721572
{
1573-
if (auto blockInvokeFunc = dyn_cast<llvm::Function>(blockDescrStruct->getValueStoredAtIndex(BLOCK_INDEX_INVOKE_FUNC)))
1573+
if (auto blockInvokeFunc = dyn_cast_or_null<llvm::Function>(blockDescrStruct->getValueStoredAtIndex(BLOCK_INDEX_INVOKE_FUNC)))
15741574
{
15751575
callInst->setCalledFunction(blockInvokeFunc);
15761576
changed = true;

0 commit comments

Comments
 (0)