Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
SSAUpdater.cpp
Go to the documentation of this file.
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/DebugInfo.h"
23#include "llvm/IR/DebugLoc.h"
24#include "llvm/IR/Instruction.h"
25#include "llvm/IR/Instructions.h"
26#include "llvm/IR/Use.h"
27#include "llvm/IR/Value.h"
28#include "llvm/Support/Casting.h"
29#include "llvm/Support/Debug.h"
30#include "llvm/Support/raw_ostream.h"
31#include "llvm/Transforms/Utils/SSAUpdaterImpl.h"
32#include <cassert>
33#include <utility>
34
35using namespacellvm;
36
37#define DEBUG_TYPE "ssaupdater"
38
39usingAvailableValsTy =DenseMap<BasicBlock *, Value *>;
40
41staticAvailableValsTy &getAvailableVals(void *AV) {
42return *static_cast<AvailableValsTy*>(AV);
43}
44
45SSAUpdater::SSAUpdater(SmallVectorImpl<PHINode *> *NewPHI)
46 : InsertedPHIs(NewPHI) {}
47
48SSAUpdater::~SSAUpdater() {
49deletestatic_cast<AvailableValsTy*>(AV);
50}
51
52voidSSAUpdater::Initialize(Type *Ty,StringRefName) {
53if (!AV)
54 AV =newAvailableValsTy();
55else
56getAvailableVals(AV).clear();
57 ProtoType = Ty;
58 ProtoName = std::string(Name);
59}
60
61boolSSAUpdater::HasValueForBlock(BasicBlock *BB) const{
62returngetAvailableVals(AV).count(BB);
63}
64
65Value *SSAUpdater::FindValueForBlock(BasicBlock *BB) const{
66returngetAvailableVals(AV).lookup(BB);
67}
68
69voidSSAUpdater::AddAvailableValue(BasicBlock *BB,Value *V) {
70assert(ProtoType &&"Need to initialize SSAUpdater");
71assert(ProtoType == V->getType() &&
72"All rewritten values must have the same type");
73getAvailableVals(AV)[BB] = V;
74}
75
76staticboolIsEquivalentPHI(PHINode *PHI,
77SmallDenseMap<BasicBlock *, Value *, 8> &ValueMapping) {
78unsigned PHINumValues =PHI->getNumIncomingValues();
79if (PHINumValues != ValueMapping.size())
80returnfalse;
81
82// Scan the phi to see if it matches.
83for (unsigned i = 0, e = PHINumValues; i != e; ++i)
84if (ValueMapping[PHI->getIncomingBlock(i)] !=
85PHI->getIncomingValue(i)) {
86returnfalse;
87 }
88
89returntrue;
90}
91
92Value *SSAUpdater::GetValueAtEndOfBlock(BasicBlock *BB) {
93Value *Res = GetValueAtEndOfBlockInternal(BB);
94return Res;
95}
96
97Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {
98// If there is no definition of the renamed variable in this block, just use
99// GetValueAtEndOfBlock to do our work.
100if (!HasValueForBlock(BB))
101returnGetValueAtEndOfBlock(BB);
102
103// Otherwise, we have the hard case. Get the live-in values for each
104// predecessor.
105SmallVector<std::pair<BasicBlock *, Value *>, 8> PredValues;
106Value *SingularValue =nullptr;
107
108// We can get our predecessor info by walking the pred_iterator list, but it
109// is relatively slow. If we already have PHI nodes in this block, walk one
110// of them to get the predecessor list instead.
111if (PHINode *SomePhi = dyn_cast<PHINode>(BB->begin())) {
112for (unsigned i = 0, e = SomePhi->getNumIncomingValues(); i != e; ++i) {
113BasicBlock *PredBB = SomePhi->getIncomingBlock(i);
114Value *PredVal =GetValueAtEndOfBlock(PredBB);
115 PredValues.push_back(std::make_pair(PredBB, PredVal));
116
117// Compute SingularValue.
118if (i == 0)
119 SingularValue = PredVal;
120elseif (PredVal != SingularValue)
121 SingularValue =nullptr;
122 }
123 }else {
124bool isFirstPred =true;
125for (BasicBlock *PredBB :predecessors(BB)) {
126Value *PredVal =GetValueAtEndOfBlock(PredBB);
127 PredValues.push_back(std::make_pair(PredBB, PredVal));
128
129// Compute SingularValue.
130if (isFirstPred) {
131 SingularValue = PredVal;
132 isFirstPred =false;
133 }elseif (PredVal != SingularValue)
134 SingularValue =nullptr;
135 }
136 }
137
138// If there are no predecessors, just return poison.
139if (PredValues.empty())
140returnPoisonValue::get(ProtoType);
141
142// Otherwise, if all the merged values are the same, just use it.
143if (SingularValue)
144return SingularValue;
145
146// Otherwise, we do need a PHI: check to see if we already have one available
147// in this block that produces the right value.
148if (isa<PHINode>(BB->begin())) {
149SmallDenseMap<BasicBlock *, Value *, 8> ValueMapping(PredValues.begin(),
150 PredValues.end());
151for (PHINode &SomePHI : BB->phis()) {
152if (IsEquivalentPHI(&SomePHI, ValueMapping))
153return &SomePHI;
154 }
155 }
156
157// Ok, we have no way out, insert a new one now.
158PHINode *InsertedPHI =
159PHINode::Create(ProtoType, PredValues.size(), ProtoName);
160 InsertedPHI->insertBefore(BB->begin());
161
162// Fill in all the predecessors of the PHI.
163for (constauto &PredValue : PredValues)
164 InsertedPHI->addIncoming(PredValue.second, PredValue.first);
165
166// See if the PHI node can be merged to a single value. This can happen in
167// loop cases when we get a PHI of itself and one other value.
168if (Value *V =
169simplifyInstruction(InsertedPHI, BB->getDataLayout())) {
170 InsertedPHI->eraseFromParent();
171return V;
172 }
173
174// Set the DebugLoc of the inserted PHI, if available.
175DebugLocDL;
176if (BasicBlock::iterator It = BB->getFirstNonPHIIt(); It != BB->end())
177DL = It->getDebugLoc();
178 InsertedPHI->setDebugLoc(DL);
179
180// If the client wants to know about all new instructions, tell it.
181if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI);
182
183LLVM_DEBUG(dbgs() <<" Inserted PHI: " << *InsertedPHI <<"\n");
184return InsertedPHI;
185}
186
187voidSSAUpdater::RewriteUse(Use &U) {
188Instruction *User = cast<Instruction>(U.getUser());
189
190Value *V;
191if (PHINode *UserPN = dyn_cast<PHINode>(User))
192 V =GetValueAtEndOfBlock(UserPN->getIncomingBlock(U));
193else
194 V =GetValueInMiddleOfBlock(User->getParent());
195
196 U.set(V);
197}
198
199voidSSAUpdater::UpdateDebugValues(Instruction *I) {
200SmallVector<DbgValueInst *, 4> DbgValues;
201SmallVector<DbgVariableRecord *, 4> DbgVariableRecords;
202llvm::findDbgValues(DbgValues,I, &DbgVariableRecords);
203for (auto &DbgValue : DbgValues) {
204if (DbgValue->getParent() ==I->getParent())
205continue;
206 UpdateDebugValue(I,DbgValue);
207 }
208for (auto &DVR : DbgVariableRecords) {
209if (DVR->getParent() ==I->getParent())
210continue;
211 UpdateDebugValue(I, DVR);
212 }
213}
214
215voidSSAUpdater::UpdateDebugValues(Instruction *I,
216SmallVectorImpl<DbgValueInst *> &DbgValues) {
217for (auto &DbgValue : DbgValues) {
218 UpdateDebugValue(I,DbgValue);
219 }
220}
221
222voidSSAUpdater::UpdateDebugValues(
223Instruction *I,SmallVectorImpl<DbgVariableRecord *> &DbgVariableRecords) {
224for (auto &DVR : DbgVariableRecords) {
225 UpdateDebugValue(I, DVR);
226 }
227}
228
229void SSAUpdater::UpdateDebugValue(Instruction *I,DbgValueInst *DbgValue) {
230BasicBlock *UserBB =DbgValue->getParent();
231if (HasValueForBlock(UserBB)) {
232Value *NewVal =GetValueAtEndOfBlock(UserBB);
233DbgValue->replaceVariableLocationOp(I, NewVal);
234 }else
235DbgValue->setKillLocation();
236}
237
238void SSAUpdater::UpdateDebugValue(Instruction *I,DbgVariableRecord *DVR) {
239BasicBlock *UserBB = DVR->getParent();
240if (HasValueForBlock(UserBB)) {
241Value *NewVal =GetValueAtEndOfBlock(UserBB);
242 DVR->replaceVariableLocationOp(I, NewVal);
243 }else
244 DVR->setKillLocation();
245}
246
247voidSSAUpdater::RewriteUseAfterInsertions(Use &U) {
248Instruction *User = cast<Instruction>(U.getUser());
249
250Value *V;
251if (PHINode *UserPN = dyn_cast<PHINode>(User))
252 V =GetValueAtEndOfBlock(UserPN->getIncomingBlock(U));
253else
254 V =GetValueAtEndOfBlock(User->getParent());
255
256 U.set(V);
257}
258
259namespacellvm {
260
261template<>
262classSSAUpdaterTraits<SSAUpdater> {
263public:
264usingBlkT =BasicBlock;
265usingValT =Value *;
266usingPhiT =PHINode;
267usingBlkSucc_iterator =succ_iterator;
268
269staticBlkSucc_iteratorBlkSucc_begin(BlkT *BB) {returnsucc_begin(BB); }
270staticBlkSucc_iteratorBlkSucc_end(BlkT *BB) {returnsucc_end(BB); }
271
272classPHI_iterator {
273private:
274PHINode *PHI;
275unsigned idx;
276
277public:
278explicitPHI_iterator(PHINode *P)// begin iterator
279 :PHI(P), idx(0) {}
280PHI_iterator(PHINode *P,bool)// end iterator
281 :PHI(P), idx(PHI->getNumIncomingValues()) {}
282
283 PHI_iterator &operator++() { ++idx;return *this; }
284booloperator==(const PHI_iterator& x) const{return idx == x.idx; }
285booloperator!=(const PHI_iterator& x) const{return !operator==(x); }
286
287Value *getIncomingValue() {returnPHI->getIncomingValue(idx); }
288BasicBlock *getIncomingBlock() {returnPHI->getIncomingBlock(idx); }
289 };
290
291static PHI_iteratorPHI_begin(PhiT *PHI) {return PHI_iterator(PHI); }
292static PHI_iteratorPHI_end(PhiT *PHI) {
293return PHI_iterator(PHI,true);
294 }
295
296 /// FindPredecessorBlocks - Put the predecessors of Info->BB into the Preds
297 /// vector, set Info->NumPreds, and allocate space in Info->Preds.
298staticvoidFindPredecessorBlocks(BasicBlock *BB,
299SmallVectorImpl<BasicBlock *> *Preds) {
300// We can get our predecessor info by walking the pred_iterator list,
301// but it is relatively slow. If we already have PHI nodes in this
302// block, walk one of them to get the predecessor list instead.
303if (PHINode *SomePhi = dyn_cast<PHINode>(BB->begin()))
304append_range(*Preds, SomePhi->blocks());
305else
306append_range(*Preds,predecessors(BB));
307 }
308
309 /// GetPoisonVal - Get a poison value of the same type as the value
310 /// being handled.
311staticValue *GetPoisonVal(BasicBlock *BB,SSAUpdater *Updater) {
312returnPoisonValue::get(Updater->ProtoType);
313 }
314
315 /// CreateEmptyPHI - Create a new PHI instruction in the specified block.
316 /// Reserve space for the operands but do not fill them in yet.
317staticValue *CreateEmptyPHI(BasicBlock *BB,unsigned NumPreds,
318SSAUpdater *Updater) {
319PHINode *PHI =
320PHINode::Create(Updater->ProtoType, NumPreds, Updater->ProtoName);
321PHI->insertBefore(BB->begin());
322returnPHI;
323 }
324
325 /// AddPHIOperand - Add the specified value as an operand of the PHI for
326 /// the specified predecessor block.
327staticvoidAddPHIOperand(PHINode *PHI,Value *Val,BasicBlock *Pred) {
328PHI->addIncoming(Val, Pred);
329 }
330
331 /// ValueIsPHI - Check if a value is a PHI.
332staticPHINode *ValueIsPHI(Value *Val,SSAUpdater *Updater) {
333return dyn_cast<PHINode>(Val);
334 }
335
336 /// ValueIsNewPHI - Like ValueIsPHI but also check if the PHI has no source
337 /// operands, i.e., it was just added.
338staticPHINode *ValueIsNewPHI(Value *Val,SSAUpdater *Updater) {
339PHINode *PHI = ValueIsPHI(Val, Updater);
340if (PHI &&PHI->getNumIncomingValues() == 0)
341returnPHI;
342returnnullptr;
343 }
344
345 /// GetPHIValue - For the specified PHI instruction, return the value
346 /// that it defines.
347staticValue *GetPHIValue(PHINode *PHI) {
348returnPHI;
349 }
350};
351
352}// end namespace llvm
353
354/// Check to see if AvailableVals has an entry for the specified BB and if so,
355/// return it. If not, construct SSA form by first calculating the required
356/// placement of PHIs and then inserting new PHIs where needed.
357Value *SSAUpdater::GetValueAtEndOfBlockInternal(BasicBlock *BB) {
358AvailableValsTy &AvailableVals =getAvailableVals(AV);
359if (Value *V = AvailableVals[BB])
360returnV;
361
362SSAUpdaterImpl<SSAUpdater> Impl(this, &AvailableVals, InsertedPHIs);
363return Impl.GetValue(BB);
364}
365
366//===----------------------------------------------------------------------===//
367// LoadAndStorePromoter Implementation
368//===----------------------------------------------------------------------===//
369
370LoadAndStorePromoter::
371LoadAndStorePromoter(ArrayRef<const Instruction *> Insts,
372SSAUpdater &S,StringRef BaseName) :SSA(S) {
373if (Insts.empty())return;
374
375constValue *SomeVal;
376if (constLoadInst *LI = dyn_cast<LoadInst>(Insts[0]))
377 SomeVal = LI;
378else
379 SomeVal = cast<StoreInst>(Insts[0])->getOperand(0);
380
381if (BaseName.empty())
382 BaseName = SomeVal->getName();
383SSA.Initialize(SomeVal->getType(), BaseName);
384}
385
386voidLoadAndStorePromoter::run(constSmallVectorImpl<Instruction *> &Insts) {
387// First step: bucket up uses of the alloca by the block they occur in.
388// This is important because we have to handle multiple defs/uses in a block
389// ourselves: SSAUpdater is purely for cross-block references.
390DenseMap<BasicBlock *, TinyPtrVector<Instruction *>> UsesByBlock;
391
392for (Instruction *User : Insts)
393 UsesByBlock[User->getParent()].push_back(User);
394
395// Okay, now we can iterate over all the blocks in the function with uses,
396// processing them. Keep track of which loads are loading a live-in value.
397// Walk the uses in the use-list order to be determinstic.
398SmallVector<LoadInst *, 32> LiveInLoads;
399DenseMap<Value *, Value *> ReplacedLoads;
400
401for (Instruction *User : Insts) {
402BasicBlock *BB =User->getParent();
403TinyPtrVector<Instruction *> &BlockUses = UsesByBlock[BB];
404
405// If this block has already been processed, ignore this repeat use.
406if (BlockUses.empty())continue;
407
408// Okay, this is the first use in the block. If this block just has a
409// single user in it, we can rewrite it trivially.
410if (BlockUses.size() == 1) {
411// If it is a store, it is a trivial def of the value in the block.
412if (StoreInst *SI = dyn_cast<StoreInst>(User)) {
413updateDebugInfo(SI);
414SSA.AddAvailableValue(BB, SI->getOperand(0));
415 }elseif (auto *AI = dyn_cast<AllocaInst>(User)) {
416// We treat AllocaInst as a store of an getValueToUseForAlloca value.
417SSA.AddAvailableValue(BB,getValueToUseForAlloca(AI));
418 }else {
419// Otherwise it is a load, queue it to rewrite as a live-in load.
420 LiveInLoads.push_back(cast<LoadInst>(User));
421 }
422 BlockUses.clear();
423continue;
424 }
425
426// Otherwise, check to see if this block is all loads.
427bool HasStore =false;
428for (Instruction *I : BlockUses) {
429if (isa<StoreInst>(I) || isa<AllocaInst>(I)) {
430 HasStore =true;
431break;
432 }
433 }
434
435// If so, we can queue them all as live in loads.
436if (!HasStore) {
437for (Instruction *I : BlockUses)
438 LiveInLoads.push_back(cast<LoadInst>(I));
439 BlockUses.clear();
440continue;
441 }
442
443// Sort all of the interesting instructions in the block so that we don't
444// have to scan a large block just to find a few instructions.
445llvm::sort(
446 BlockUses.begin(), BlockUses.end(),
447 [](Instruction *A,Instruction *B) { return A->comesBefore(B); });
448
449// Otherwise, we have mixed loads and stores (or just a bunch of stores).
450// Since SSAUpdater is purely for cross-block values, we need to determine
451// the order of these instructions in the block. If the first use in the
452// block is a load, then it uses the live in value. The last store defines
453// the live out value.
454Value *StoredValue =nullptr;
455for (Instruction *I : BlockUses) {
456if (LoadInst *L = dyn_cast<LoadInst>(I)) {
457// If we haven't seen a store yet, this is a live in use, otherwise
458// use the stored value.
459if (StoredValue) {
460replaceLoadWithValue(L, StoredValue);
461 L->replaceAllUsesWith(StoredValue);
462 ReplacedLoads[L] = StoredValue;
463 }else {
464 LiveInLoads.push_back(L);
465 }
466continue;
467 }
468
469if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
470updateDebugInfo(SI);
471
472// Remember that this is the active value in the block.
473 StoredValue = SI->getOperand(0);
474 }elseif (auto *AI = dyn_cast<AllocaInst>(I)) {
475// Check if this an alloca, in which case we treat it as a store of
476// getValueToUseForAlloca.
477 StoredValue =getValueToUseForAlloca(AI);
478 }
479 }
480
481// The last stored value that happened is the live-out for the block.
482assert(StoredValue &&"Already checked that there is a store in block");
483SSA.AddAvailableValue(BB, StoredValue);
484 BlockUses.clear();
485 }
486
487// Okay, now we rewrite all loads that use live-in values in the loop,
488// inserting PHI nodes as necessary.
489for (LoadInst *ALoad : LiveInLoads) {
490Value *NewVal =SSA.GetValueInMiddleOfBlock(ALoad->getParent());
491replaceLoadWithValue(ALoad, NewVal);
492
493// Avoid assertions in unreachable code.
494if (NewVal == ALoad) NewVal =PoisonValue::get(NewVal->getType());
495 ALoad->replaceAllUsesWith(NewVal);
496 ReplacedLoads[ALoad] = NewVal;
497 }
498
499// Allow the client to do stuff before we start nuking things.
500doExtraRewritesBeforeFinalDeletion();
501
502// Now that everything is rewritten, delete the old instructions from the
503// function. They should all be dead now.
504for (Instruction *User : Insts) {
505if (!shouldDelete(User))
506continue;
507
508// If this is a load that still has uses, then the load must have been added
509// as a live value in the SSAUpdate data structure for a block (e.g. because
510// the loaded value was stored later). In this case, we need to recursively
511// propagate the updates until we get to the real value.
512if (!User->use_empty()) {
513Value *NewVal = ReplacedLoads[User];
514assert(NewVal &&"not a replaced load?");
515
516// Propagate down to the ultimate replacee. The intermediately loads
517// could theoretically already have been deleted, so we don't want to
518// dereference the Value*'s.
519DenseMap<Value*, Value*>::iterator RLI = ReplacedLoads.find(NewVal);
520while (RLI != ReplacedLoads.end()) {
521 NewVal = RLI->second;
522 RLI = ReplacedLoads.find(NewVal);
523 }
524
525replaceLoadWithValue(cast<LoadInst>(User), NewVal);
526User->replaceAllUsesWith(NewVal);
527 }
528
529instructionDeleted(User);
530User->eraseFromParent();
531 }
532}
PHI
Rewrite undef for PHI
Definition:AMDGPURewriteUndefForPHI.cpp:100
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Casting.h
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DebugLoc.h
Debug.h
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
DenseMap.h
This file defines the DenseMap class.
Name
std::string Name
Definition:ELFObjHandler.cpp:77
BasicBlock.h
CFG.h
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Instruction.h
Use.h
This defines the Use class.
Value.h
InstructionSimplify.h
Instructions.h
I
#define I(x, y, z)
Definition:MD5.cpp:58
getAvailableVals
static AvailableValsTy & getAvailableVals(void *AV)
Definition:MachineSSAUpdater.cpp:39
AvailableValsTy
DenseMap< MachineBasicBlock *, Register > AvailableValsTy
Definition:MachineSSAUpdater.cpp:37
SSA
Memory SSA
Definition:MemorySSA.cpp:72
P
#define P(N)
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SSAUpdaterImpl.h
getAvailableVals
static AvailableValsTy & getAvailableVals(void *AV)
Definition:SSAUpdater.cpp:41
IsEquivalentPHI
static bool IsEquivalentPHI(PHINode *PHI, SmallDenseMap< BasicBlock *, Value *, 8 > &ValueMapping)
Definition:SSAUpdater.cpp:76
SSAUpdater.h
STLExtras.h
This file contains some templates that are useful if you are working with the STL at all.
SmallVector.h
This file defines the SmallVector class.
TinyPtrVector.h
LiveDebugValues::DbgValue
Class recording the (high level) value of a variable.
Definition:InstrRefBasedImpl.h:512
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition:ArrayRef.h:163
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BasicBlock::end
iterator end()
Definition:BasicBlock.h:464
llvm::BasicBlock::begin
iterator begin()
Instruction iterator methods.
Definition:BasicBlock.h:451
llvm::BasicBlock::phis
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
Definition:BasicBlock.h:520
llvm::BasicBlock::getFirstNonPHIIt
InstListType::const_iterator getFirstNonPHIIt() const
Iterator returning form of getFirstNonPHI.
Definition:BasicBlock.cpp:374
llvm::BasicBlock::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
Definition:BasicBlock.cpp:296
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition:BasicBlock.h:177
llvm::DbgRecord::getParent
const BasicBlock * getParent() const
Definition:DebugProgramInstruction.cpp:507
llvm::DbgValueInst
This represents the llvm.dbg.value instruction.
Definition:IntrinsicInst.h:468
llvm::DbgVariableRecord
Record of a variable value-assignment, aka a non instruction representation of the dbg....
Definition:DebugProgramInstruction.h:270
llvm::DbgVariableRecord::setKillLocation
void setKillLocation()
Definition:DebugProgramInstruction.cpp:356
llvm::DbgVariableRecord::replaceVariableLocationOp
void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
Definition:DebugProgramInstruction.cpp:286
llvm::DebugLoc
A debug info location.
Definition:DebugLoc.h:33
llvm::DenseMapBase::lookup
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition:DenseMap.h:194
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition:DenseMap.h:156
llvm::DenseMapBase::size
unsigned size() const
Definition:DenseMap.h:99
llvm::DenseMapBase::count
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition:DenseMap.h:152
llvm::DenseMapBase::end
iterator end()
Definition:DenseMap.h:84
llvm::DenseMapBase::clear
void clear()
Definition:DenseMap.h:110
llvm::DenseMapIterator
Definition:DenseMap.h:1189
llvm::DenseMap
Definition:DenseMap.h:727
llvm::Instruction
Definition:Instruction.h:68
llvm::Instruction::insertBefore
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
Definition:Instruction.cpp:99
llvm::Instruction::eraseFromParent
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Definition:Instruction.cpp:94
llvm::Instruction::setDebugLoc
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition:Instruction.h:489
llvm::LoadAndStorePromoter::getValueToUseForAlloca
virtual Value * getValueToUseForAlloca(Instruction *AI) const
Return the value to use for the point in the code that the alloca is positioned.
Definition:SSAUpdater.h:188
llvm::LoadAndStorePromoter::instructionDeleted
virtual void instructionDeleted(Instruction *I) const
Called before each instruction is deleted.
Definition:SSAUpdater.h:176
llvm::LoadAndStorePromoter::doExtraRewritesBeforeFinalDeletion
virtual void doExtraRewritesBeforeFinalDeletion()
This hook is invoked after all the stores are found and inserted as available values.
Definition:SSAUpdater.h:169
llvm::LoadAndStorePromoter::LoadAndStorePromoter
LoadAndStorePromoter(ArrayRef< const Instruction * > Insts, SSAUpdater &S, StringRef Name=StringRef())
Definition:SSAUpdater.cpp:371
llvm::LoadAndStorePromoter::replaceLoadWithValue
virtual void replaceLoadWithValue(LoadInst *LI, Value *V) const
Clients can choose to implement this to get notified right before a load is RAUW'd another value.
Definition:SSAUpdater.h:173
llvm::LoadAndStorePromoter::run
void run(const SmallVectorImpl< Instruction * > &Insts)
This does the promotion.
Definition:SSAUpdater.cpp:386
llvm::LoadAndStorePromoter::SSA
SSAUpdater & SSA
Definition:SSAUpdater.h:153
llvm::LoadAndStorePromoter::updateDebugInfo
virtual void updateDebugInfo(Instruction *I) const
Called to update debug info associated with the instruction.
Definition:SSAUpdater.h:179
llvm::LoadAndStorePromoter::shouldDelete
virtual bool shouldDelete(Instruction *I) const
Return false if a sub-class wants to keep one of the loads/stores after the SSA construction.
Definition:SSAUpdater.h:183
llvm::LoadInst
An instruction for reading from memory.
Definition:Instructions.h:176
llvm::PHINode
Definition:Instructions.h:2600
llvm::PHINode::addIncoming
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
Definition:Instructions.h:2735
llvm::PHINode::Create
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Definition:Instructions.h:2635
llvm::PoisonValue::get
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition:Constants.cpp:1878
llvm::SSAUpdaterImpl
Definition:SSAUpdaterImpl.h:31
llvm::SSAUpdaterTraits< SSAUpdater >::PHI_iterator::getIncomingValue
Value * getIncomingValue()
Definition:SSAUpdater.cpp:287
llvm::SSAUpdaterTraits< SSAUpdater >::PHI_iterator::getIncomingBlock
BasicBlock * getIncomingBlock()
Definition:SSAUpdater.cpp:288
llvm::SSAUpdaterTraits< SSAUpdater >::PHI_iterator::PHI_iterator
PHI_iterator(PHINode *P)
Definition:SSAUpdater.cpp:278
llvm::SSAUpdaterTraits< SSAUpdater >::PHI_iterator::PHI_iterator
PHI_iterator(PHINode *P, bool)
Definition:SSAUpdater.cpp:280
llvm::SSAUpdaterTraits< SSAUpdater >::PHI_iterator::operator++
PHI_iterator & operator++()
Definition:SSAUpdater.cpp:283
llvm::SSAUpdaterTraits< SSAUpdater >::PHI_iterator::operator!=
bool operator!=(const PHI_iterator &x) const
Definition:SSAUpdater.cpp:285
llvm::SSAUpdaterTraits< SSAUpdater >::PHI_iterator::operator==
bool operator==(const PHI_iterator &x) const
Definition:SSAUpdater.cpp:284
llvm::SSAUpdaterTraits< SSAUpdater >::BlkSucc_end
static BlkSucc_iterator BlkSucc_end(BlkT *BB)
Definition:SSAUpdater.cpp:270
llvm::SSAUpdaterTraits< SSAUpdater >::BlkSucc_begin
static BlkSucc_iterator BlkSucc_begin(BlkT *BB)
Definition:SSAUpdater.cpp:269
llvm::SSAUpdaterTraits< SSAUpdater >::FindPredecessorBlocks
static void FindPredecessorBlocks(BasicBlock *BB, SmallVectorImpl< BasicBlock * > *Preds)
FindPredecessorBlocks - Put the predecessors of Info->BB into the Preds vector, set Info->NumPreds,...
Definition:SSAUpdater.cpp:298
llvm::SSAUpdaterTraits< SSAUpdater >::CreateEmptyPHI
static Value * CreateEmptyPHI(BasicBlock *BB, unsigned NumPreds, SSAUpdater *Updater)
CreateEmptyPHI - Create a new PHI instruction in the specified block.
Definition:SSAUpdater.cpp:317
llvm::SSAUpdaterTraits< SSAUpdater >::ValueIsNewPHI
static PHINode * ValueIsNewPHI(Value *Val, SSAUpdater *Updater)
ValueIsNewPHI - Like ValueIsPHI but also check if the PHI has no source operands, i....
Definition:SSAUpdater.cpp:338
llvm::SSAUpdaterTraits< SSAUpdater >::PHI_begin
static PHI_iterator PHI_begin(PhiT *PHI)
Definition:SSAUpdater.cpp:291
llvm::SSAUpdaterTraits< SSAUpdater >::AddPHIOperand
static void AddPHIOperand(PHINode *PHI, Value *Val, BasicBlock *Pred)
AddPHIOperand - Add the specified value as an operand of the PHI for the specified predecessor block.
Definition:SSAUpdater.cpp:327
llvm::SSAUpdaterTraits< SSAUpdater >::GetPHIValue
static Value * GetPHIValue(PHINode *PHI)
GetPHIValue - For the specified PHI instruction, return the value that it defines.
Definition:SSAUpdater.cpp:347
llvm::SSAUpdaterTraits< SSAUpdater >::GetPoisonVal
static Value * GetPoisonVal(BasicBlock *BB, SSAUpdater *Updater)
GetPoisonVal - Get a poison value of the same type as the value being handled.
Definition:SSAUpdater.cpp:311
llvm::SSAUpdaterTraits< SSAUpdater >::PHI_end
static PHI_iterator PHI_end(PhiT *PHI)
Definition:SSAUpdater.cpp:292
llvm::SSAUpdaterTraits< SSAUpdater >::ValueIsPHI
static PHINode * ValueIsPHI(Value *Val, SSAUpdater *Updater)
ValueIsPHI - Check if a value is a PHI.
Definition:SSAUpdater.cpp:332
llvm::SSAUpdaterTraits
Definition:MachineSSAUpdater.h:29
llvm::SSAUpdater
Helper class for SSA formation on a set of values defined in multiple blocks.
Definition:SSAUpdater.h:40
llvm::SSAUpdater::RewriteUse
void RewriteUse(Use &U)
Rewrite a use of the symbolic value.
Definition:SSAUpdater.cpp:187
llvm::SSAUpdater::RewriteUseAfterInsertions
void RewriteUseAfterInsertions(Use &U)
Rewrite a use like RewriteUse but handling in-block definitions.
Definition:SSAUpdater.cpp:247
llvm::SSAUpdater::FindValueForBlock
Value * FindValueForBlock(BasicBlock *BB) const
Return the value for the specified block if the SSAUpdater has one, otherwise return nullptr.
Definition:SSAUpdater.cpp:65
llvm::SSAUpdater::Initialize
void Initialize(Type *Ty, StringRef Name)
Reset this object to get ready for a new set of SSA updates with type 'Ty'.
Definition:SSAUpdater.cpp:52
llvm::SSAUpdater::~SSAUpdater
~SSAUpdater()
Definition:SSAUpdater.cpp:48
llvm::SSAUpdater::GetValueInMiddleOfBlock
Value * GetValueInMiddleOfBlock(BasicBlock *BB)
Construct SSA form, materializing a value that is live in the middle of the specified block.
Definition:SSAUpdater.cpp:97
llvm::SSAUpdater::SSAUpdater
SSAUpdater(SmallVectorImpl< PHINode * > *InsertedPHIs=nullptr)
If InsertedPHIs is specified, it will be filled in with all PHI Nodes created by rewriting.
Definition:SSAUpdater.cpp:45
llvm::SSAUpdater::UpdateDebugValues
void UpdateDebugValues(Instruction *I)
Rewrite debug value intrinsics to conform to a new SSA form.
Definition:SSAUpdater.cpp:199
llvm::SSAUpdater::HasValueForBlock
bool HasValueForBlock(BasicBlock *BB) const
Return true if the SSAUpdater already has a value for the specified block.
Definition:SSAUpdater.cpp:61
llvm::SSAUpdater::GetValueAtEndOfBlock
Value * GetValueAtEndOfBlock(BasicBlock *BB)
Construct SSA form, materializing a value that is live at the end of the specified block.
Definition:SSAUpdater.cpp:92
llvm::SSAUpdater::AddAvailableValue
void AddAvailableValue(BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value.
Definition:SSAUpdater.cpp:69
llvm::SmallDenseMap
Definition:DenseMap.h:883
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorBase::size
size_t size() const
Definition:SmallVector.h:78
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVectorTemplateCommon::begin
iterator begin()
Definition:SmallVector.h:267
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StoreInst
An instruction for storing to memory.
Definition:Instructions.h:292
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition:StringRef.h:147
llvm::SuccIterator
Definition:CFG.h:141
llvm::TinyPtrVector
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
Definition:TinyPtrVector.h:29
llvm::TinyPtrVector::begin
iterator begin()
Definition:TinyPtrVector.h:184
llvm::TinyPtrVector::empty
bool empty() const
Definition:TinyPtrVector.h:162
llvm::TinyPtrVector::end
iterator end()
Definition:TinyPtrVector.h:191
llvm::TinyPtrVector::size
unsigned size() const
Definition:TinyPtrVector.h:171
llvm::TinyPtrVector::clear
void clear()
Definition:TinyPtrVector.h:269
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition:Use.h:43
llvm::User
Definition:User.h:44
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition:Value.h:255
llvm::Value::replaceAllUsesWith
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition:Value.cpp:534
llvm::Value::use_empty
bool use_empty() const
Definition:Value.h:344
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition:Value.cpp:309
DebugInfo.h
llvm::M68k::MemAddrModeKind::V
@ V
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Definition:STLExtras.h:2115
llvm::findDbgValues
void findDbgValues(SmallVectorImpl< DbgValueInst * > &DbgValues, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords=nullptr)
Finds the llvm.dbg.value intrinsics describing a value.
Definition:DebugInfo.cpp:155
llvm::operator==
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
Definition:AddressRanges.h:153
llvm::simplifyInstruction
Value * simplifyInstruction(Instruction *I, const SimplifyQuery &Q)
See if we can compute a simplified version of this instruction.
Definition:InstructionSimplify.cpp:7234
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition:STLExtras.h:1664
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::succ_iterator
SuccIterator< Instruction, BasicBlock > succ_iterator
Definition:CFG.h:242
llvm::succ_begin
RNSuccIterator< NodeRef, BlockT, RegionT > succ_begin(NodeRef Node)
Definition:RegionIterator.h:249
llvm::succ_end
RNSuccIterator< NodeRef, BlockT, RegionT > succ_end(NodeRef Node)
Definition:RegionIterator.h:254
llvm::predecessors
auto predecessors(const MachineBasicBlock *BB)
Definition:MachineBasicBlock.h:1377
raw_ostream.h

Generated on Thu Jul 17 2025 17:55:09 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp