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"
20 #include "llvm/IR/DataLayout.h"
21 #include "llvm/IR/Dominators.h"
23 #include "llvm/IR/IRBuilder.h"
24 #include "llvm/IR/Operator.h"
25 
26 namespace llvm {
27 
28 class User;
29 class BasicBlock;
30 class Function;
31 class BranchInst;
32 class Instruction;
33 class CallInst;
34 class DbgDeclareInst;
35 class DbgValueInst;
36 class StoreInst;
37 class LoadInst;
38 class Value;
39 class PHINode;
40 class AllocaInst;
41 class AssumptionCache;
42 class ConstantExpr;
43 class DataLayout;
44 class TargetLibraryInfo;
45 class TargetTransformInfo;
46 class DIBuilder;
47 class DominatorTree;
48 class LazyValueInfo;
49 
50 template<typename T> class SmallVectorImpl;
51 
52 //===----------------------------------------------------------------------===//
53 // Local constant propagation.
54 //
55 
56 /// If a terminator instruction is predicated on a constant value, convert it
57 /// into an unconditional branch to the constant destination.
58 /// This is a nontrivial operation because the successors of this basic block
59 /// must have their PHI nodes updated.
60 /// Also calls RecursivelyDeleteTriviallyDeadInstructions() on any branch/switch
61 /// conditions and indirectbr addresses this might make dead if
62 /// DeleteDeadConditions is true.
63 bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions = false,
64  const TargetLibraryInfo *TLI = nullptr);
65 
66 //===----------------------------------------------------------------------===//
67 // Local dead code elimination.
68 //
69 
70 /// Return true if the result produced by the instruction is not used, and the
71 /// instruction has no side effects.
72 bool isInstructionTriviallyDead(Instruction *I,
73  const TargetLibraryInfo *TLI = nullptr);
74 
75 /// Return true if the result produced by the instruction would have no side
76 /// effects if it was not used. This is equivalent to checking whether
77 /// isInstructionTriviallyDead would be true if the use count was 0.
78 bool wouldInstructionBeTriviallyDead(Instruction *I,
79  const TargetLibraryInfo *TLI = nullptr);
80 
81 /// If the specified value is a trivially dead instruction, delete it.
82 /// If that makes any of its operands trivially dead, delete them too,
83 /// recursively. Return true if any instructions were deleted.
85  const TargetLibraryInfo *TLI = nullptr);
86 
87 /// If the specified value is an effectively dead PHI node, due to being a
88 /// def-use chain of single-use nodes that either forms a cycle or is terminated
89 /// by a trivially dead instruction, delete it. If that makes any of its
90 /// operands trivially dead, delete them too, recursively. Return true if a
91 /// change was made.
92 bool RecursivelyDeleteDeadPHINode(PHINode *PN,
93  const TargetLibraryInfo *TLI = nullptr);
94 
95 /// Scan the specified basic block and try to simplify any instructions in it
96 /// and recursively delete dead instructions.
97 ///
98 /// This returns true if it changed the code, note that it can delete
99 /// instructions in other blocks as well in this block.
101  const TargetLibraryInfo *TLI = nullptr);
102 
103 //===----------------------------------------------------------------------===//
104 // Control Flow Graph Restructuring.
105 //
106 
107 /// Like BasicBlock::removePredecessor, this method is called when we're about
108 /// to delete Pred as a predecessor of BB. If BB contains any PHI nodes, this
109 /// drops the entries in the PHI nodes for Pred.
110 ///
111 /// Unlike the removePredecessor method, this attempts to simplify uses of PHI
112 /// nodes that collapse into identity values. For example, if we have:
113 /// x = phi(1, 0, 0, 0)
114 /// y = and x, z
115 ///
116 /// .. and delete the predecessor corresponding to the '1', this will attempt to
117 /// recursively fold the 'and' to 0.
119 
120 /// BB is a block with one predecessor and its predecessor is known to have one
121 /// successor (BB!). Eliminate the edge between them, moving the instructions in
122 /// the predecessor into BB. This deletes the predecessor block.
123 void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, DominatorTree *DT = nullptr);
124 
125 /// BB is known to contain an unconditional branch, and contains no instructions
126 /// other than PHI nodes, potential debug intrinsics and the branch. If
127 /// possible, eliminate BB by rewriting all the predecessors to branch to the
128 /// successor block and return true. If we can't transform, return false.
130 
131 /// Check for and eliminate duplicate PHI nodes in this block. This doesn't try
132 /// to be clever about PHI nodes which differ only in the order of the incoming
133 /// values, but instcombine orders them so it usually won't matter.
135 
136 /// This function is used to do simplification of a CFG. For
137 /// example, it adjusts branches to branches to eliminate the extra hop, it
138 /// eliminates unreachable basic blocks, and does other "peephole" optimization
139 /// of the CFG. It returns true if a modification was made, possibly deleting
140 /// the basic block that was pointed to. LoopHeaders is an optional input
141 /// parameter, providing the set of loop header that SimplifyCFG should not
142 /// eliminate.
143 bool SimplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
144  unsigned BonusInstThreshold, AssumptionCache *AC = nullptr,
145  SmallPtrSetImpl<BasicBlock *> *LoopHeaders = nullptr,
146  bool LateSimplifyCFG = false);
147 
148 /// This function is used to flatten a CFG. For example, it uses parallel-and
149 /// and parallel-or mode to collapse if-conditions and merge if-regions with
150 /// identical statements.
151 bool FlattenCFG(BasicBlock *BB, AliasAnalysis *AA = nullptr);
152 
153 /// If this basic block is ONLY a setcc and a branch, and if a predecessor
154 /// branches to us and one of our successors, fold the setcc into the
155 /// predecessor and use logical operations to pick the right destination.
156 bool FoldBranchToCommonDest(BranchInst *BI, unsigned BonusInstThreshold = 1);
157 
158 /// This function takes a virtual register computed by an Instruction and
159 /// replaces it with a slot in the stack frame, allocated via alloca.
160 /// This allows the CFG to be changed around without fear of invalidating the
161 /// SSA information for the value. It returns the pointer to the alloca inserted
162 /// to create a stack slot for X.
163 AllocaInst *DemoteRegToStack(Instruction &X,
164  bool VolatileLoads = false,
165  Instruction *AllocaPoint = nullptr);
166 
167 /// This function takes a virtual register computed by a phi node and replaces
168 /// it with a slot in the stack frame, allocated via alloca. The phi node is
169 /// deleted and it returns the pointer to the alloca inserted.
170 AllocaInst *DemotePHIToStack(PHINode *P, Instruction *AllocaPoint = nullptr);
171 
172 /// Try to ensure that the alignment of \p V is at least \p PrefAlign bytes. If
173 /// the owning object can be modified and has an alignment less than \p
174 /// PrefAlign, it will be increased and \p PrefAlign returned. If the alignment
175 /// cannot be increased, the known alignment of the value is returned.
176 ///
177 /// It is not always possible to modify the alignment of the underlying object,
178 /// so if alignment is important, a more reliable approach is to simply align
179 /// all global variables and allocation instructions to their preferred
180 /// alignment from the beginning.
181 unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
182  const DataLayout &DL,
183  const Instruction *CxtI = nullptr,
184  AssumptionCache *AC = nullptr,
185  const DominatorTree *DT = nullptr);
186 
187 /// Try to infer an alignment for the specified pointer.
188 static inline unsigned getKnownAlignment(Value *V, const DataLayout &DL,
189  const Instruction *CxtI = nullptr,
190  AssumptionCache *AC = nullptr,
191  const DominatorTree *DT = nullptr) {
192  return getOrEnforceKnownAlignment(V, 0, DL, CxtI, AC, DT);
193 }
194 
195 /// Given a getelementptr instruction/constantexpr, emit the code necessary to
196 /// compute the offset from the base pointer (without adding in the base
197 /// pointer). Return the result as a signed integer of intptr size.
198 /// When NoAssumptions is true, no assumptions about index computation not
199 /// overflowing is made.
200 template <typename IRBuilderTy>
201 Value *EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &DL, User *GEP,
202  bool NoAssumptions = false) {
203  GEPOperator *GEPOp = cast<GEPOperator>(GEP);
204  Type *IntPtrTy = DL.getIntPtrType(GEP->getType());
205  Value *Result = Constant::getNullValue(IntPtrTy);
206 
207  // If the GEP is inbounds, we know that none of the addressing operations will
208  // overflow in an unsigned sense.
209  bool isInBounds = GEPOp->isInBounds() && !NoAssumptions;
210 
211  // Build a mask for high order bits.
212  unsigned IntPtrWidth = IntPtrTy->getScalarType()->getIntegerBitWidth();
213  uint64_t PtrSizeMask = ~0ULL >> (64 - IntPtrWidth);
214 
216  for (User::op_iterator i = GEP->op_begin() + 1, e = GEP->op_end(); i != e;
217  ++i, ++GTI) {
218  Value *Op = *i;
219  uint64_t Size = DL.getTypeAllocSize(GTI.getIndexedType()) & PtrSizeMask;
220  if (Constant *OpC = dyn_cast<Constant>(Op)) {
221  if (OpC->isZeroValue())
222  continue;
223 
224  // Handle a struct index, which adds its field offset to the pointer.
225  if (StructType *STy = GTI.getStructTypeOrNull()) {
226  if (OpC->getType()->isVectorTy())
227  OpC = OpC->getSplatValue();
228 
229  uint64_t OpValue = cast<ConstantInt>(OpC)->getZExtValue();
230  Size = DL.getStructLayout(STy)->getElementOffset(OpValue);
231 
232  if (Size)
233  Result = Builder->CreateAdd(Result, ConstantInt::get(IntPtrTy, Size),
234  GEP->getName()+".offs");
235  continue;
236  }
237 
238  Constant *Scale = ConstantInt::get(IntPtrTy, Size);
239  Constant *OC = ConstantExpr::getIntegerCast(OpC, IntPtrTy, true /*SExt*/);
240  Scale = ConstantExpr::getMul(OC, Scale, isInBounds/*NUW*/);
241  // Emit an add instruction.
242  Result = Builder->CreateAdd(Result, Scale, GEP->getName()+".offs");
243  continue;
244  }
245  // Convert to correct type.
246  if (Op->getType() != IntPtrTy)
247  Op = Builder->CreateIntCast(Op, IntPtrTy, true, Op->getName()+".c");
248  if (Size != 1) {
249  // We'll let instcombine(mul) convert this to a shl if possible.
250  Op = Builder->CreateMul(Op, ConstantInt::get(IntPtrTy, Size),
251  GEP->getName()+".idx", isInBounds /*NUW*/);
252  }
253 
254  // Emit an add instruction.
255  Result = Builder->CreateAdd(Op, Result, GEP->getName()+".offs");
256  }
257  return Result;
258 }
259 
260 ///===---------------------------------------------------------------------===//
261 /// Dbg Intrinsic utilities
262 ///
263 
264 /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value
265 /// that has an associated llvm.dbg.decl intrinsic.
267  StoreInst *SI, DIBuilder &Builder);
268 
269 /// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value
270 /// that has an associated llvm.dbg.decl intrinsic.
272  LoadInst *LI, DIBuilder &Builder);
273 
274 /// Inserts a llvm.dbg.value intrinsic after a phi of an alloca'd value
275 /// that has an associated llvm.dbg.decl intrinsic.
277  PHINode *LI, DIBuilder &Builder);
278 
279 /// Lowers llvm.dbg.declare intrinsics into appropriate set of
280 /// llvm.dbg.value intrinsics.
281 bool LowerDbgDeclare(Function &F);
282 
283 /// Finds the llvm.dbg.declare intrinsic corresponding to an alloca, if any.
285 
286 /// Finds the llvm.dbg.value intrinsics describing a value.
288 
289 /// Replaces llvm.dbg.declare instruction when the address it describes
290 /// is replaced with a new value. If Deref is true, an additional DW_OP_deref is
291 /// prepended to the expression. If Offset is non-zero, a constant displacement
292 /// is added to the expression (after the optional Deref). Offset can be
293 /// negative.
294 bool replaceDbgDeclare(Value *Address, Value *NewAddress,
295  Instruction *InsertBefore, DIBuilder &Builder,
296  bool Deref, int Offset);
297 
298 /// Replaces llvm.dbg.declare instruction when the alloca it describes
299 /// is replaced with a new value. If Deref is true, an additional DW_OP_deref is
300 /// prepended to the expression. If Offset is non-zero, a constant displacement
301 /// is added to the expression (after the optional Deref). Offset can be
302 /// negative. New llvm.dbg.declare is inserted immediately before AI.
303 bool replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
304  DIBuilder &Builder, bool Deref, int Offset = 0);
305 
306 /// Replaces multiple llvm.dbg.value instructions when the alloca it describes
307 /// is replaced with a new value. If Offset is non-zero, a constant displacement
308 /// is added to the expression (after the mandatory Deref). Offset can be
309 /// negative. New llvm.dbg.value instructions are inserted at the locations of
310 /// the instructions they replace.
311 void replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
312  DIBuilder &Builder, int Offset = 0);
313 
314 /// Assuming the instruction \p I is going to be deleted, attempt to salvage any
315 /// dbg.value intrinsics referring to \p I by rewriting its effect into a
316 /// DIExpression.
318 
319 /// Remove all instructions from a basic block other than it's terminator
320 /// and any present EH pad instructions.
322 
323 /// Insert an unreachable instruction before the specified
324 /// instruction, making it and the rest of the code in the block dead.
325 unsigned changeToUnreachable(Instruction *I, bool UseLLVMTrap,
326  bool PreserveLCSSA = false);
327 
328 /// Convert the CallInst to InvokeInst with the specified unwind edge basic
329 /// block. This also splits the basic block where CI is located, because
330 /// InvokeInst is a terminator instruction. Returns the newly split basic
331 /// block.
333  BasicBlock *UnwindEdge);
334 
335 /// Replace 'BB's terminator with one that does not have an unwind successor
336 /// block. Rewrites `invoke` to `call`, etc. Updates any PHIs in unwind
337 /// successor.
338 ///
339 /// \param BB Block whose terminator will be replaced. Its terminator must
340 /// have an unwind successor.
341 void removeUnwindEdge(BasicBlock *BB);
342 
343 /// Remove all blocks that can not be reached from the function's entry.
344 ///
345 /// Returns true if any basic block was removed.
346 bool removeUnreachableBlocks(Function &F, LazyValueInfo *LVI = nullptr);
347 
348 /// Combine the metadata of two instructions so that K can replace J
349 ///
350 /// Metadata not listed as known via KnownIDs is removed
351 void combineMetadata(Instruction *K, const Instruction *J, ArrayRef<unsigned> KnownIDs);
352 
353 /// Combine the metadata of two instructions so that K can replace J. This
354 /// specifically handles the case of CSE-like transformations.
355 ///
356 /// Unknown metadata is removed.
358 
359 // Replace each use of 'From' with 'To', if that use does not belong to basic
360 // block where 'From' is defined. Returns the number of replacements made.
361 unsigned replaceNonLocalUsesWith(Instruction *From, Value *To);
362 
363 /// Replace each use of 'From' with 'To' if that use is dominated by
364 /// the given edge. Returns the number of replacements made.
365 unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
366  const BasicBlockEdge &Edge);
367 /// Replace each use of 'From' with 'To' if that use is dominated by
368 /// the end of the given BasicBlock. Returns the number of replacements made.
369 unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
370  const BasicBlock *BB);
371 
372 
373 /// Return true if the CallSite CS calls a gc leaf function.
374 ///
375 /// A leaf function is a function that does not safepoint the thread during its
376 /// execution. During a call or invoke to such a function, the callers stack
377 /// does not have to be made parseable.
378 ///
379 /// Most passes can and should ignore this information, and it is only used
380 /// during lowering by the GC infrastructure.
382 
383 /// Copy a nonnull metadata node to a new load instruction.
384 ///
385 /// This handles mapping it to range metadata if the new load is an integer
386 /// load instead of a pointer load.
387 void copyNonnullMetadata(const LoadInst &OldLI, MDNode *N, LoadInst &NewLI);
388 
389 /// Copy a range metadata node to a new load instruction.
390 ///
391 /// This handles mapping it to nonnull metadata if the new load is a pointer
392 /// load instead of an integer load and the range doesn't cover null.
393 void copyRangeMetadata(const DataLayout &DL, const LoadInst &OldLI, MDNode *N,
394  LoadInst &NewLI);
395 
396 //===----------------------------------------------------------------------===//
397 // Intrinsic pattern matching
398 //
399 
400 /// Try and match a bswap or bitreverse idiom.
401 ///
402 /// If an idiom is matched, an intrinsic call is inserted before \c I. Any added
403 /// instructions are returned in \c InsertedInsts. They will all have been added
404 /// to a basic block.
405 ///
406 /// A bitreverse idiom normally requires around 2*BW nodes to be searched (where
407 /// BW is the bitwidth of the integer type). A bswap idiom requires anywhere up
408 /// to BW / 4 nodes to be searched, so is significantly faster.
409 ///
410 /// This function returns true on a successful match or false otherwise.
412  Instruction *I, bool MatchBSwaps, bool MatchBitReversals,
413  SmallVectorImpl<Instruction *> &InsertedInsts);
414 
415 //===----------------------------------------------------------------------===//
416 // Sanitizer utilities
417 //
418 
419 /// Given a CallInst, check if it calls a string function known to CodeGen,
420 /// and mark it with NoBuiltin if so. To be used by sanitizers that intend
421 /// to intercept string functions and want to avoid converting them to target
422 /// specific instructions.
424  const TargetLibraryInfo *TLI);
425 
426 //===----------------------------------------------------------------------===//
427 // Transform predicates
428 //
429 
430 /// Given an instruction, is it legal to set operand OpIdx to a non-constant
431 /// value?
432 bool canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx);
433 
434 } // End llvm namespace
435 
436 #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:201
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:1275
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:1310
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Various leaf nodes.
Definition: ISDOpcodes.h:60
AAResults AliasAnalysis
Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.
DbgDeclareInst * FindAllocaDbgDeclare(Value *V)
Finds the llvm.dbg.declare intrinsic corresponding to an alloca, if any.
Definition: Local.cpp:1238
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
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:1393
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:1816
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:1248
#define F(x, y, z)
Definition: MD5.cpp:55
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:1852
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:1321
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:134
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:188
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 ...
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
void ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI, StoreInst *SI, DIBuilder &Builder)
===---------------------------------------------------------------——===// Dbg Intrinsic utilities ...
Definition: Local.cpp:1104
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:2158
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:1877
bool callsGCLeafFunction(ImmutableCallSite CS)
Return true if the CallSite CS calls a gc leaf function.
Definition: Local.cpp:1835
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:1257
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:1193
bool removeUnreachableBlocks(Function &F, LazyValueInfo *LVI=nullptr)
Remove all blocks that can not be reached from the function&#39;s entry.
Definition: Local.cpp:1669
Provides information about what library functions are available for the current target.
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
const size_t N
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:1372
void removeUnwindEdge(BasicBlock *BB)
Replace &#39;BB&#39;s terminator with one that does not have an unwind successor block.
Definition: Local.cpp:1631
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:687
#define I(x, y, z)
Definition: MD5.cpp:58
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:2148
void combineMetadataForCSE(Instruction *K, const Instruction *J)
Combine the metadata of two instructions so that K can replace J.
Definition: Local.cpp:1768
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:1444
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:2074
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2137
This represents the llvm.dbg.declare instruction.
Definition: IntrinsicInst.h:89
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:1703
unsigned replaceNonLocalUsesWith(Instruction *From, Value *To)
Definition: Local.cpp:1799
an instruction to allocate memory on the stack
Definition: Instructions.h:60
gep_type_iterator gep_type_begin(const User *GEP)