@@ -1349,18 +1349,6 @@ static bool isPointerValueDeadOnEntryToFunction(
1349
1349
SmallVector<LoadInst *, 4 > Loads;
1350
1350
SmallVector<StoreInst *, 4 > Stores;
1351
1351
for (auto *U : GV->users ()) {
1352
- if (Operator::getOpcode (U) == Instruction::BitCast) {
1353
- for (auto *UU : U->users ()) {
1354
- if (auto *LI = dyn_cast<LoadInst>(UU))
1355
- Loads.push_back (LI);
1356
- else if (auto *SI = dyn_cast<StoreInst>(UU))
1357
- Stores.push_back (SI);
1358
- else
1359
- return false ;
1360
- }
1361
- continue ;
1362
- }
1363
-
1364
1352
Instruction *I = dyn_cast<Instruction>(U);
1365
1353
if (!I)
1366
1354
return false ;
@@ -1410,62 +1398,6 @@ static bool isPointerValueDeadOnEntryToFunction(
1410
1398
return true ;
1411
1399
}
1412
1400
1413
- // / C may have non-instruction users. Can all of those users be turned into
1414
- // / instructions?
1415
- static bool allNonInstructionUsersCanBeMadeInstructions (Constant *C) {
1416
- // We don't do this exhaustively. The most common pattern that we really need
1417
- // to care about is a constant GEP or constant bitcast - so just looking
1418
- // through one single ConstantExpr.
1419
- //
1420
- // The set of constants that this function returns true for must be able to be
1421
- // handled by makeAllConstantUsesInstructions.
1422
- for (auto *U : C->users ()) {
1423
- if (isa<Instruction>(U))
1424
- continue ;
1425
- if (!isa<ConstantExpr>(U))
1426
- // Non instruction, non-constantexpr user; cannot convert this.
1427
- return false ;
1428
- for (auto *UU : U->users ())
1429
- if (!isa<Instruction>(UU))
1430
- // A constantexpr used by another constant. We don't try and recurse any
1431
- // further but just bail out at this point.
1432
- return false ;
1433
- }
1434
-
1435
- return true ;
1436
- }
1437
-
1438
- // / C may have non-instruction users, and
1439
- // / allNonInstructionUsersCanBeMadeInstructions has returned true. Convert the
1440
- // / non-instruction users to instructions.
1441
- static void makeAllConstantUsesInstructions (Constant *C) {
1442
- SmallVector<ConstantExpr*,4 > Users;
1443
- for (auto *U : C->users ()) {
1444
- if (isa<ConstantExpr>(U))
1445
- Users.push_back (cast<ConstantExpr>(U));
1446
- else
1447
- // We should never get here; allNonInstructionUsersCanBeMadeInstructions
1448
- // should not have returned true for C.
1449
- assert (
1450
- isa<Instruction>(U) &&
1451
- " Can't transform non-constantexpr non-instruction to instruction!" );
1452
- }
1453
-
1454
- SmallVector<Value*,4 > UUsers;
1455
- for (auto *U : Users) {
1456
- UUsers.clear ();
1457
- append_range (UUsers, U->users ());
1458
- for (auto *UU : UUsers) {
1459
- Instruction *UI = cast<Instruction>(UU);
1460
- Instruction *NewU = U->getAsInstruction (UI);
1461
- UI->replaceUsesOfWith (U, NewU);
1462
- }
1463
- // We've replaced all the uses, so destroy the constant. (destroyConstant
1464
- // will update value handles and metadata.)
1465
- U->destroyConstant ();
1466
- }
1467
- }
1468
-
1469
1401
// For a global variable with one store, if the store dominates any loads,
1470
1402
// those loads will always load the stored value (as opposed to the
1471
1403
// initializer), even in the presence of recursion.
@@ -1523,7 +1455,6 @@ processInternalGlobal(GlobalVariable *GV, const GlobalStatus &GS,
1523
1455
GV->getValueType ()->isSingleValueType () &&
1524
1456
GV->getType ()->getAddressSpace () == 0 &&
1525
1457
!GV->isExternallyInitialized () &&
1526
- allNonInstructionUsersCanBeMadeInstructions (GV) &&
1527
1458
GS.AccessingFunction ->doesNotRecurse () &&
1528
1459
isPointerValueDeadOnEntryToFunction (GS.AccessingFunction , GV,
1529
1460
LookupDomTree)) {
@@ -1539,8 +1470,6 @@ processInternalGlobal(GlobalVariable *GV, const GlobalStatus &GS,
1539
1470
if (!isa<UndefValue>(GV->getInitializer ()))
1540
1471
new StoreInst (GV->getInitializer (), Alloca, &FirstI);
1541
1472
1542
- makeAllConstantUsesInstructions (GV);
1543
-
1544
1473
GV->replaceAllUsesWith (Alloca);
1545
1474
GV->eraseFromParent ();
1546
1475
++NumLocalized;
0 commit comments