Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Transforms/Utils/SSAUpdater.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- SSAUpdater.cpp - Unstructured SSA Update Tool ----------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file implements the SSAUpdater class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/Transforms/Utils/SSAUpdater.h"
14
#include "llvm/ADT/DenseMap.h"
15
#include "llvm/ADT/STLExtras.h"
16
#include "llvm/ADT/SmallVector.h"
17
#include "llvm/ADT/TinyPtrVector.h"
18
#include "llvm/Analysis/InstructionSimplify.h"
19
#include "llvm/IR/BasicBlock.h"
20
#include "llvm/IR/CFG.h"
21
#include "llvm/IR/Constants.h"
22
#include "llvm/IR/DebugLoc.h"
23
#include "llvm/IR/Instruction.h"
24
#include "llvm/IR/Instructions.h"
25
#include "llvm/IR/Module.h"
26
#include "llvm/IR/Use.h"
27
#include "llvm/IR/Value.h"
28
#include "llvm/IR/ValueHandle.h"
29
#include "llvm/Support/Casting.h"
30
#include "llvm/Support/Debug.h"
31
#include "llvm/Support/raw_ostream.h"
32
#include "llvm/Transforms/Utils/SSAUpdaterImpl.h"
33
#include <cassert>
34
#include <utility>
35
36
using namespace llvm;
37
38
#define DEBUG_TYPE "ssaupdater"
39
40
using AvailableValsTy = DenseMap<BasicBlock *, Value *>;
41
42
3.42M
static AvailableValsTy &getAvailableVals(void *AV) {
43
3.42M
  return *static_cast<AvailableValsTy*>(AV);
44
3.42M
}
45
46
SSAUpdater::SSAUpdater(SmallVectorImpl<PHINode *> *NewPHI)
47
795k
  : InsertedPHIs(NewPHI) {}
48
49
795k
SSAUpdater::~SSAUpdater() {
50
795k
  delete static_cast<AvailableValsTy*>(AV);
51
795k
}
52
53
869k
void SSAUpdater::Initialize(Type *Ty, StringRef Name) {
54
869k
  if (!AV)
55
763k
    AV = new AvailableValsTy();
56
106k
  else
57
106k
    getAvailableVals(AV).clear();
58
869k
  ProtoType = Ty;
59
869k
  ProtoName = Name;
60
869k
}
61
62
1.42M
bool SSAUpdater::HasValueForBlock(BasicBlock *BB) const {
63
1.42M
  return getAvailableVals(AV).count(BB);
64
1.42M
}
65
66
3
Value *SSAUpdater::FindValueForBlock(BasicBlock *BB) const {
67
3
  AvailableValsTy::iterator AVI = getAvailableVals(AV).find(BB);
68
3
  return (AVI != getAvailableVals(AV).end()) ? 
AVI->second2
:
nullptr1
;
69
3
}
70
71
1.33M
void SSAUpdater::AddAvailableValue(BasicBlock *BB, Value *V) {
72
1.33M
  assert(ProtoType && "Need to initialize SSAUpdater");
73
1.33M
  assert(ProtoType == V->getType() &&
74
1.33M
         "All rewritten values must have the same type");
75
1.33M
  getAvailableVals(AV)[BB] = V;
76
1.33M
}
77
78
static bool IsEquivalentPHI(PHINode *PHI,
79
50.3k
                        SmallDenseMap<BasicBlock *, Value *, 8> &ValueMapping) {
80
50.3k
  unsigned PHINumValues = PHI->getNumIncomingValues();
81
50.3k
  if (PHINumValues != ValueMapping.size())
82
13
    return false;
83
50.3k
84
50.3k
  // Scan the phi to see if it matches.
85
142k
  
for (unsigned i = 0, e = PHINumValues; 50.3k
i != e;
++i92.3k
)
86
97.0k
    if (ValueMapping[PHI->getIncomingBlock(i)] !=
87
97.0k
        PHI->getIncomingValue(i)) {
88
4.74k
      return false;
89
4.74k
    }
90
50.3k
91
50.3k
  
return true45.6k
;
92
50.3k
}
93
94
560k
Value *SSAUpdater::GetValueAtEndOfBlock(BasicBlock *BB) {
95
560k
  Value *Res = GetValueAtEndOfBlockInternal(BB);
96
560k
  return Res;
97
560k
}
98
99
349k
Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {
100
349k
  // If there is no definition of the renamed variable in this block, just use
101
349k
  // GetValueAtEndOfBlock to do our work.
102
349k
  if (!HasValueForBlock(BB))
103
201k
    return GetValueAtEndOfBlock(BB);
104
147k
105
147k
  // Otherwise, we have the hard case.  Get the live-in values for each
106
147k
  // predecessor.
107
147k
  SmallVector<std::pair<BasicBlock *, Value *>, 8> PredValues;
108
147k
  Value *SingularValue = nullptr;
109
147k
110
147k
  // We can get our predecessor info by walking the pred_iterator list, but it
111
147k
  // is relatively slow.  If we already have PHI nodes in this block, walk one
112
147k
  // of them to get the predecessor list instead.
113
147k
  if (PHINode *SomePhi = dyn_cast<PHINode>(BB->begin())) {
114
173k
    for (unsigned i = 0, e = SomePhi->getNumIncomingValues(); i != e; 
++i116k
) {
115
116k
      BasicBlock *PredBB = SomePhi->getIncomingBlock(i);
116
116k
      Value *PredVal = GetValueAtEndOfBlock(PredBB);
117
116k
      PredValues.push_back(std::make_pair(PredBB, PredVal));
118
116k
119
116k
      // Compute SingularValue.
120
116k
      if (i == 0)
121
56.9k
        SingularValue = PredVal;
122
59.6k
      else if (PredVal != SingularValue)
123
48.8k
        SingularValue = nullptr;
124
116k
    }
125
90.9k
  } else {
126
90.9k
    bool isFirstPred = true;
127
223k
    for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; 
++PI132k
) {
128
132k
      BasicBlock *PredBB = *PI;
129
132k
      Value *PredVal = GetValueAtEndOfBlock(PredBB);
130
132k
      PredValues.push_back(std::make_pair(PredBB, PredVal));
131
132k
132
132k
      // Compute SingularValue.
133
132k
      if (isFirstPred) {
134
90.9k
        SingularValue = PredVal;
135
90.9k
        isFirstPred = false;
136
90.9k
      } else 
if (41.4k
PredVal != SingularValue41.4k
)
137
445
        SingularValue = nullptr;
138
132k
    }
139
90.9k
  }
