Skip to content

Commit 194a213

Browse files
jaladreipsigcbot
authored andcommitted
Handle indirect calls in MergeAllocas pass
Handle indirect calls in MergeAllocas pass
1 parent 35faa23 commit 194a213

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

IGC/AdaptorCommon/RayTracing/MergeAllocas.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ AllocationBasedLivenessAnalysis::LivenessData* AllocationBasedLivenessAnalysis::
9292
// figure out the potential accesses to the memory via GEP and bitcasts
9393
while (!worklist.empty() && !hasNoLifetimeEnd)
9494
{
95-
auto* use = worklist.pop_back_val();;
95+
auto* use = worklist.pop_back_val();
9696
auto* II = cast<Instruction>(use->getUser());
9797

9898
if (allUsers.contains(II))
@@ -112,12 +112,26 @@ AllocationBasedLivenessAnalysis::LivenessData* AllocationBasedLivenessAnalysis::
112112
hasNoLifetimeEnd = true;
113113
break;
114114
case Instruction::Store:
115-
if (cast<StoreInst>(II)->getValueOperand() == cast<Value>(use))
115+
{
116+
auto* storeI = cast<StoreInst>(II);
117+
if (storeI->getValueOperand() == cast<Value>(use))
116118
hasNoLifetimeEnd = true;
119+
}
117120
break;
118121
case Instruction::Call:
119-
if (!cast<CallInst>(II)->getCalledFunction()->getArg(use->getOperandNo())->hasAttribute(llvm::Attribute::NoCapture))
122+
{
123+
auto* callI = cast<CallInst>(II);
124+
if (auto* fn = callI->getCalledFunction())
125+
{
126+
if (!fn->getArg(use->getOperandNo())->hasAttribute(llvm::Attribute::NoCapture))
127+
hasNoLifetimeEnd = true;
128+
}
129+
else
130+
{
131+
// TODO: can indirect calls somehow pass nocapture?
120132
hasNoLifetimeEnd = true;
133+
}
134+
}
121135
break;
122136
default:
123137
break;

0 commit comments

Comments
 (0)