Skip to content

Commit fdc6004

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 4262034: Purge unused instructions after value remapping in new inline raytracing
Purge unused instructions after value remapping in new inline raytracing
1 parent 2c37305 commit fdc6004

File tree

1 file changed

+6
-40
lines changed

1 file changed

+6
-40
lines changed

IGC/AdaptorCommon/RayTracing/NewTraceRayInlineLoweringPass.cpp

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
142142
switch (II->getOpcode()) {
143143
case Instruction::Store: {
144144
auto *storeI = cast<StoreInst>(II);
145-
if (storeI->getValueOperand() == use->get() && v2vMap.count(storeI->getPointerOperand()) == 0) {
145+
if (storeI->getValueOperand() == use->get()) {
146146
SmallVector<Instruction *> origins;
147147
auto hasOrigins = Provenance::tryFindPointerOrigin(storeI->getPointerOperand(), origins);
148148

@@ -157,8 +157,7 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
157157
cast<ArrayType>(array->getAllocatedType())->getNumElements());
158158

159159
IRB.SetInsertPoint(array);
160-
auto *newArray = IRB.CreateAlloca(ty, nullptr, VALUE_NAME("RQObjectArrayAlloca_") + array->getName(),
161-
array->getAddressSpace());
160+
auto *newArray = IRB.CreateAlloca(ty, nullptr, array->getName(), array->getAddressSpace());
162161
v2vMap[array] = newArray;
163162

164163
llvm::for_each(array->uses(), [&worklist](Use &U) { worklist.push_back(&U); });
@@ -181,14 +180,12 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
181180
SmallVector<Value *> indices(cast<GetElementPtrInst>(II)->indices());
182181

183182
IRB.SetInsertPoint(II);
184-
v2vMap[II] = IRB.CreateInBoundsGEP(array->getAllocatedType(), array, indices,
185-
VALUE_NAME("RQObjectGEP_") + II->getName());
183+
v2vMap[II] = IRB.CreateInBoundsGEP(array->getAllocatedType(), array, indices, II->getName());
186184
llvm::for_each(II->uses(), [&worklist](Use &U) { worklist.push_back(&U); });
187185
} break;
188186
case Instruction::Load:
189187
IRB.SetInsertPoint(II);
190-
v2vMap[II] = IRB.CreateLoad(m_RQObjectType->getPointerTo(), v2vMap[II->getOperand(0)],
191-
VALUE_NAME("RQObjectLoad_") + II->getName());
188+
v2vMap[II] = IRB.CreateLoad(m_RQObjectType->getPointerTo(), v2vMap[II->getOperand(0)], II->getName());
192189
llvm::for_each(II->uses(), [&worklist](Use &U) { worklist.push_back(&U); });
193190
break;
194191
case Instruction::Select:
@@ -197,8 +194,8 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
197194
continue;
198195

199196
IRB.SetInsertPoint(II);
200-
v2vMap[II] = IRB.CreateSelect(II->getOperand(0), v2vMap[II->getOperand(1)], v2vMap[II->getOperand(2)],
201-
VALUE_NAME("RQObjectSelect_") + II->getName());
197+
v2vMap[II] =
198+
IRB.CreateSelect(II->getOperand(0), v2vMap[II->getOperand(1)], v2vMap[II->getOperand(2)], II->getName());
202199
llvm::for_each(II->uses(), [&worklist](Use &U) { worklist.push_back(&U); });
203200
break;
204201
default:
@@ -211,37 +208,6 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
211208

212209
RemapFunction(F, v2vMap, RF_IgnoreMissingLocals | RF_ReuseAndMutateDistinctMDs);
213210

214-
DenseSet<Instruction *> canBeDeleted;
215-
216-
// try to remove as many of unused instructions as possible
217-
for (auto [from, _] : v2vMap) {
218-
219-
if (auto *I = dyn_cast<Instruction>(const_cast<Value *>(from))) {
220-
221-
if (I->getType()->isVoidTy())
222-
continue;
223-
224-
canBeDeleted.insert(I);
225-
}
226-
}
227-
228-
while (!canBeDeleted.empty()) {
229-
230-
bool changed = false;
231-
for (auto *V : canBeDeleted) {
232-
233-
if (V->use_empty()) {
234-
235-
canBeDeleted.erase(V);
236-
cast<Instruction>(V)->eraseFromParent();
237-
changed = true;
238-
break;
239-
}
240-
}
241-
if (!changed) // no progress has been done
242-
break;
243-
}
244-
245211
return true;
246212
}
247213

0 commit comments

Comments
 (0)