140
147k
141
147k
  // If there are no predecessors, just return undef.
142
147k
  if (PredValues.empty())
143
0
    return UndefValue::get(ProtoType);
144
147k
145
147k
  // Otherwise, if all the merged values are the same, just use it.
146
147k
  if (SingularValue)
147
99.4k
    return SingularValue;
148
48.4k
149
48.4k
  // Otherwise, we do need a PHI: check to see if we already have one available
150
48.4k
  // in this block that produces the right value.
151
48.4k
  if (isa<PHINode>(BB->begin())) {
152
48.0k
    SmallDenseMap<BasicBlock *, Value *, 8> ValueMapping(PredValues.begin(),
153
48.0k
                                                         PredValues.end());
154
50.3k
    for (PHINode &SomePHI : BB->phis()) {
155
50.3k
      if (IsEquivalentPHI(&SomePHI, ValueMapping))
156
45.6k
        return &SomePHI;
157
50.3k
    }
158
48.0k
  }
159
48.4k
160
48.4k
  // Ok, we have no way out, insert a new one now.
161
48.4k
  PHINode *InsertedPHI = PHINode::Create(ProtoType, PredValues.size(),
162
2.81k
                                         ProtoName, &BB->front());
163
2.81k
164
2.81k
  // Fill in all the predecessors of the PHI.
165
2.81k
  for (const auto &PredValue : PredValues)
166
5.73k
    InsertedPHI->addIncoming(PredValue.second, PredValue.first);
167
2.81k
168
2.81k
  // See if the PHI node can be merged to a single value.  This can happen in
169
2.81k
  // loop cases when we get a PHI of itself and one other value.
170
2.81k
  if (Value *V =
171
0
          SimplifyInstruction(InsertedPHI, BB->getModule()->getDataLayout())) {
172
0
    InsertedPHI->eraseFromParent();
173
0
    return V;
174
0
  }
