@@ -142,7 +142,7 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
142
142
switch (II->getOpcode ()) {
143
143
case Instruction::Store: {
144
144
auto *storeI = cast<StoreInst>(II);
145
- if (storeI->getValueOperand () == use->get () && v2vMap. count (storeI-> getPointerOperand ()) == 0 ) {
145
+ if (storeI->getValueOperand () == use->get ()) {
146
146
SmallVector<Instruction *> origins;
147
147
auto hasOrigins = Provenance::tryFindPointerOrigin (storeI->getPointerOperand (), origins);
148
148
@@ -157,8 +157,7 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
157
157
cast<ArrayType>(array->getAllocatedType ())->getNumElements ());
158
158
159
159
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 ());
162
161
v2vMap[array] = newArray;
163
162
164
163
llvm::for_each (array->uses (), [&worklist](Use &U) { worklist.push_back (&U); });
@@ -181,14 +180,12 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
181
180
SmallVector<Value *> indices (cast<GetElementPtrInst>(II)->indices ());
182
181
183
182
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 ());
186
184
llvm::for_each (II->uses (), [&worklist](Use &U) { worklist.push_back (&U); });
187
185
} break ;
188
186
case Instruction::Load:
189
187
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 ());
192
189
llvm::for_each (II->uses (), [&worklist](Use &U) { worklist.push_back (&U); });
193
190
break ;
194
191
case Instruction::Select:
@@ -197,8 +194,8 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
197
194
continue ;
198
195
199
196
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 ());
202
199
llvm::for_each (II->uses (), [&worklist](Use &U) { worklist.push_back (&U); });
203
200
break ;
204
201
default :
@@ -211,37 +208,6 @@ bool InlineRaytracing::LowerAllocations(Function &F) {
211
208
212
209
RemapFunction (F, v2vMap, RF_IgnoreMissingLocals | RF_ReuseAndMutateDistinctMDs);
213
210
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
-
245
211
return true ;
246
212
}
247
213
0 commit comments