@@ -290,13 +290,6 @@ bool PPCMergeStringPool::mergeModuleStringPool(Module &M) {
290
290
return true ;
291
291
}
292
292
293
- static bool userHasOperand (User *TheUser, GlobalVariable *GVOperand) {
294
- for (Value *Op : TheUser->operands ())
295
- if (Op == GVOperand)
296
- return true ;
297
- return false ;
298
- }
299
-
300
293
// For pooled strings we need to add the offset into the pool for each string.
301
294
// This is done by adding a Get Element Pointer (GEP) before each user. This
302
295
// function adds the GEP.
@@ -307,29 +300,13 @@ void PPCMergeStringPool::replaceUsesWithGEP(GlobalVariable *GlobalToReplace,
307
300
Indices.push_back (ConstantInt::get (Type::getInt32Ty (*Context), 0 ));
308
301
Indices.push_back (ConstantInt::get (Type::getInt32Ty (*Context), ElementIndex));
309
302
310
- // Need to save a temporary copy of each user list because we remove uses
311
- // as we replace them.
312
- SmallVector<User *> Users;
313
- for (User *CurrentUser : GlobalToReplace->users ())
314
- Users.push_back (CurrentUser);
315
-
316
- for (User *CurrentUser : Users) {
317
- // The user was not found so it must have been replaced earlier.
318
- if (!userHasOperand (CurrentUser, GlobalToReplace))
319
- continue ;
320
-
321
- // We cannot replace operands in globals so we ignore those.
322
- if (isa<GlobalValue>(CurrentUser))
323
- continue ;
324
-
325
- Constant *ConstGEP = ConstantExpr::getInBoundsGetElementPtr (
326
- PooledStructType, GPool, Indices);
327
- LLVM_DEBUG (dbgs () << " Replacing this global:\n " );
328
- LLVM_DEBUG (GlobalToReplace->dump ());
329
- LLVM_DEBUG (dbgs () << " with this:\n " );
330
- LLVM_DEBUG (ConstGEP->dump ());
331
- GlobalToReplace->replaceAllUsesWith (ConstGEP);
332
- }
303
+ Constant *ConstGEP =
304
+ ConstantExpr::getInBoundsGetElementPtr (PooledStructType, GPool, Indices);
305
+ LLVM_DEBUG (dbgs () << " Replacing this global:\n " );
306
+ LLVM_DEBUG (GlobalToReplace->dump ());
307
+ LLVM_DEBUG (dbgs () << " with this:\n " );
308
+ LLVM_DEBUG (ConstGEP->dump ());
309
+ GlobalToReplace->replaceAllUsesWith (ConstGEP);
333
310
}
334
311
335
312
} // namespace
0 commit comments