LLVM  6.0.0svn
Local.h
Go to the documentation of this file.
1 //===-- Local.h - Functions to perform local transformations ----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This family of functions perform various local transformations to the
11 // program.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_TRANSFORMS_UTILS_LOCAL_H
16 #define LLVM_TRANSFORMS_UTILS_LOCAL_H
17 
18 #include "llvm/ADT/SmallPtrSet.h"
19 #include "llvm/ADT/TinyPtrVector.h"
21 #include "llvm/IR/DataLayout.h"
22 #include "llvm/IR/Dominators.h"
24 #include "llvm/IR/IRBuilder.h"
25 #include "llvm/IR/Operator.h"
26 
27 namespace llvm {
28 
29 class User;
30 class BasicBlock;
31 class Function;
32 class BranchInst;
33 class Instruction;
34 class CallInst;
35 class DbgDeclareInst;
36 class DbgInfoIntrinsic;
37 class DbgValueInst;
38 class StoreInst;
39 class LoadInst;
40 class Value;
41 class PHINode;
42 class AllocaInst;
43 class AssumptionCache;
44 class ConstantExpr;
45 class DataLayout;
46 class TargetLibraryInfo;
47 class TargetTransformInfo;
48 class DIBuilder;
49 class DominatorTree;
50 class LazyValueInfo;
51 
52 template<typename T> class SmallVectorImpl;
53 
54 //===----------------------------------------------------------------------===//
55 // Local constant propagation.
56 //
57 
58 /// If a terminator instruction is predicated on a constant value, convert it
59 /// into an unconditional branch to the constant destination.
60 /// This is a nontrivial operation because the successors of this basic block
61 /// must have their PHI nodes updated.
62 /// Also calls RecursivelyDeleteTriviallyDeadInstructions() on any branch/switch
63 /// conditions and indirectbr addresses this might make dead if
64 /// DeleteDeadConditions is true.
65 bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions = false,
66  const TargetLibraryInfo *TLI = nullptr);
67 
68 //===----------------------------------------------------------------------===//
69 // Local dead code elimination.
70 //
71 
72 /// Return true if the result produced by the instruction is not used, and the
73 /// instruction has no side effects.
74 bool isInstructionTriviallyDead(Instruction *I,
75  const TargetLibraryInfo *TLI = nullptr);
76 
77 /// Return true if the result produced by the instruction would have no side
78 /// effects if it was not used. This is equivalent to checking whether
79 /// isInstructionTriviallyDead would be true if the use count was 0.
80 bool wouldInstructionBeTriviallyDead(Instruction *I,
81  const TargetLibraryInfo *TLI = nullptr);
82 
83 /// If the specified value is a trivially dead instruction, delete it.
84 /// If that makes any of its operands trivially dead, delete them too,
85 /// recursively. Return true if any instructions were deleted.
87  const TargetLibraryInfo *TLI = nullptr);
88 
89 /// If the specified value is an effectively dead PHI node, due to being a
90 /// def-use chain of single-use nodes that either forms a cycle or is terminated
91 /// by a trivially dead instruction, delete it. If that makes any of its
92 /// operands trivially dead, delete them too, recursively. Return true if a
93 /// change was made.
94 bool RecursivelyDeleteDeadPHINode(PHINode *PN,
95  const TargetLibraryInfo *TLI = nullptr);
96 
97 /// Scan the specified basic block and try to simplify any instructions in it
98 /// and recursively delete dead instructions.
99 ///
100 /// This returns true if it changed the code, note that it can delete
101 /// instructions in other blocks as well in this block.
103  const TargetLibraryInfo *TLI = nullptr);
104 
105 //===----------------------------------------------------------------------===//
106 // Control Flow Graph Restructuring.
107 //
108 
109 /// Like BasicBlock::removePredecessor, this method is called when we're about
110 /// to delete Pred as a predecessor of BB. If BB contains any PHI nodes, this
111 /// drops the entries in the PHI nodes for Pred.
112 ///
113 /// Unlike the removePredecessor method, this attempts to simplify uses of PHI
114 /// nodes that collapse into identity values. For example, if we have:
115 /// x = phi(1, 0, 0, 0)
116 /// y = and x, z
117 ///
118 /// .. and delete the predecessor corresponding to the '1', this will attempt to
119 /// recursively fold the 'and' to 0.
121 
122 /// BB is a block with one predecessor and its predecessor is known to have one
123 /// successor (BB!). Eliminate the edge between them, moving the instructions in
124 /// the predecessor into BB. This deletes the predecessor block.
125 void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, DominatorTree *DT = nullptr);
126 
127 /// BB is known to contain an unconditional branch, and contains no instructions
128 /// other than PHI nodes, potential debug intrinsics and the branch. If
129 /// possible, eliminate BB by rewriting all the predecessors to branch to the
130 /// successor block and return true. If we can't transform, return false.
132 
133 /// Check for and eliminate duplicate PHI nodes in this block. This doesn't try
134 /// to be clever about PHI nodes which differ only in the order of the incoming
135 /// values, but instcombine orders them so it usually won't matter.
137 
138 /// This function is used to do simplification of a CFG. For
139 /// example, it adjusts branches to branches to eliminate the extra hop, it
140 /// eliminates unreachable basic blocks, and does other "peephole" optimization
141 /// of the CFG. It returns true if a modification was made, possibly deleting
142 /// the basic block that was pointed to. LoopHeaders is an optional input
143 /// parameter, providing the set of loop header that SimplifyCFG should not
144 /// eliminate.
145 bool SimplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
146  unsigned BonusInstThreshold, AssumptionCache *AC = nullptr,
147  SmallPtrSetImpl<BasicBlock *> *LoopHeaders = nullptr,
148  bool LateSimplifyCFG = false);
149 
150 /// This function is used to flatten a CFG. For example, it uses parallel-and
151 /// and parallel-or mode to collapse if-conditions and merge if-regions with
152 /// identical statements.
153 bool FlattenCFG(BasicBlock *BB, AliasAnalysis *AA = nullptr);
154 
155 /// If this basic block is ONLY a setcc and a branch, and if a predecessor
156 /// branches to us and one of our successors, fold the setcc into the
157 /// predecessor and use logical operations to pick the right destination.
158 bool FoldBranchToCommonDest(BranchInst *BI, unsigned BonusInstThreshold = 1);
159 
160 /// This function takes a virtual register computed by an Instruction and
161 /// replaces it with a slot in the stack frame, allocated via alloca.
162 /// This allows the CFG to be changed around without fear of invalidating the
163 /// SSA information for the value. It returns the pointer to the alloca inserted
164 /// to create a stack slot for X.
165 AllocaInst *DemoteRegToStack(Instruction &X,
166  bool VolatileLoads = false,
167  Instruction *AllocaPoint = nullptr);
168 
169 /// This function takes a virtual register computed by a phi node and replaces
170 /// it with a slot in the stack frame, allocated via alloca. The phi node is
171 /// deleted and it returns the pointer to the alloca inserted.
172 AllocaInst *DemotePHIToStack(PHINode *P, Instruction *AllocaPoint = nullptr);
173 
174 /// Try to ensure that the alignment of \p V is at least \p PrefAlign bytes. If
175 /// the owning object can be modified and has an alignment less than \p
176 /// PrefAlign, it will be increased and \p PrefAlign returned. If the alignment
177 /// cannot be increased, the known alignment of the value is returned.
178 ///
179 /// It is not always possible to modify the alignment of the underlying object,
180 /// so if alignment is important, a more reliable approach is to simply align
181 /// all global variables and allocation instructions to their preferred
182 /// alignment from the beginning.
183 unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
184  const DataLayout &DL,
185  const Instruction *CxtI = nullptr,
186  AssumptionCache *AC = nullptr,
187  const DominatorTree *DT = nullptr);
188 
189 /// Try to infer an alignment for the specified pointer.
190 static inline unsigned getKnownAlignment(Value *V, const DataLayout &DL,
191  const Instruction *CxtI = nullptr,
192  AssumptionCache *AC = nullptr,
193  const DominatorTree *DT = nullptr) {
194  return getOrEnforceKnownAlignment(V, 0, DL, CxtI, AC, DT);
195 }
196 
197 /// Given a getelementptr instruction/constantexpr, emit the code necessary to
198 /// compute the offset from the base pointer (without adding in the base
199 /// pointer). Return the result as a signed integer of intptr size.
200 /// When NoAssumptions is true, no assumptions about index computation not
201 /// overflowing is made.
202 template <typename IRBuilderTy>
203 Value *EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &DL, User *GEP,
204  bool NoAssumptions = false) {
205  GEPOperator *GEPOp = cast<GEPOperator>(GEP);
206  Type *IntPtrTy = DL.getIntPtrType(GEP->getType());
207  Value *Result = Constant::getNullValue(IntPtrTy);
208 
209  // If the GEP is inbounds, we know that none of the addressing operations will
210  // overflow in an unsigned sense.
211  bool isInBounds = GEPOp->isInBounds() && !NoAssumptions;
212 
213  // Build a mask for high order bits.
214  unsigned IntPtrWidth = IntPtrTy->getScalarType()->getIntegerBitWidth();
215  uint64_t PtrSizeMask = ~0ULL >> (64 - IntPtrWidth);
216 
218  for (User::op_iterator i = GEP->op_begin() + 1, e = GEP->op_end(); i != e;
219  ++i, ++GTI) {
220  Value *Op = *i;
221  uint64_t Size = DL.getTypeAllocSize(GTI.getIndexedType()) & PtrSizeMask;
222  if (Constant *OpC = dyn_cast<Constant>(Op)) {
223  if (OpC->isZeroValue())
224  continue;
225 
226  // Handle a struct index, which adds its field offset to the pointer.
227  if (StructType *STy = GTI.getStructTypeOrNull()) {
228  if (OpC->getType()->isVectorTy())
229  OpC = OpC->getSplatValue();
230 
231  uint64_t OpValue = cast<ConstantInt>(OpC)->getZExtValue();
232  Size = DL.getStructLayout(STy)->getElementOffset(OpValue);
233 
234  if (Size)
235  Result = Builder->CreateAdd(Result, ConstantInt::get(IntPtrTy, Size),
236  GEP->getName()+".offs");
237  continue;
238  }
239 
240  Constant *Scale = ConstantInt::get(IntPtrTy, Size);
241  Constant *OC = ConstantExpr::getIntegerCast(OpC, IntPtrTy, true /*SExt*/);
242  Scale = ConstantExpr::getMul(OC, Scale, isInBounds/*NUW*/);
243  // Emit an add instruction.
244  Result = Builder->CreateAdd(Result, Scale, GEP->getName()+".offs");
245  continue;
246  }
247  // Convert to correct type.
248  if (Op->getType() != IntPtrTy)
249  Op = Builder->CreateIntCast(Op, IntPtrTy, true, Op->getName()+".c");
250  if (Size != 1) {
251  // We'll let instcombine(mul) convert this to a shl if possible.
252  Op = Builder->CreateMul(Op, ConstantInt::get(IntPtrTy, Size),
253  GEP->getName()+".idx", isInBounds /*NUW*/);
254  }
255 
256  // Emit an add instruction.
257  Result = Builder->CreateAdd(Op, Result, GEP->getName()+".offs");
258  }
259  return Result;
260 }
261 
262 ///===---------------------------------------------------------------------===//
263 /// Dbg Intrinsic utilities
264 ///
265 
266 /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value
267 /// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
269  StoreInst *SI, DIBuilder &Builder);
270 
271 /// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value
272 /// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
274  LoadInst *LI, DIBuilder &Builder);
275 
276 /// Inserts a llvm.dbg.value intrinsic after a phi that has an associated
277 /// llvm.dbg.declare or llvm.dbg.addr intrinsic.
279  PHINode *LI, DIBuilder &Builder);
280 
281 /// Lowers llvm.dbg.declare intrinsics into appropriate set of
282 /// llvm.dbg.value intrinsics.
283 bool LowerDbgDeclare(Function &F);
284 
285 /// Finds all intrinsics declaring local variables as living in the memory that
286 /// 'V' points to. This may include a mix of dbg.declare and
287 /// dbg.addr intrinsics.
289 
290 /// Finds the llvm.dbg.value intrinsics describing a value.
292 
293 /// Replaces llvm.dbg.declare instruction when the address it describes
294 /// is replaced with a new value. If Deref is true, an additional DW_OP_deref is
295 /// prepended to the expression. If Offset is non-zero, a constant displacement
296 /// is added to the expression (after the optional Deref). Offset can be
297 /// negative.
298 bool replaceDbgDeclare(Value *Address, Value *NewAddress,
299  Instruction *InsertBefore, DIBuilder &Builder,
300  bool Deref, int Offset);
301 
302 /// Replaces llvm.dbg.declare instruction when the alloca it describes
303 /// is replaced with a new value. If Deref is true, an additional DW_OP_deref is
304 /// prepended to the expression. If Offset is non-zero, a constant displacement
305 /// is added to the expression (after the optional Deref). Offset can be
306 /// negative. New llvm.dbg.declare is inserted immediately before AI.
307 bool replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
308  DIBuilder &Builder, bool Deref, int Offset = 0);
309 
310 /// Replaces multiple llvm.dbg.value instructions when the alloca it describes
311 /// is replaced with a new value. If Offset is non-zero, a constant displacement
312 /// is added to the expression (after the mandatory Deref). Offset can be
313 /// negative. New llvm.dbg.value instructions are inserted at the locations of
314 /// the instructions they replace.
315 void replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
316  DIBuilder &Builder, int Offset = 0);
317 
318 /// Assuming the instruction \p I is going to be deleted, attempt to salvage any
319 /// dbg.value intrinsics referring to \p I by rewriting its effect into a
320 /// DIExpression.
322 
323 /// Remove all instructions from a basic block other than it's terminator
324 /// and any present EH pad instructions.
326 
327 /// Insert an unreachable instruction before the specified
328 /// instruction, making it and the rest of the code in the block dead.
329 unsigned changeToUnreachable(Instruction *I, bool UseLLVMTrap,
330  bool PreserveLCSSA = false);
331 
332 /// Convert the CallInst to InvokeInst with the specified unwind edge basic
333 /// block. This also splits the basic block where CI is located, because
334 /// InvokeInst is a terminator instruction. Returns the newly split basic
335 /// block.
337  BasicBlock *UnwindEdge);
338 
339 /// Replace 'BB's terminator with one that does not have an unwind successor
340 /// block. Rewrites `invoke` to `call`, etc. Updates any PHIs in unwind
341 /// successor.
342 ///
343 /// \param BB Block whose terminator will be replaced. Its terminator must
344 /// have an unwind successor.
345 void removeUnwindEdge(BasicBlock *BB);
346 
347 /// Remove all blocks that can not be reached from the function's entry.
348 ///
349 /// Returns true if any basic block was removed.
350 bool removeUnreachableBlocks(Function &F, LazyValueInfo *LVI = nullptr);
351 
352 /// Combine the metadata of two instructions so that K can replace J
353 ///
354 /// Metadata not listed as known via KnownIDs is removed
355 void combineMetadata(Instruction *K, const Instruction *J, ArrayRef<unsigned> KnownIDs);
356 
357 /// Combine the metadata of two instructions so that K can replace J. This
358 /// specifically handles the case of CSE-like transformations.
359 ///
360 /// Unknown metadata is removed.
362 
363 // Replace each use of 'From' with 'To', if that use does not belong to basic
364 // block where 'From' is defined. Returns the number of replacements made.
365 unsigned replaceNonLocalUsesWith(Instruction *From, Value *To);
366 
367 /// Replace each use of 'From' with 'To' if that use is dominated by
368 /// the given edge. Returns the number of replacements made.
369 unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
370  const BasicBlockEdge &Edge);
371 /// Replace each use of 'From' with 'To' if that use is dominated by
372 /// the end of the given BasicBlock. Returns the number of replacements made.
373 unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
374  const BasicBlock *BB);
375 
376 
377 /// Return true if the CallSite CS calls a gc leaf function.
378 ///
379 /// A leaf function is a function that does not safepoint the thread during its
380 /// execution. During a call or invoke to such a function, the callers stack
381 /// does not have to be made parseable.
382 ///
383 /// Most passes can and should ignore this information, and it is only used
384 /// during lowering by the GC infrastructure.
386 
387 /// Copy a nonnull metadata node to a new load instruction.
388 ///
389 /// This handles mapping it to range metadata if the new load is an integer
390 /// load instead of a pointer load.
391 void copyNonnullMetadata(const LoadInst &OldLI, MDNode *N, LoadInst &NewLI);
392 
393 /// Copy a range metadata node to a new load instruction.
394 ///
395 /// This handles mapping it to nonnull metadata if the new load is a pointer
396 /// load instead of an integer load and the range doesn't cover null.
397 void copyRangeMetadata(const DataLayout &DL, const LoadInst &OldLI, MDNode *N,
398  LoadInst &NewLI);
399 
400 //===----------------------------------------------------------------------===//
401 // Intrinsic pattern matching
402 //
403 
404 /// Try and match a bswap or bitreverse idiom.
405 ///
406 /// If an idiom is matched, an intrinsic call is inserted before \c I. Any added
407 /// instructions are returned in \c InsertedInsts. They will all have been added
408 /// to a basic block.
409 ///
410 /// A bitreverse idiom normally requires around 2*BW nodes to be searched (where
411 /// BW is the bitwidth of the integer type). A bswap idiom requires anywhere up
412 /// to BW / 4 nodes to be searched, so is significantly faster.
413 ///
414 /// This function returns true on a successful match or false otherwise.
416  Instruction *I, bool MatchBSwaps, bool MatchBitReversals,
417  SmallVectorImpl<Instruction *> &InsertedInsts);
418 
419 //===----------------------------------------------------------------------===//
420 // Sanitizer utilities
421 //
422 
423 /// Given a CallInst, check if it calls a string function known to CodeGen,
424 /// and mark it with NoBuiltin if so. To be used by sanitizers that intend
425 /// to intercept string functions and want to avoid converting them to target
426 /// specific instructions.
428  const TargetLibraryInfo *TLI);
429 
430 //===----------------------------------------------------------------------===//
431 // Transform predicates
432 //
433 
434 /// Given an instruction, is it legal to set operand OpIdx to a non-constant
435 /// value?
436 bool canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx);
437 
438 } // End llvm namespace
439 
440 #endif
Value * EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &DL, User *GEP, bool NoAssumptions=false)
Given a getelementptr instruction/constantexpr, emit the code necessary to compute the offset from th...
Definition: Local.h:203
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
bool replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress, DIBuilder &Builder, bool Deref, int Offset=0)
Replaces llvm.dbg.declare instruction when the alloca it describes is replaced with a new value...
Definition: Local.cpp:1284
AllocaInst * DemoteRegToStack(Instruction &X, bool VolatileLoads=false, Instruction *AllocaPoint=nullptr)
This function takes a virtual register computed by an Instruction and replaces it with a slot in the ...
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to ensure that the alignment of V is at least PrefAlign bytes.
Definition: Local.cpp:1034
void replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress, DIBuilder &Builder, int Offset=0)
Replaces multiple llvm.dbg.value instructions when the alloca it describes is replaced with a new val...
Definition: Local.cpp:1318
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Various leaf nodes.
Definition: ISDOpcodes.h:60
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
Definition: DataLayout.cpp:562
This class represents a function call, abstracting a target machine&#39;s calling convention.
void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, DominatorTree *DT=nullptr)
BB is a block with one predecessor and its predecessor is known to have one successor (BB!)...
Definition: Local.cpp:587
A cache of .assume calls within a function.
bool SimplifyInstructionsInBlock(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr)
Scan the specified basic block and try to simplify any instructions in it and recursively delete dead...
Definition: Local.cpp:504
Metadata node.
Definition: Metadata.h:862
F(f)
An instruction for reading from memory.
Definition: Instructions.h:164
Hexagon Common GEP
void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred)
Like BasicBlock::removePredecessor, this method is called when we&#39;re about to delete Pred as a predec...
Definition: Local.cpp:556
unsigned changeToUnreachable(Instruction *I, bool UseLLVMTrap, bool PreserveLCSSA=false)
Insert an unreachable instruction before the specified instruction, making it and the rest of the cod...
Definition: Local.cpp:1401
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
Definition: TinyPtrVector.h:31
unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT, const BasicBlockEdge &Edge)
Replace each use of &#39;From&#39; with &#39;To&#39; if that use is dominated by the given edge.
Definition: Local.cpp:1824
op_iterator op_begin()
Definition: User.h:214
static Constant * getNullValue(Type *Ty)
Constructor to create a &#39;0&#39; constant of arbitrary type.
Definition: Constants.cpp:207
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
Definition: Constants.cpp:1518
Class to represent struct types.
Definition: DerivedTypes.h:201
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions=false, const TargetLibraryInfo *TLI=nullptr)
If a terminator instruction is predicated on a constant value, convert it into an unconditional branc...
Definition: Local.cpp:70
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
void findDbgValues(SmallVectorImpl< DbgValueInst *> &DbgValues, Value *V)
Finds the llvm.dbg.value intrinsics describing a value.
Definition: Local.cpp:1256
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
void copyNonnullMetadata(const LoadInst &OldLI, MDNode *N, LoadInst &NewLI)
Copy a nonnull metadata node to a new load instruction.
Definition: Local.cpp:1869
bool SimplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI, unsigned BonusInstThreshold, AssumptionCache *AC=nullptr, SmallPtrSetImpl< BasicBlock *> *LoopHeaders=nullptr, bool LateSimplifyCFG=false)
This function is used to do simplification of a CFG.
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Definition: Operator.h:404
void salvageDebugInfo(Instruction &I)
Assuming the instruction I is going to be deleted, attempt to salvage any dbg.value intrinsics referr...
Definition: Local.cpp:1329
An instruction for storing to memory.
Definition: Instructions.h:306
bool EliminateDuplicatePHINodes(BasicBlock *BB)
Check for and eliminate duplicate PHI nodes in this block.
Definition: Local.cpp:931
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:140
static unsigned getKnownAlignment(Value *V, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to infer an alignment for the specified pointer.
Definition: Local.h:190
bool FlattenCFG(BasicBlock *BB, AliasAnalysis *AA=nullptr)
This function is used to flatten a CFG.
Definition: FlattenCFG.cpp:480
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
Definition: DataLayout.cpp:702
#define P(N)
bool FoldBranchToCommonDest(BranchInst *BI, unsigned BonusInstThreshold=1)
If this basic block is ONLY a setcc and a branch, and if a predecessor branches to us and one of our ...
AAResults AliasAnalysis
Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB)
BB is known to contain an unconditional branch, and contains no instructions other than PHI nodes...
Definition: Local.cpp:837
This is an important base class in LLVM.
Definition: Constant.h:42
bool canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx)
Given an instruction, is it legal to set operand OpIdx to a non-constant value?
Definition: Local.cpp:2175
void ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII, StoreInst *SI, DIBuilder &Builder)
===---------------------------------------------------------------——===// Dbg Intrinsic utilities ...
Definition: Local.cpp:1102
op_iterator op_end()
Definition: User.h:216
void copyRangeMetadata(const DataLayout &DL, const LoadInst &OldLI, MDNode *N, LoadInst &NewLI)
Copy a range metadata node to a new load instruction.
Definition: Local.cpp:1894
bool callsGCLeafFunction(ImmutableCallSite CS, const TargetLibraryInfo &TLI)
Return true if the CallSite CS calls a gc leaf function.
Definition: Local.cpp:1843
bool replaceDbgDeclare(Value *Address, Value *NewAddress, Instruction *InsertBefore, DIBuilder &Builder, bool Deref, int Offset)
Replaces llvm.dbg.declare instruction when the address it describes is replaced with a new value...
Definition: Local.cpp:1264
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr)
If the specified value is a trivially dead instruction, delete it.
Definition: Local.cpp:370
bool LowerDbgDeclare(Function &F)
Lowers llvm.dbg.declare intrinsics into appropriate set of llvm.dbg.value intrinsics.
Definition: Local.cpp:1192
bool removeUnreachableBlocks(Function &F, LazyValueInfo *LVI=nullptr)
Remove all blocks that can not be reached from the function&#39;s entry.
Definition: Local.cpp:1677
Provides information about what library functions are available for the current target.
This is the common base class for debug info intrinsics.
Definition: IntrinsicInst.h:67
bool RecursivelyDeleteDeadPHINode(PHINode *PN, const TargetLibraryInfo *TLI=nullptr)
If the specified value is an effectively dead PHI node, due to being a def-use chain of single-use no...
Definition: Local.cpp:427
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:560
unsigned removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB)
Remove all instructions from a basic block other than it&#39;s terminator and any present EH pad instruct...
Definition: Local.cpp:1380
TinyPtrVector< DbgInfoIntrinsic * > FindDbgAddrUses(Value *V)
Finds all intrinsics declaring local variables as living in the memory that &#39;V&#39; points to...
Definition: Local.cpp:1238
void removeUnwindEdge(BasicBlock *BB)
Replace &#39;BB&#39;s terminator with one that does not have an unwind successor block.
Definition: Local.cpp:1639
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
could "use" a pointer
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:405
uint64_t getElementOffset(unsigned Idx) const
Definition: DataLayout.h:515
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:218
Establish a view to a call site for examination.
Definition: CallSite.h:695
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
void maybeMarkSanitizerLibraryCallNoBuiltin(CallInst *CI, const TargetLibraryInfo *TLI)
Given a CallInst, check if it calls a string function known to CodeGen, and mark it with NoBuiltin if...
Definition: Local.cpp:2165
void combineMetadataForCSE(Instruction *K, const Instruction *J)
Combine the metadata of two instructions so that K can replace J.
Definition: Local.cpp:1776
This pass computes, caches, and vends lazy value constraint information.
Definition: LazyValueInfo.h:32
AllocaInst * DemotePHIToStack(PHINode *P, Instruction *AllocaPoint=nullptr)
This function takes a virtual register computed by a phi node and replaces it with a slot in the stac...
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction has no side ef...
Definition: Local.cpp:293
LLVM Value Representation.
Definition: Value.h:73
BasicBlock * changeToInvokeAndSplitBasicBlock(CallInst *CI, BasicBlock *UnwindEdge)
Convert the CallInst to InvokeInst with the specified unwind edge basic block.
Definition: Local.cpp:1452
bool wouldInstructionBeTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction would have no side effects if it was not used...
Definition: Local.cpp:300
bool recognizeBSwapOrBitReverseIdiom(Instruction *I, bool MatchBSwaps, bool MatchBitReversals, SmallVectorImpl< Instruction *> &InsertedInsts)
Try and match a bswap or bitreverse idiom.
Definition: Local.cpp:2091
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2137
void combineMetadata(Instruction *K, const Instruction *J, ArrayRef< unsigned > KnownIDs)
Combine the metadata of two instructions so that K can replace J.
Definition: Local.cpp:1711
unsigned replaceNonLocalUsesWith(Instruction *From, Value *To)
Definition: Local.cpp:1807
an instruction to allocate memory on the stack
Definition: Instructions.h:60
gep_type_iterator gep_type_begin(const User *GEP)