175
2.81k
176
2.81k
  // Set the DebugLoc of the inserted PHI, if available.
177
2.81k
  DebugLoc DL;
178
2.81k
  if (const Instruction *I = BB->getFirstNonPHI())
179
2.81k
      DL = I->getDebugLoc();
180
2.81k
  InsertedPHI->setDebugLoc(DL);
181
2.81k
182
2.81k
  // If the client wants to know about all new instructions, tell it.
183
2.81k
  if (InsertedPHIs) 
InsertedPHIs->push_back(InsertedPHI)2.63k
;
184
2.81k
185
2.81k
  LLVM_DEBUG(dbgs() << "  Inserted PHI: " << *InsertedPHI << "\n");
186
2.81k
  return InsertedPHI;
187
2.81k
}
188
189
412k
void SSAUpdater::RewriteUse(Use &U) {
190
412k
  Instruction *User = cast<Instruction>(U.getUser());
191
412k
192
412k
  Value *V;
193
412k
  if (PHINode *UserPN = dyn_cast<PHINode>(User))
194
108k
    V = GetValueAtEndOfBlock(UserPN->getIncomingBlock(U));
195
304k
  else
196
304k
    V = GetValueInMiddleOfBlock(User->getParent());
197
412k
198
412k
  // Notify that users of the existing value that it is being replaced.
199
412k
  Value *OldVal = U.get();
200
412k
  if (OldVal != V && 
OldVal->hasValueHandle()369k
)
201
68.9k
    ValueHandleBase::ValueIsRAUWd(OldVal, V);
202
412k
203
412k
  U.set(V);
204
412k
}
205
206
80
void SSAUpdater::RewriteUseAfterInsertions(Use &U) {
207
80
  Instruction *User = cast<Instruction>(U.getUser());
208
80
209
80
  Value *V;
210
80
  if (PHINode *UserPN = dyn_cast<PHINode>(User))
211
57
    V = GetValueAtEndOfBlock(UserPN->getIncomingBlock(U));
212
23
  else
213
23
    V = GetValueAtEndOfBlock(User->getParent());
214
80
215
80
  U.set(V);
216
80
}
217
218
namespace llvm {
219
220
template<>
221
class SSAUpdaterTraits<SSAUpdater> {
222
public:
223
  using BlkT = BasicBlock;
224
  using ValT = Value *;
225
  using PhiT = PHINode;
226
  using BlkSucc_iterator = succ_iterator;
227
228
1.59M
  static BlkSucc_iterator BlkSucc_begin(BlkT *BB) { return succ_begin(BB); }
229
1.59M
  static BlkSucc_iterator BlkSucc_end(BlkT *BB) { return succ_end(BB); }
230
231
  class PHI_iterator {
232
  private:
233
    PHINode *PHI;
234
    unsigned idx;
235
236
  public:
237
    explicit PHI_iterator(PHINode *P) // begin iterator
238
303k
      : PHI(P), idx(0) {}
239
    PHI_iterator(PHINode *P, bool) // end iterator
240
303k
      : PHI(P), idx(PHI->getNumIncomingValues()) {}
241
242
97.5k
    PHI_iterator &operator++() { ++idx; return *this; }
243
401k
    bool operator==(const PHI_iterator& x) const { return idx == x.idx; }
244
401k
    bool operator!=(const PHI_iterator& x) const { return !operator==(x); }
245
246
371k
    Value *getIncomingValue() { return PHI->getIncomingValue(idx); }
247
371k
    BasicBlock *getIncomingBlock() { return PHI->getIncomingBlock(idx); }
248
  };
249
250
303k
  static PHI_iterator PHI_begin(PhiT *PHI) { return PHI_iterator(PHI); }
251
303k
  static PHI_iterator PHI_end(PhiT *PHI) {
252
303k
    return PHI_iterator(PHI, true);
253
303k
  }
254
255
  /// FindPredecessorBlocks - Put the predecessors of Info->BB into the Preds
256
  /// vector, set Info->NumPreds, and allocate space in Info->Preds.
257
  static void FindPredecessorBlocks(BasicBlock *BB,
258
1.16M
                                    SmallVectorImpl<BasicBlock *> *Preds) {
259
1.16M
    // We can get our predecessor info by walking the pred_iterator list,
260
1.16M
    // but it is relatively slow.  If we already have PHI nodes in this
261
1.16M
    // block, walk one of them to get the predecessor list instead.
262
1.16M
    if (PHINode *SomePhi = dyn_cast<PHINode>(BB->begin())) {
263
311k
      Preds->append(SomePhi->block_begin(), SomePhi->block_end());
264
853k
    } else {
265
1.94M
      for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; 
++PI1.09M
)
266
1.09M
        Preds->push_back(*PI);
267
853k
    }
268
1.16M
  }
269
270
  /// GetUndefVal - Get an undefined value of the same type as the value
271
  /// being handled.
272
825
  static Value *GetUndefVal(BasicBlock *BB, SSAUpdater *Updater) {
273
825
    return UndefValue::get(Updater->ProtoType);
274
825
  }
275
276
  /// CreateEmptyPHI - Create a new PHI instruction in the specified block.
277
  /// Reserve space for the operands but do not fill them in yet.
278
  static Value *CreateEmptyPHI(BasicBlock *BB, unsigned NumPreds,
279
162k
                               SSAUpdater *Updater) {
280
162k
    PHINode *PHI = PHINode::Create(Updater->ProtoType, NumPreds,
281
162k
                                   Updater->ProtoName, &BB->front());
282
162k
    return PHI;
283
162k
  }
284
285
  /// AddPHIOperand - Add the specified value as an operand of the PHI for
286
  /// the specified predecessor block.
287
358k
  static void AddPHIOperand(PHINode *PHI, Value *Val, BasicBlock *Pred) {
288
358k
    PHI->addIncoming(Val, Pred);
289
358k
  }
290
291
  /// InstrIsPHI - Check if an instruction is a PHI.
292
  ///
293
0
  static PHINode *InstrIsPHI(Instruction *I) {
294
0
    return dyn_cast<PHINode>(I);
295
0
  }
296
297
  /// ValueIsPHI - Check if a value is a PHI.
298
234k
  static PHINode *ValueIsPHI(Value *Val, SSAUpdater *Updater) {
299
234k
    return dyn_cast<PHINode>(Val);
300
234k
  }
301
302
  /// ValueIsNewPHI - Like ValueIsPHI but also check if the PHI has no source
303
  /// operands, i.e., it was just added.
304
174k
  static PHINode *ValueIsNewPHI(Value *Val, SSAUpdater *Updater) {
305
174k
    PHINode *PHI = ValueIsPHI(Val, Updater);
306
174k
    if (PHI && PHI->getNumIncomingValues() == 0)
307
162k
      return PHI;
308
12.3k
    return nullptr;
309
12.3k
  }
310
311
  /// GetPHIValue - For the specified PHI instruction, return the value
312
  /// that it defines.
313
52.0k
  static Value *GetPHIValue(PHINode *PHI) {
314
52.0k
    return PHI;
315
52.0k
  }
316
};
317
318
} // end namespace llvm
319
320
/// Check to see if AvailableVals has an entry for the specified BB and if so,
321
/// return it.  If not, construct SSA form by first calculating the required
322
/// placement of PHIs and then inserting new PHIs where needed.
323
560k
Value *SSAUpdater::GetValueAtEndOfBlockInternal(BasicBlock *BB) {
324
560k
  AvailableValsTy &AvailableVals = getAvailableVals(AV);
325
560k
  if (Value *V = AvailableVals[BB])
326
305k
    return V;
327
255k
328
255k
  SSAUpdaterImpl<SSAUpdater> Impl(this, &AvailableVals, InsertedPHIs);
329
255k
  return Impl.GetValue(BB);
330
255k
}
331
332
//===----------------------------------------------------------------------===//
333
// LoadAndStorePromoter Implementation
334
//===----------------------------------------------------------------------===//
335
336
LoadAndStorePromoter::
337
LoadAndStorePromoter(ArrayRef<const Instruction *> Insts,
338
2.51k
                     SSAUpdater &S, StringRef BaseName) : SSA(S) {
339
2.51k
  if (Insts.empty()) 
return0
;
340
2.51k
341
2.51k
  const Value *SomeVal;
342
2.51k
  if (const LoadInst *LI = dyn_cast<LoadInst>(Insts[0]))
343
572
    SomeVal = LI;
344
1.94k
  else
345
1.94k
    SomeVal = cast<StoreInst>(Insts[0])->getOperand(0);
346
2.51k
347
2.51k
  if (BaseName.empty())
348
2.51k
    BaseName = SomeVal->getName();
349
2.51k
  SSA.Initialize(SomeVal->getType(), BaseName);
350
2.51k
}
351
352
2.51k
void LoadAndStorePromoter::run(const SmallVectorImpl<Instruction *> &Insts) {
353
2.51k
  // First step: bucket up uses of the alloca by the block they occur in.
354
2.51k
  // This is important because we have to handle multiple defs/uses in a block
355
2.51k
  // ourselves: SSAUpdater is purely for cross-block references.
356
2.51k
  DenseMap<BasicBlock *, TinyPtrVector<Instruction *>> UsesByBlock;
357
2.51k
358
2.51k
  for (Instruction *User : Insts)
359
4.86k
    UsesByBlock[User->getParent()].push_back(User);
360
2.51k
361
2.51k
  // Okay, now we can iterate over all the blocks in the function with uses,
362
2.51k
  // processing them.  Keep track of which loads are loading a live-in value.
363
2.51k
  // Walk the uses in the use-list order to be determinstic.
364
2.51k
  SmallVector<LoadInst *, 32> LiveInLoads;
365
2.51k
  DenseMap<Value *, Value *> ReplacedLoads;
366
2.51k
367
4.86k
  for (Instruction *User : Insts) {
368
4.86k
    BasicBlock *BB = User->getParent();
369
4.86k
    TinyPtrVector<Instruction *> &BlockUses = UsesByBlock[BB];
370
4.86k
371
4.86k
    // If this block has already been processed, ignore this repeat use.
372
4.86k
    if (BlockUses.empty()) 
continue1.88k
;
373
2.98k
374
2.98k
    // Okay, this is the first use in the block.  If this block just has a
375
2.98k
    // single user in it, we can rewrite it trivially.
376
2.98k
    if (BlockUses.size() == 1) {
377
1.34k
      // If it is a store, it is a trivial def of the value in the block.
378
1.34k
      if (StoreInst *SI = dyn_cast<StoreInst>(User)) {
379
1.09k
        updateDebugInfo(SI);
380
1.09k
        SSA.AddAvailableValue(BB, SI->getOperand(0));
381
1.09k
      } else
382
245
        // Otherwise it is a load, queue it to rewrite as a live-in load.
383
245
        LiveInLoads.push_back(cast<LoadInst>(User));
384
1.34k
      BlockUses.clear();
385
1.34k
      continue;
386
1.34k
    }
387
1.64k
388
1.64k
    // Otherwise, check to see if this block is all loads.
389
1.64k
    bool HasStore = false;
390
2.18k
    for (Instruction *I : BlockUses) {
391
2.18k
      if (isa<StoreInst>(I)) {
392
1.62k
        HasStore = true;
393
1.62k
        break;
394
1.62k
      }
395
2.18k
    }
396
1.64k
397
1.64k
    // If so, we can queue them all as live in loads.  We don't have an
398
1.64k
    // efficient way to tell which on is first in the block and don't want to
399
1.64k
    // scan large blocks, so just add all loads as live ins.
400
1.64k
    if (!HasStore) {
401
19
      for (Instruction *I : BlockUses)
402
38
        LiveInLoads.push_back(cast<LoadInst>(I));
403
19
      BlockUses.clear();
404
19
      continue;
405
19
    }
406
1.62k
407
1.62k
    // Otherwise, we have mixed loads and stores (or just a bunch of stores).
408
1.62k
    // Since SSAUpdater is purely for cross-block values, we need to determine
409
1.62k
    // the order of these instructions in the block.  If the first use in the
410
1.62k
    // block is a load, then it uses the live in value.  The last store defines
411
1.62k
    // the live out value.  We handle this by doing a linear scan of the block.
412
1.62k
    Value *StoredValue = nullptr;
413
59.3k
    for (Instruction &I : *BB) {
414
59.3k
      if (LoadInst *L = dyn_cast<LoadInst>(&I)) {
415
12.0k
        // If this is a load from an unrelated pointer, ignore it.
416
12.0k
        if (!isInstInList(L, Insts)) 
continue10.4k
;
417
1.62k
418
1.62k
        // If we haven't seen a store yet, this is a live in use, otherwise
419
1.62k
        // use the stored value.
420
1.62k
        if (StoredValue) {
421
379
          replaceLoadWithValue(L, StoredValue);
422
379
          L->replaceAllUsesWith(StoredValue);
423
379
          ReplacedLoads[L] = StoredValue;
424
1.24k
        } else {
425
1.24k
          LiveInLoads.push_back(L);
426
1.24k
        }
427
1.62k
        continue;
428
1.62k
      }
429
47.3k
430
47.3k
      if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
431
6.30k
        // If this is a store to an unrelated pointer, ignore it.
432
6.30k
        if (!isInstInList(SI, Insts)) 
continue4.44k
;
433
1.86k
        updateDebugInfo(SI);
434
1.86k
435
1.86k
        // Remember that this is the active value in the block.
436
1.86k
        StoredValue = SI->getOperand(0);
437
1.86k
      }
438
47.3k
    }
439
1.62k
440
1.62k
    // The last stored value that happened is the live-out for the block.
441
1.62k
    assert(StoredValue && "Already checked that there is a store in block");
442
1.62k
    SSA.AddAvailableValue(BB, StoredValue);
443
1.62k
    BlockUses.clear();
444
1.62k
  }
445
2.51k
446
2.51k
  // Okay, now we rewrite all loads that use live-in values in the loop,
447
2.51k
  // inserting PHI nodes as necessary.
448
2.51k
  for (LoadInst *ALoad : LiveInLoads) {
449
1.52k
    Value *NewVal = SSA.GetValueInMiddleOfBlock(ALoad->getParent());
450
1.52k
    replaceLoadWithValue(ALoad, NewVal);
451
1.52k
452
1.52k
    // Avoid assertions in unreachable code.
453
1.52k
    if (NewVal == ALoad) 
NewVal = UndefValue::get(NewVal->getType())0
;
454
1.52k
    ALoad->replaceAllUsesWith(NewVal);
455
1.52k
    ReplacedLoads[ALoad] = NewVal;
456
1.52k
  }
457
2.51k
458
2.51k
  // Allow the client to do stuff before we start nuking things.
459
2.51k
  doExtraRewritesBeforeFinalDeletion();
460
2.51k
461
2.51k
  // Now that everything is rewritten, delete the old instructions from the
462
2.51k
  // function.  They should all be dead now.
463
4.86k
  for (Instruction *User : Insts) {
464
4.86k
    // If this is a load that still has uses, then the load must have been added
465
4.86k
    // as a live value in the SSAUpdate data structure for a block (e.g. because
466
4.86k
    // the loaded value was stored later).  In this case, we need to recursively
467
4.86k
    // propagate the updates until we get to the real value.
468
4.86k
    if (!User->use_empty()) {
469
4
      Value *NewVal = ReplacedLoads[User];
470
4
      assert(NewVal && "not a replaced load?");
471
4
472
4
      // Propagate down to the ultimate replacee.  The intermediately loads
473
4
      // could theoretically already have been deleted, so we don't want to
474
4
      // dereference the Value*'s.
475
4
      DenseMap<Value*, Value*>::iterator RLI = ReplacedLoads.find(NewVal);
476
4
      while (RLI != ReplacedLoads.end()) {
477
0
        NewVal = RLI->second;
478
0
        RLI = ReplacedLoads.find(NewVal);
479
0
      }
480
4
481
4
      replaceLoadWithValue(cast<LoadInst>(User), NewVal);
482
4
      User->replaceAllUsesWith(NewVal);
483
4
    }
484
4.86k
485
4.86k
    instructionDeleted(User);
486
4.86k
    User->eraseFromParent();
487
4.86k
  }
488
2.51k
}
489
490
bool
491
LoadAndStorePromoter::isInstInList(Instruction *I,
492
                                   const SmallVectorImpl<Instruction *> &Insts)
493
136
                                   const {
494
136
  return is_contained(Insts, I);
495
136
}