LLVM  16.0.0git
Local.h
Go to the documentation of this file.
1 //===- Local.h - Functions to perform local transformations -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This family of functions perform various local transformations to the
10 // program.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TRANSFORMS_UTILS_LOCAL_H
15 #define LLVM_TRANSFORMS_UTILS_LOCAL_H
16
18 #include "llvm/IR/Dominators.h"
21 #include <cstdint>
22
23 namespace llvm {
24
25 class DataLayout;
26 class Value;
27 class WeakTrackingVH;
28 class WeakVH;
29 template <typename T> class SmallVectorImpl;
30 class AAResults;
31 class AllocaInst;
32 class AssumptionCache;
33 class BasicBlock;
34 class BranchInst;
35 class CallBase;
36 class CallInst;
37 class DbgVariableIntrinsic;
38 class DIBuilder;
39 class DomTreeUpdater;
40 class Function;
41 class Instruction;
42 class InvokeInst;
44 class MDNode;
45 class MemorySSAUpdater;
46 class PHINode;
47 class StoreInst;
48 class TargetLibraryInfo;
49 class TargetTransformInfo;
50
51 //===----------------------------------------------------------------------===//
52 // Local constant propagation.
53 //
54
55 /// If a terminator instruction is predicated on a constant value, convert it
56 /// into an unconditional branch to the constant destination.
57 /// This is a nontrivial operation because the successors of this basic block
58 /// must have their PHI nodes updated.
59 /// Also calls RecursivelyDeleteTriviallyDeadInstructions() on any branch/switch
62 bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions = false,
63  const TargetLibraryInfo *TLI = nullptr,
64  DomTreeUpdater *DTU = 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 will return. Certain side-effecting instructions are also
72 /// considered dead if there are no uses of the instruction.
74  const TargetLibraryInfo *TLI = nullptr);
75
76 /// Return true if the result produced by the instruction would have no side
77 /// effects if it was not used. This is equivalent to checking whether
78 /// isInstructionTriviallyDead would be true if the use count was 0.
80  const TargetLibraryInfo *TLI = nullptr);
81
82 /// Return true if the result produced by the instruction has no side effects on
83 /// any paths other than where it is used. This is less conservative than
84 /// wouldInstructionBeTriviallyDead which is based on the assumption
85 /// that the use count will be 0. An example usage of this API is for
86 /// identifying instructions that can be sunk down to use(s).
88  Instruction *I, const TargetLibraryInfo *TLI = nullptr);
89
90 /// If the specified value is a trivially dead instruction, delete it.
91 /// If that makes any of its operands trivially dead, delete them too,
92 /// recursively. Return true if any instructions were deleted.
94  Value *V, const TargetLibraryInfo *TLI = nullptr,
95  MemorySSAUpdater *MSSAU = nullptr,
97  std::function<void(Value *)>());
98
99 /// Delete all of the instructions in DeadInsts, and all other instructions
100 /// that deleting these in turn causes to be trivially dead.
101 ///
102 /// The initial instructions in the provided vector must all have empty use
103 /// lists and satisfy isInstructionTriviallyDead.
104 ///
105 /// DeadInsts will be used as scratch storage for this routine and will be
106 /// empty afterward.
109  const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr,
111  std::function<void(Value *)>());
112
113 /// Same functionality as RecursivelyDeleteTriviallyDeadInstructions, but allow
114 /// instructions that are not trivially dead. These will be ignored.
115 /// Returns true if any changes were made, i.e. any instructions trivially dead
116 /// were found and deleted.
119  const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr,
121  std::function<void(Value *)>());
122
123 /// If the specified value is an effectively dead PHI node, due to being a
124 /// def-use chain of single-use nodes that either forms a cycle or is terminated
125 /// by a trivially dead instruction, delete it. If that makes any of its
126 /// operands trivially dead, delete them too, recursively. Return true if a
129  const TargetLibraryInfo *TLI = nullptr,
130  MemorySSAUpdater *MSSAU = nullptr);
131
132 /// Scan the specified basic block and try to simplify any instructions in it
133 /// and recursively delete dead instructions.
134 ///
135 /// This returns true if it changed the code, note that it can delete
136 /// instructions in other blocks as well in this block.
138  const TargetLibraryInfo *TLI = nullptr);
139
140 /// Replace all the uses of an SSA value in @llvm.dbg intrinsics with
141 /// undef. This is useful for signaling that a variable, e.g. has been
142 /// found dead and hence it's unavailable at a given program point.
143 /// Returns true if the dbg values have been changed.
144 bool replaceDbgUsesWithUndef(Instruction *I);
145
146 //===----------------------------------------------------------------------===//
147 // Control Flow Graph Restructuring.
148 //
149
150 /// BB is a block with one predecessor and its predecessor is known to have one
151 /// successor (BB!). Eliminate the edge between them, moving the instructions in
152 /// the predecessor into BB. This deletes the predecessor block.
153 void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, DomTreeUpdater *DTU = nullptr);
154
155 /// BB is known to contain an unconditional branch, and contains no instructions
156 /// other than PHI nodes, potential debug intrinsics and the branch. If
157 /// possible, eliminate BB by rewriting all the predecessors to branch to the
158 /// successor block and return true. If we can't transform, return false.
160  DomTreeUpdater *DTU = nullptr);
161
162 /// Check for and eliminate duplicate PHI nodes in this block. This doesn't try
163 /// to be clever about PHI nodes which differ only in the order of the incoming
164 /// values, but instcombine orders them so it usually won't matter.
166
167 /// This function is used to do simplification of a CFG. For example, it
168 /// adjusts branches to branches to eliminate the extra hop, it eliminates
169 /// unreachable basic blocks, and does other peephole optimization of the CFG.
170 /// It returns true if a modification was made, possibly deleting the basic
171 /// block that was pointed to. LoopHeaders is an optional input parameter
172 /// providing the set of loop headers that SimplifyCFG should not eliminate.
173 extern cl::opt<bool> RequireAndPreserveDomTree;
174 bool simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
175  DomTreeUpdater *DTU = nullptr,
176  const SimplifyCFGOptions &Options = {},
178
179 /// This function is used to flatten a CFG. For example, it uses parallel-and
180 /// and parallel-or mode to collapse if-conditions and merge if-regions with
181 /// identical statements.
182 bool FlattenCFG(BasicBlock *BB, AAResults *AA = nullptr);
183
184 /// If this basic block is ONLY a setcc and a branch, and if a predecessor
185 /// branches to us and one of our successors, fold the setcc into the
186 /// predecessor and use logical operations to pick the right destination.
187 bool FoldBranchToCommonDest(BranchInst *BI, llvm::DomTreeUpdater *DTU = nullptr,
188  MemorySSAUpdater *MSSAU = nullptr,
189  const TargetTransformInfo *TTI = nullptr,
190  unsigned BonusInstThreshold = 1);
191
192 /// This function takes a virtual register computed by an Instruction and
193 /// replaces it with a slot in the stack frame, allocated via alloca.
194 /// This allows the CFG to be changed around without fear of invalidating the
195 /// SSA information for the value. It returns the pointer to the alloca inserted
196 /// to create a stack slot for X.
197 AllocaInst *DemoteRegToStack(Instruction &X,
199  Instruction *AllocaPoint = nullptr);
200
201 /// This function takes a virtual register computed by a phi node and replaces
202 /// it with a slot in the stack frame, allocated via alloca. The phi node is
203 /// deleted and it returns the pointer to the alloca inserted.
204 AllocaInst *DemotePHIToStack(PHINode *P, Instruction *AllocaPoint = nullptr);
205
206 /// Try to ensure that the alignment of \p V is at least \p PrefAlign bytes. If
207 /// the owning object can be modified and has an alignment less than \p
208 /// PrefAlign, it will be increased and \p PrefAlign returned. If the alignment
209 /// cannot be increased, the known alignment of the value is returned.
210 ///
211 /// It is not always possible to modify the alignment of the underlying object,
212 /// so if alignment is important, a more reliable approach is to simply align
213 /// all global variables and allocation instructions to their preferred
214 /// alignment from the beginning.
215 Align getOrEnforceKnownAlignment(Value *V, MaybeAlign PrefAlign,
216  const DataLayout &DL,
217  const Instruction *CxtI = nullptr,
218  AssumptionCache *AC = nullptr,
219  const DominatorTree *DT = nullptr);
220
221 /// Try to infer an alignment for the specified pointer.
223  const Instruction *CxtI = nullptr,
224  AssumptionCache *AC = nullptr,
225  const DominatorTree *DT = nullptr) {
226  return getOrEnforceKnownAlignment(V, MaybeAlign(), DL, CxtI, AC, DT);
227 }
228
229 /// Create a call that matches the invoke \p II in terms of arguments,
230 /// attributes, debug information, etc. The call is not placed in a block and it
231 /// will not have a name. The invoke instruction is not removed, nor are the
232 /// uses replaced by the new call.
233 CallInst *createCallMatchingInvoke(InvokeInst *II);
234
235 /// This function converts the specified invoek into a normall call.
236 CallInst *changeToCall(InvokeInst *II, DomTreeUpdater *DTU = nullptr);
237
238 ///===---------------------------------------------------------------------===//
239 /// Dbg Intrinsic utilities
240 ///
241
242 /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value
243 /// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
244 void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
245  StoreInst *SI, DIBuilder &Builder);
246
247 /// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value
248 /// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
249 void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
251
252 /// Inserts a llvm.dbg.value intrinsic after a phi that has an associated
253 /// llvm.dbg.declare or llvm.dbg.addr intrinsic.
254 void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
255  PHINode *LI, DIBuilder &Builder);
256
257 /// Lowers llvm.dbg.declare intrinsics into appropriate set of
258 /// llvm.dbg.value intrinsics.
259 bool LowerDbgDeclare(Function &F);
260
261 /// Propagate dbg.value intrinsics through the newly inserted PHIs.
263  SmallVectorImpl<PHINode *> &InsertedPHIs);
264
265 /// Replaces llvm.dbg.declare instruction when the address it
266 /// describes is replaced with a new value. If Deref is true, an
267 /// additional DW_OP_deref is prepended to the expression. If Offset
268 /// is non-zero, a constant displacement is added to the expression
269 /// (between the optional Deref operations). Offset can be negative.
271  uint8_t DIExprFlags, int Offset);
272
273 /// Replaces multiple llvm.dbg.value instructions when the alloca it describes
274 /// is replaced with a new value. If Offset is non-zero, a constant displacement
275 /// is added to the expression (after the mandatory Deref). Offset can be
276 /// negative. New llvm.dbg.value instructions are inserted at the locations of
277 /// the instructions they replace.
278 void replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
279  DIBuilder &Builder, int Offset = 0);
280
281 /// Assuming the instruction \p I is going to be deleted, attempt to salvage
282 /// debug users of \p I by writing the effect of \p I in a DIExpression. If it
283 /// cannot be salvaged changes its debug uses to undef.
284 void salvageDebugInfo(Instruction &I);
285
286
287 /// Implementation of salvageDebugInfo, applying only to instructions in
288 /// \p Insns, rather than all debug users from findDbgUsers( \p I).
289 /// Mark undef if salvaging cannot be completed.
290 void salvageDebugInfoForDbgValues(Instruction &I,
291  ArrayRef<DbgVariableIntrinsic *> Insns);
292
293 /// Given an instruction \p I and DIExpression \p DIExpr operating on
294 /// it, append the effects of \p I to the DIExpression operand list
295 /// \p Ops, or return \p nullptr if it cannot be salvaged.
296 /// \p CurrentLocOps is the number of SSA values referenced by the
297 /// incoming \p Ops. \return the first non-constant operand
298 /// implicitly referred to by Ops. If \p I references more than one
301 ///
302 /// \example
303 ////
304 /// I = add %a, i32 1
305 ///
306 /// Return = %a
307 /// Ops = llvm::dwarf::DW_OP_lit1 llvm::dwarf::DW_OP_add
308 ///
309 /// I = add %a, %b
310 ///
311 /// Return = %a
312 /// Ops = llvm::dwarf::DW_OP_LLVM_arg0 llvm::dwarf::DW_OP_add
314 Value *salvageDebugInfoImpl(Instruction &I, uint64_t CurrentLocOps,
315  SmallVectorImpl<uint64_t> &Ops,
317
318 /// Point debug users of \p From to \p To or salvage them. Use this function
319 /// only when replacing all uses of \p From with \p To, with a guarantee that
320 /// \p From is going to be deleted.
321 ///
322 /// Follow these rules to prevent use-before-def of \p To:
323 /// . If \p To is a linked Instruction, set \p DomPoint to \p To.
324 /// . If \p To is an unlinked Instruction, set \p DomPoint to the Instruction
325 /// \p To will be inserted after.
326 /// . If \p To is not an Instruction (e.g a Constant), the choice of
327 /// \p DomPoint is arbitrary. Pick \p From for simplicity.
328 ///
329 /// If a debug user cannot be preserved without reordering variable updates or
330 /// introducing a use-before-def, it is either salvaged (\ref salvageDebugInfo)
331 /// or deleted. Returns true if any debug users were updated.
332 bool replaceAllDbgUsesWith(Instruction &From, Value &To, Instruction &DomPoint,
333  DominatorTree &DT);
334
335 /// Remove all instructions from a basic block other than its terminator
336 /// and any present EH pad instructions. Returns a pair where the first element
337 /// is the number of instructions (excluding debug info intrinsics) that have
338 /// been removed, and the second element is the number of debug info intrinsics
339 /// that have been removed.
340 std::pair<unsigned, unsigned>
342
343 /// Insert an unreachable instruction before the specified
344 /// instruction, making it and the rest of the code in the block dead.
345 unsigned changeToUnreachable(Instruction *I, bool PreserveLCSSA = false,
346  DomTreeUpdater *DTU = nullptr,
347  MemorySSAUpdater *MSSAU = nullptr);
348
349 /// Convert the CallInst to InvokeInst with the specified unwind edge basic
350 /// block. This also splits the basic block where CI is located, because
351 /// InvokeInst is a terminator instruction. Returns the newly split basic
352 /// block.
354  BasicBlock *UnwindEdge,
355  DomTreeUpdater *DTU = nullptr);
356
357 /// Replace 'BB's terminator with one that does not have an unwind successor
358 /// block. Rewrites invoke to call, etc. Updates any PHIs in unwind
359 /// successor.
360 ///
361 /// \param BB Block whose terminator will be replaced. Its terminator must
362 /// have an unwind successor.
363 void removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU = nullptr);
364
365 /// Remove all blocks that can not be reached from the function's entry.
366 ///
367 /// Returns true if any basic block was removed.
368 bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU = nullptr,
369  MemorySSAUpdater *MSSAU = nullptr);
370
371 /// Combine the metadata of two instructions so that K can replace J. Some
372 /// metadata kinds can only be kept if K does not move, meaning it dominated
373 /// J in the original IR.
374 ///
375 /// Metadata not listed as known via KnownIDs is removed
376 void combineMetadata(Instruction *K, const Instruction *J,
377  ArrayRef<unsigned> KnownIDs, bool DoesKMove);
378
379 /// Combine the metadata of two instructions so that K can replace J. This
380 /// specifically handles the case of CSE-like transformations. Some
381 /// metadata can only be kept if K dominates J. For this to be correct,
382 /// K cannot be hoisted.
383 ///
384 /// Unknown metadata is removed.
385 void combineMetadataForCSE(Instruction *K, const Instruction *J,
386  bool DoesKMove);
387
388 /// Copy the metadata from the source instruction to the destination (the
389 /// replacement for the source instruction).
391
392 /// Patch the replacement so that it is not more restrictive than the value
393 /// being replaced. It assumes that the replacement does not get moved from
394 /// its original position.
395 void patchReplacementInstruction(Instruction *I, Value *Repl);
396
397 // Replace each use of 'From' with 'To', if that use does not belong to basic
398 // block where 'From' is defined. Returns the number of replacements made.
399 unsigned replaceNonLocalUsesWith(Instruction *From, Value *To);
400
401 /// Replace each use of 'From' with 'To' if that use is dominated by
402 /// the given edge. Returns the number of replacements made.
403 unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
404  const BasicBlockEdge &Edge);
405 /// Replace each use of 'From' with 'To' if that use is dominated by
406 /// the end of the given BasicBlock. Returns the number of replacements made.
407 unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
408  const BasicBlock *BB);
409
410 /// Return true if this call calls a gc leaf function.
411 ///
412 /// A leaf function is a function that does not safepoint the thread during its
413 /// execution. During a call or invoke to such a function, the callers stack
414 /// does not have to be made parseable.
415 ///
416 /// Most passes can and should ignore this information, and it is only used
417 /// during lowering by the GC infrastructure.
418 bool callsGCLeafFunction(const CallBase *Call, const TargetLibraryInfo &TLI);
419
420 /// Copy a nonnull metadata node to a new load instruction.
421 ///
422 /// This handles mapping it to range metadata if the new load is an integer
425
426 /// Copy a range metadata node to a new load instruction.
427 ///
428 /// This handles mapping it to nonnull metadata if the new load is a pointer
432
433 /// Remove the debug intrinsic instructions for the given instruction.
434 void dropDebugUsers(Instruction &I);
435
436 /// Hoist all of the instructions in the \p IfBlock to the dominant block
437 /// \p DomBlock, by moving its instructions to the insertion point \p InsertPt.
438 ///
439 /// The moved instructions receive the insertion point debug location values
440 /// (DILocations) and their debug intrinsic instructions are removed.
441 void hoistAllInstructionsInto(BasicBlock *DomBlock, Instruction *InsertPt,
442  BasicBlock *BB);
443
444 //===----------------------------------------------------------------------===//
445 // Intrinsic pattern matching
446 //
447
448 /// Try to match a bswap or bitreverse idiom.
449 ///
450 /// If an idiom is matched, an intrinsic call is inserted before \c I. Any added
451 /// instructions are returned in \c InsertedInsts. They will all have been added
452 /// to a basic block.
453 ///
454 /// A bitreverse idiom normally requires around 2*BW nodes to be searched (where
455 /// BW is the bitwidth of the integer type). A bswap idiom requires anywhere up
456 /// to BW / 4 nodes to be searched, so is significantly faster.
457 ///
458 /// This function returns true on a successful match or false otherwise.
460  Instruction *I, bool MatchBSwaps, bool MatchBitReversals,
461  SmallVectorImpl<Instruction *> &InsertedInsts);
462
463 //===----------------------------------------------------------------------===//
464 // Sanitizer utilities
465 //
466
467 /// Given a CallInst, check if it calls a string function known to CodeGen,
468 /// and mark it with NoBuiltin if so. To be used by sanitizers that intend
469 /// to intercept string functions and want to avoid converting them to target
470 /// specific instructions.
472  const TargetLibraryInfo *TLI);
473
474 //===----------------------------------------------------------------------===//
475 // Transform predicates
476 //
477
478 /// Given an instruction, is it legal to set operand OpIdx to a non-constant
479 /// value?
480 bool canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx);
481
482 //===----------------------------------------------------------------------===//
483 // Value helper functions
484 //
485
486 /// Invert the given true/false value, possibly reusing an existing copy.
487 Value *invertCondition(Value *Condition);
488
489
490 //===----------------------------------------------------------------------===//
491 // Assorted
492 //
493
494 /// If we can infer one attribute from another on the declaration of a
495 /// function, explicitly materialize the maximal set in the IR.
496 bool inferAttributesFromOthers(Function &F);
497
498 } // end namespace llvm
499
500 #endif // LLVM_TRANSFORMS_UTILS_LOCAL_H
llvm::invertCondition
Value * invertCondition(Value *Condition)
Invert the given true/false value, possibly reusing an existing copy.
Definition: Local.cpp:3403
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
If the specified value is a trivially dead instruction, delete it.
Definition: Local.cpp:518
void combineMetadata(Instruction *K, const Instruction *J, ArrayRef< unsigned > KnownIDs, bool DoesKMove)
Combine the metadata of two instructions so that K can replace J.
Definition: Local.cpp:2585
llvm
This is an optimization pass for GlobalISel generic memory operations.
llvm::ConvertDebugDeclareToDebugValue
void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, StoreInst *SI, DIBuilder &Builder)
===------------------------------------------------------------------—===// Dbg Intrinsic utilities
Definition: Local.cpp:1515
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::callsGCLeafFunction
bool callsGCLeafFunction(const CallBase *Call, const TargetLibraryInfo &TLI)
Return true if this call calls a gc leaf function.
Definition: Local.cpp:2813
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
llvm::replaceNonLocalUsesWith
unsigned replaceNonLocalUsesWith(Instruction *From, Value *To)
Definition: Local.cpp:2780
llvm::dropDebugUsers
void dropDebugUsers(Instruction &I)
Remove the debug intrinsic instructions for the given instruction.
Definition: Local.cpp:2885
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
llvm::removeUnreachableBlocks
bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Remove all blocks that can not be reached from the function's entry.
Definition: Local.cpp:2548
llvm::getOrEnforceKnownAlignment
Align getOrEnforceKnownAlignment(Value *V, MaybeAlign 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:1419
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:79
llvm::changeToCall
CallInst * changeToCall(InvokeInst *II, DomTreeUpdater *DTU=nullptr)
This function converts the specified invoek into a normall call.
Definition: Local.cpp:2250
void combineMetadataForCSE(Instruction *K, const Instruction *J, bool DoesKMove)
Combine the metadata of two instructions so that K can replace J.
Definition: Local.cpp:2666
F
#define F(x, y, z)
Definition: MD5.cpp:55
bool RecursivelyDeleteDeadPHINode(PHINode *PN, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=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:628
CommandLine.h
llvm::SimplifyInstructionsInBlock
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:708
llvm::DemotePHIToStack
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...
Definition: DemoteRegToStack.cpp:109
llvm::getKnownAlignment
Align 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:222
llvm::canReplaceOperandWithVariable
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:3330
llvm::FoldBranchToCommonDest
bool FoldBranchToCommonDest(BranchInst *BI, llvm::DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr, const TargetTransformInfo *TTI=nullptr, 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 ...
Definition: SimplifyCFG.cpp:3627
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
llvm::inferAttributesFromOthers
bool inferAttributesFromOthers(Function &F)
If we can infer one attribute from another on the declaration of a function, explicitly materialize t...
Definition: Local.cpp:3437
std::pair< unsigned, unsigned > removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB)
Remove all instructions from a basic block other than its terminator and any present EH pad instructi...
Definition: Local.cpp:2161
llvm::Instruction
Definition: Instruction.h:42
llvm::salvageDebugInfo
void salvageDebugInfo(const MachineRegisterInfo &MRI, MachineInstr &MI)
Assuming the instruction MI is going to be deleted, attempt to salvage debug users of MI by writing t...
Definition: Utils.cpp:1360
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
Definition: Local.cpp:2867
llvm::DomTreeUpdater
Definition: DomTreeUpdater.h:28
Align
uint64_t Align
Definition: ELFObjHandler.cpp:81
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MCID::Call
@ Call
Definition: MCInstrDesc.h:155
X
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:414
Definition: Local.cpp:2842
Copy the metadata from the source instruction to the destination (the replacement for the source inst...
Definition: Local.cpp:2679
llvm::removeUnwindEdge
void removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU=nullptr)
Replace 'BB's terminator with one that does not have an unwind successor block.
Definition: Local.cpp:2509
llvm::TryToSimplifyUncondBranchFromEmptyBlock
bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB, DomTreeUpdater *DTU=nullptr)
BB is known to contain an unconditional branch, and contains no instructions other than PHI nodes,...
Definition: Local.cpp:1053
uint64_t
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::insertDebugValuesForPHIs
void insertDebugValuesForPHIs(BasicBlock *BB, SmallVectorImpl< PHINode * > &InsertedPHIs)
Propagate dbg.value intrinsics through the newly inserted PHIs.
Definition: Local.cpp:1688
ArrayRef.h
llvm::hoistAllInstructionsInto
void hoistAllInstructionsInto(BasicBlock *DomBlock, Instruction *InsertPt, BasicBlock *BB)
Hoist all of the instructions in the IfBlock to the dominant block DomBlock, by moving its instructio...
Definition: Local.cpp:2892
llvm::salvageDebugInfoForDbgValues
void salvageDebugInfoForDbgValues(Instruction &I, ArrayRef< DbgVariableIntrinsic * > Insns)
Implementation of salvageDebugInfo, applying only to instructions in Insns, rather than all debug use...
Definition: Local.cpp:1808
SI
StandardInstrumentations SI(Debug, VerifyEach)
bool wouldInstructionBeTriviallyDeadOnUnusedPaths(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction has no side effects on any paths other than whe...
Definition: Local.cpp:402
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
llvm::TTI
TargetTransformInfo TTI
Definition: TargetTransformInfo.h:167
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
llvm::replaceDominatedUsesWith
unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT, const BasicBlockEdge &Edge)
Replace each use of 'From' with 'To' if that use is dominated by the given edge.
Definition: Local.cpp:2795
llvm::replaceAllDbgUsesWith
bool replaceAllDbgUsesWith(Instruction &From, Value &To, Instruction &DomPoint, DominatorTree &DT)
Point debug users of From to To or salvage them.
Definition: Local.cpp:2106
llvm::changeToInvokeAndSplitBasicBlock
BasicBlock * changeToInvokeAndSplitBasicBlock(CallInst *CI, BasicBlock *UnwindEdge, DomTreeUpdater *DTU=nullptr)
Convert the CallInst to InvokeInst with the specified unwind edge basic block.
Definition: Local.cpp:2270
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::simplifyCFG
bool simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI, DomTreeUpdater *DTU=nullptr, const SimplifyCFGOptions &Options={}, ArrayRef< WeakVH > LoopHeaders={})
Definition: SimplifyCFG.cpp:7258
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:98
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction will return.
Definition: Local.cpp:395
llvm::AssumptionCache
A cache of @llvm.assume calls within a function.
Definition: AssumptionCache.h:42
llvm::FlattenCFG
bool FlattenCFG(BasicBlock *BB, AAResults *AA=nullptr)
This function is used to flatten a CFG.
Definition: FlattenCFG.cpp:548
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::recognizeBSwapOrBitReverseIdiom
bool recognizeBSwapOrBitReverseIdiom(Instruction *I, bool MatchBSwaps, bool MatchBitReversals, SmallVectorImpl< Instruction * > &InsertedInsts)
Try to match a bswap or bitreverse idiom.
Definition: Local.cpp:3219
llvm::DemoteRegToStack
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 ...
Definition: DemoteRegToStack.cpp:22
llvm::maybeMarkSanitizerLibraryCallNoBuiltin
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:3320
llvm::RequireAndPreserveDomTree
cl::opt< bool > RequireAndPreserveDomTree
This function is used to do simplification of a CFG.
llvm::replaceDbgValueForAlloca
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:1791
llvm::EliminateDuplicatePHINodes
bool EliminateDuplicatePHINodes(BasicBlock *BB)
Check for and eliminate duplicate PHI nodes in this block.
Definition: Local.cpp:1360
llvm::ConstantFoldTerminator
bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions=false, const TargetLibraryInfo *TLI=nullptr, DomTreeUpdater *DTU=nullptr)
If a terminator instruction is predicated on a constant value, convert it into an unconditional branc...
Definition: Local.cpp:125
llvm::salvageDebugInfoImpl
Value * salvageDebugInfoImpl(Instruction &I, uint64_t CurrentLocOps, SmallVectorImpl< uint64_t > &Ops, SmallVectorImpl< Value * > &AdditionalValues)
Definition: Local.cpp:1974
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::LowerDbgDeclare
bool LowerDbgDeclare(Function &F)
Lowers llvm.dbg.declare intrinsics into appropriate set of llvm.dbg.value intrinsics.
Definition: Local.cpp:1614
llvm::replaceDbgUsesWithUndef
bool replaceDbgUsesWithUndef(Instruction *I)
Replace all the uses of an SSA value in @llvm.dbg intrinsics with undef.
Definition: Local.cpp:595
SimplifyCFGOptions.h
AA
llvm::changeToUnreachable
unsigned changeToUnreachable(Instruction *I, bool PreserveLCSSA=false, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Insert an unreachable instruction before the specified instruction, making it and the rest of the cod...
Definition: Local.cpp:2185
Dominators.h
N
#define N
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
llvm::createCallMatchingInvoke
CallInst * createCallMatchingInvoke(InvokeInst *II)
Create a call that matches the invoke II in terms of arguments, attributes, debug information,...
Definition: Local.cpp:2224
llvm::patchReplacementInstruction
void patchReplacementInstruction(Instruction *I, Value *Repl)
Patch the replacement so that it is not more restrictive than the value being replaced.
Definition: Local.cpp:2730
llvm::MergeBasicBlockIntoOnlyPred
void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, DomTreeUpdater *DTU=nullptr)
BB is a block with one predecessor and its predecessor is known to have one successor (BB!...
Definition: Local.cpp:748
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::replaceDbgDeclare