Local.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- Local.h - Functions to perform local transformations -----*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This family of functions perform various local transformations to the
  15. // program.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_TRANSFORMS_UTILS_LOCAL_H
  19. #define LLVM_TRANSFORMS_UTILS_LOCAL_H
  20. #include "llvm/ADT/ArrayRef.h"
  21. #include "llvm/IR/Dominators.h"
  22. #include "llvm/Support/CommandLine.h"
  23. #include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
  24. #include <cstdint>
  25. namespace llvm {
  26. class DataLayout;
  27. class Value;
  28. class WeakTrackingVH;
  29. class WeakVH;
  30. template <typename T> class SmallVectorImpl;
  31. class AAResults;
  32. class AllocaInst;
  33. class AssumptionCache;
  34. class BasicBlock;
  35. class BranchInst;
  36. class CallBase;
  37. class CallInst;
  38. class DbgVariableIntrinsic;
  39. class DIBuilder;
  40. class DomTreeUpdater;
  41. class Function;
  42. class Instruction;
  43. class InvokeInst;
  44. class LoadInst;
  45. class MDNode;
  46. class MemorySSAUpdater;
  47. class PHINode;
  48. class StoreInst;
  49. class TargetLibraryInfo;
  50. class TargetTransformInfo;
  51. //===----------------------------------------------------------------------===//
  52. // Local constant propagation.
  53. //
  54. /// If a terminator instruction is predicated on a constant value, convert it
  55. /// into an unconditional branch to the constant destination.
  56. /// This is a nontrivial operation because the successors of this basic block
  57. /// must have their PHI nodes updated.
  58. /// Also calls RecursivelyDeleteTriviallyDeadInstructions() on any branch/switch
  59. /// conditions and indirectbr addresses this might make dead if
  60. /// DeleteDeadConditions is true.
  61. bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions = false,
  62. const TargetLibraryInfo *TLI = nullptr,
  63. DomTreeUpdater *DTU = nullptr);
  64. //===----------------------------------------------------------------------===//
  65. // Local dead code elimination.
  66. //
  67. /// Return true if the result produced by the instruction is not used, and the
  68. /// instruction will return. Certain side-effecting instructions are also
  69. /// considered dead if there are no uses of the instruction.
  70. bool isInstructionTriviallyDead(Instruction *I,
  71. const TargetLibraryInfo *TLI = nullptr);
  72. /// Return true if the result produced by the instruction would have no side
  73. /// effects if it was not used. This is equivalent to checking whether
  74. /// isInstructionTriviallyDead would be true if the use count was 0.
  75. bool wouldInstructionBeTriviallyDead(Instruction *I,
  76. const TargetLibraryInfo *TLI = nullptr);
  77. /// Return true if the result produced by the instruction has no side effects on
  78. /// any paths other than where it is used. This is less conservative than
  79. /// wouldInstructionBeTriviallyDead which is based on the assumption
  80. /// that the use count will be 0. An example usage of this API is for
  81. /// identifying instructions that can be sunk down to use(s).
  82. bool wouldInstructionBeTriviallyDeadOnUnusedPaths(
  83. Instruction *I, const TargetLibraryInfo *TLI = nullptr);
  84. /// If the specified value is a trivially dead instruction, delete it.
  85. /// If that makes any of its operands trivially dead, delete them too,
  86. /// recursively. Return true if any instructions were deleted.
  87. bool RecursivelyDeleteTriviallyDeadInstructions(
  88. Value *V, const TargetLibraryInfo *TLI = nullptr,
  89. MemorySSAUpdater *MSSAU = nullptr,
  90. std::function<void(Value *)> AboutToDeleteCallback =
  91. std::function<void(Value *)>());
  92. /// Delete all of the instructions in `DeadInsts`, and all other instructions
  93. /// that deleting these in turn causes to be trivially dead.
  94. ///
  95. /// The initial instructions in the provided vector must all have empty use
  96. /// lists and satisfy `isInstructionTriviallyDead`.
  97. ///
  98. /// `DeadInsts` will be used as scratch storage for this routine and will be
  99. /// empty afterward.
  100. void RecursivelyDeleteTriviallyDeadInstructions(
  101. SmallVectorImpl<WeakTrackingVH> &DeadInsts,
  102. const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr,
  103. std::function<void(Value *)> AboutToDeleteCallback =
  104. std::function<void(Value *)>());
  105. /// Same functionality as RecursivelyDeleteTriviallyDeadInstructions, but allow
  106. /// instructions that are not trivially dead. These will be ignored.
  107. /// Returns true if any changes were made, i.e. any instructions trivially dead
  108. /// were found and deleted.
  109. bool RecursivelyDeleteTriviallyDeadInstructionsPermissive(
  110. SmallVectorImpl<WeakTrackingVH> &DeadInsts,
  111. const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr,
  112. std::function<void(Value *)> AboutToDeleteCallback =
  113. std::function<void(Value *)>());
  114. /// If the specified value is an effectively dead PHI node, due to being a
  115. /// def-use chain of single-use nodes that either forms a cycle or is terminated
  116. /// by a trivially dead instruction, delete it. If that makes any of its
  117. /// operands trivially dead, delete them too, recursively. Return true if a
  118. /// change was made.
  119. bool RecursivelyDeleteDeadPHINode(PHINode *PN,
  120. const TargetLibraryInfo *TLI = nullptr,
  121. MemorySSAUpdater *MSSAU = nullptr);
  122. /// Scan the specified basic block and try to simplify any instructions in it
  123. /// and recursively delete dead instructions.
  124. ///
  125. /// This returns true if it changed the code, note that it can delete
  126. /// instructions in other blocks as well in this block.
  127. bool SimplifyInstructionsInBlock(BasicBlock *BB,
  128. const TargetLibraryInfo *TLI = nullptr);
  129. /// Replace all the uses of an SSA value in @llvm.dbg intrinsics with
  130. /// undef. This is useful for signaling that a variable, e.g. has been
  131. /// found dead and hence it's unavailable at a given program point.
  132. /// Returns true if the dbg values have been changed.
  133. bool replaceDbgUsesWithUndef(Instruction *I);
  134. //===----------------------------------------------------------------------===//
  135. // Control Flow Graph Restructuring.
  136. //
  137. /// BB is a block with one predecessor and its predecessor is known to have one
  138. /// successor (BB!). Eliminate the edge between them, moving the instructions in
  139. /// the predecessor into BB. This deletes the predecessor block.
  140. void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, DomTreeUpdater *DTU = nullptr);
  141. /// BB is known to contain an unconditional branch, and contains no instructions
  142. /// other than PHI nodes, potential debug intrinsics and the branch. If
  143. /// possible, eliminate BB by rewriting all the predecessors to branch to the
  144. /// successor block and return true. If we can't transform, return false.
  145. bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
  146. DomTreeUpdater *DTU = nullptr);
  147. /// Check for and eliminate duplicate PHI nodes in this block. This doesn't try
  148. /// to be clever about PHI nodes which differ only in the order of the incoming
  149. /// values, but instcombine orders them so it usually won't matter.
  150. bool EliminateDuplicatePHINodes(BasicBlock *BB);
  151. /// This function is used to do simplification of a CFG. For example, it
  152. /// adjusts branches to branches to eliminate the extra hop, it eliminates
  153. /// unreachable basic blocks, and does other peephole optimization of the CFG.
  154. /// It returns true if a modification was made, possibly deleting the basic
  155. /// block that was pointed to. LoopHeaders is an optional input parameter
  156. /// providing the set of loop headers that SimplifyCFG should not eliminate.
  157. extern cl::opt<bool> RequireAndPreserveDomTree;
  158. bool simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
  159. DomTreeUpdater *DTU = nullptr,
  160. const SimplifyCFGOptions &Options = {},
  161. ArrayRef<WeakVH> LoopHeaders = {});
  162. /// This function is used to flatten a CFG. For example, it uses parallel-and
  163. /// and parallel-or mode to collapse if-conditions and merge if-regions with
  164. /// identical statements.
  165. bool FlattenCFG(BasicBlock *BB, AAResults *AA = nullptr);
  166. /// If this basic block is ONLY a setcc and a branch, and if a predecessor
  167. /// branches to us and one of our successors, fold the setcc into the
  168. /// predecessor and use logical operations to pick the right destination.
  169. bool FoldBranchToCommonDest(BranchInst *BI, llvm::DomTreeUpdater *DTU = nullptr,
  170. MemorySSAUpdater *MSSAU = nullptr,
  171. const TargetTransformInfo *TTI = nullptr,
  172. unsigned BonusInstThreshold = 1);
  173. /// This function takes a virtual register computed by an Instruction and
  174. /// replaces it with a slot in the stack frame, allocated via alloca.
  175. /// This allows the CFG to be changed around without fear of invalidating the
  176. /// SSA information for the value. It returns the pointer to the alloca inserted
  177. /// to create a stack slot for X.
  178. AllocaInst *DemoteRegToStack(Instruction &X,
  179. bool VolatileLoads = false,
  180. Instruction *AllocaPoint = nullptr);
  181. /// This function takes a virtual register computed by a phi node and replaces
  182. /// it with a slot in the stack frame, allocated via alloca. The phi node is
  183. /// deleted and it returns the pointer to the alloca inserted.
  184. AllocaInst *DemotePHIToStack(PHINode *P, Instruction *AllocaPoint = nullptr);
  185. /// Try to ensure that the alignment of \p V is at least \p PrefAlign bytes. If
  186. /// the owning object can be modified and has an alignment less than \p
  187. /// PrefAlign, it will be increased and \p PrefAlign returned. If the alignment
  188. /// cannot be increased, the known alignment of the value is returned.
  189. ///
  190. /// It is not always possible to modify the alignment of the underlying object,
  191. /// so if alignment is important, a more reliable approach is to simply align
  192. /// all global variables and allocation instructions to their preferred
  193. /// alignment from the beginning.
  194. Align getOrEnforceKnownAlignment(Value *V, MaybeAlign PrefAlign,
  195. const DataLayout &DL,
  196. const Instruction *CxtI = nullptr,
  197. AssumptionCache *AC = nullptr,
  198. const DominatorTree *DT = nullptr);
  199. /// Try to infer an alignment for the specified pointer.
  200. inline Align getKnownAlignment(Value *V, const DataLayout &DL,
  201. const Instruction *CxtI = nullptr,
  202. AssumptionCache *AC = nullptr,
  203. const DominatorTree *DT = nullptr) {
  204. return getOrEnforceKnownAlignment(V, MaybeAlign(), DL, CxtI, AC, DT);
  205. }
  206. /// Create a call that matches the invoke \p II in terms of arguments,
  207. /// attributes, debug information, etc. The call is not placed in a block and it
  208. /// will not have a name. The invoke instruction is not removed, nor are the
  209. /// uses replaced by the new call.
  210. CallInst *createCallMatchingInvoke(InvokeInst *II);
  211. /// This function converts the specified invoke into a normal call.
  212. CallInst *changeToCall(InvokeInst *II, DomTreeUpdater *DTU = nullptr);
  213. ///===---------------------------------------------------------------------===//
  214. /// Dbg Intrinsic utilities
  215. ///
  216. /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value
  217. /// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
  218. void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
  219. StoreInst *SI, DIBuilder &Builder);
  220. /// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value
  221. /// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
  222. void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
  223. LoadInst *LI, DIBuilder &Builder);
  224. /// Inserts a llvm.dbg.value intrinsic after a phi that has an associated
  225. /// llvm.dbg.declare or llvm.dbg.addr intrinsic.
  226. void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
  227. PHINode *LI, DIBuilder &Builder);
  228. /// Lowers llvm.dbg.declare intrinsics into appropriate set of
  229. /// llvm.dbg.value intrinsics.
  230. bool LowerDbgDeclare(Function &F);
  231. /// Propagate dbg.value intrinsics through the newly inserted PHIs.
  232. void insertDebugValuesForPHIs(BasicBlock *BB,
  233. SmallVectorImpl<PHINode *> &InsertedPHIs);
  234. /// Replaces llvm.dbg.declare instruction when the address it
  235. /// describes is replaced with a new value. If Deref is true, an
  236. /// additional DW_OP_deref is prepended to the expression. If Offset
  237. /// is non-zero, a constant displacement is added to the expression
  238. /// (between the optional Deref operations). Offset can be negative.
  239. bool replaceDbgDeclare(Value *Address, Value *NewAddress, DIBuilder &Builder,
  240. uint8_t DIExprFlags, int Offset);
  241. /// Replaces multiple llvm.dbg.value instructions when the alloca it describes
  242. /// is replaced with a new value. If Offset is non-zero, a constant displacement
  243. /// is added to the expression (after the mandatory Deref). Offset can be
  244. /// negative. New llvm.dbg.value instructions are inserted at the locations of
  245. /// the instructions they replace.
  246. void replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
  247. DIBuilder &Builder, int Offset = 0);
  248. /// Assuming the instruction \p I is going to be deleted, attempt to salvage
  249. /// debug users of \p I by writing the effect of \p I in a DIExpression. If it
  250. /// cannot be salvaged changes its debug uses to undef.
  251. void salvageDebugInfo(Instruction &I);
  252. /// Implementation of salvageDebugInfo, applying only to instructions in
  253. /// \p Insns, rather than all debug users from findDbgUsers( \p I).
  254. /// Mark undef if salvaging cannot be completed.
  255. void salvageDebugInfoForDbgValues(Instruction &I,
  256. ArrayRef<DbgVariableIntrinsic *> Insns);
  257. /// Given an instruction \p I and DIExpression \p DIExpr operating on
  258. /// it, append the effects of \p I to the DIExpression operand list
  259. /// \p Ops, or return \p nullptr if it cannot be salvaged.
  260. /// \p CurrentLocOps is the number of SSA values referenced by the
  261. /// incoming \p Ops. \return the first non-constant operand
  262. /// implicitly referred to by Ops. If \p I references more than one
  263. /// non-constant operand, any additional operands are added to
  264. /// \p AdditionalValues.
  265. ///
  266. /// \example
  267. ////
  268. /// I = add %a, i32 1
  269. ///
  270. /// Return = %a
  271. /// Ops = llvm::dwarf::DW_OP_lit1 llvm::dwarf::DW_OP_add
  272. ///
  273. /// I = add %a, %b
  274. ///
  275. /// Return = %a
  276. /// Ops = llvm::dwarf::DW_OP_LLVM_arg0 llvm::dwarf::DW_OP_add
  277. /// AdditionalValues = %b
  278. Value *salvageDebugInfoImpl(Instruction &I, uint64_t CurrentLocOps,
  279. SmallVectorImpl<uint64_t> &Ops,
  280. SmallVectorImpl<Value *> &AdditionalValues);
  281. /// Point debug users of \p From to \p To or salvage them. Use this function
  282. /// only when replacing all uses of \p From with \p To, with a guarantee that
  283. /// \p From is going to be deleted.
  284. ///
  285. /// Follow these rules to prevent use-before-def of \p To:
  286. /// . If \p To is a linked Instruction, set \p DomPoint to \p To.
  287. /// . If \p To is an unlinked Instruction, set \p DomPoint to the Instruction
  288. /// \p To will be inserted after.
  289. /// . If \p To is not an Instruction (e.g a Constant), the choice of
  290. /// \p DomPoint is arbitrary. Pick \p From for simplicity.
  291. ///
  292. /// If a debug user cannot be preserved without reordering variable updates or
  293. /// introducing a use-before-def, it is either salvaged (\ref salvageDebugInfo)
  294. /// or deleted. Returns true if any debug users were updated.
  295. bool replaceAllDbgUsesWith(Instruction &From, Value &To, Instruction &DomPoint,
  296. DominatorTree &DT);
  297. /// Remove all instructions from a basic block other than its terminator
  298. /// and any present EH pad instructions. Returns a pair where the first element
  299. /// is the number of instructions (excluding debug info intrinsics) that have
  300. /// been removed, and the second element is the number of debug info intrinsics
  301. /// that have been removed.
  302. std::pair<unsigned, unsigned>
  303. removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB);
  304. /// Insert an unreachable instruction before the specified
  305. /// instruction, making it and the rest of the code in the block dead.
  306. unsigned changeToUnreachable(Instruction *I, bool PreserveLCSSA = false,
  307. DomTreeUpdater *DTU = nullptr,
  308. MemorySSAUpdater *MSSAU = nullptr);
  309. /// Convert the CallInst to InvokeInst with the specified unwind edge basic
  310. /// block. This also splits the basic block where CI is located, because
  311. /// InvokeInst is a terminator instruction. Returns the newly split basic
  312. /// block.
  313. BasicBlock *changeToInvokeAndSplitBasicBlock(CallInst *CI,
  314. BasicBlock *UnwindEdge,
  315. DomTreeUpdater *DTU = nullptr);
  316. /// Replace 'BB's terminator with one that does not have an unwind successor
  317. /// block. Rewrites `invoke` to `call`, etc. Updates any PHIs in unwind
  318. /// successor. Returns the instruction that replaced the original terminator,
  319. /// which might be a call in case the original terminator was an invoke.
  320. ///
  321. /// \param BB Block whose terminator will be replaced. Its terminator must
  322. /// have an unwind successor.
  323. Instruction *removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU = nullptr);
  324. /// Remove all blocks that can not be reached from the function's entry.
  325. ///
  326. /// Returns true if any basic block was removed.
  327. bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU = nullptr,
  328. MemorySSAUpdater *MSSAU = nullptr);
  329. /// Combine the metadata of two instructions so that K can replace J. Some
  330. /// metadata kinds can only be kept if K does not move, meaning it dominated
  331. /// J in the original IR.
  332. ///
  333. /// Metadata not listed as known via KnownIDs is removed
  334. void combineMetadata(Instruction *K, const Instruction *J,
  335. ArrayRef<unsigned> KnownIDs, bool DoesKMove);
  336. /// Combine the metadata of two instructions so that K can replace J. This
  337. /// specifically handles the case of CSE-like transformations. Some
  338. /// metadata can only be kept if K dominates J. For this to be correct,
  339. /// K cannot be hoisted.
  340. ///
  341. /// Unknown metadata is removed.
  342. void combineMetadataForCSE(Instruction *K, const Instruction *J,
  343. bool DoesKMove);
  344. /// Copy the metadata from the source instruction to the destination (the
  345. /// replacement for the source instruction).
  346. void copyMetadataForLoad(LoadInst &Dest, const LoadInst &Source);
  347. /// Patch the replacement so that it is not more restrictive than the value
  348. /// being replaced. It assumes that the replacement does not get moved from
  349. /// its original position.
  350. void patchReplacementInstruction(Instruction *I, Value *Repl);
  351. // Replace each use of 'From' with 'To', if that use does not belong to basic
  352. // block where 'From' is defined. Returns the number of replacements made.
  353. unsigned replaceNonLocalUsesWith(Instruction *From, Value *To);
  354. /// Replace each use of 'From' with 'To' if that use is dominated by
  355. /// the given edge. Returns the number of replacements made.
  356. unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
  357. const BasicBlockEdge &Edge);
  358. /// Replace each use of 'From' with 'To' if that use is dominated by
  359. /// the end of the given BasicBlock. Returns the number of replacements made.
  360. unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
  361. const BasicBlock *BB);
  362. /// Return true if this call calls a gc leaf function.
  363. ///
  364. /// A leaf function is a function that does not safepoint the thread during its
  365. /// execution. During a call or invoke to such a function, the callers stack
  366. /// does not have to be made parseable.
  367. ///
  368. /// Most passes can and should ignore this information, and it is only used
  369. /// during lowering by the GC infrastructure.
  370. bool callsGCLeafFunction(const CallBase *Call, const TargetLibraryInfo &TLI);
  371. /// Copy a nonnull metadata node to a new load instruction.
  372. ///
  373. /// This handles mapping it to range metadata if the new load is an integer
  374. /// load instead of a pointer load.
  375. void copyNonnullMetadata(const LoadInst &OldLI, MDNode *N, LoadInst &NewLI);
  376. /// Copy a range metadata node to a new load instruction.
  377. ///
  378. /// This handles mapping it to nonnull metadata if the new load is a pointer
  379. /// load instead of an integer load and the range doesn't cover null.
  380. void copyRangeMetadata(const DataLayout &DL, const LoadInst &OldLI, MDNode *N,
  381. LoadInst &NewLI);
  382. /// Remove the debug intrinsic instructions for the given instruction.
  383. void dropDebugUsers(Instruction &I);
  384. /// Hoist all of the instructions in the \p IfBlock to the dominant block
  385. /// \p DomBlock, by moving its instructions to the insertion point \p InsertPt.
  386. ///
  387. /// The moved instructions receive the insertion point debug location values
  388. /// (DILocations) and their debug intrinsic instructions are removed.
  389. void hoistAllInstructionsInto(BasicBlock *DomBlock, Instruction *InsertPt,
  390. BasicBlock *BB);
  391. //===----------------------------------------------------------------------===//
  392. // Intrinsic pattern matching
  393. //
  394. /// Try to match a bswap or bitreverse idiom.
  395. ///
  396. /// If an idiom is matched, an intrinsic call is inserted before \c I. Any added
  397. /// instructions are returned in \c InsertedInsts. They will all have been added
  398. /// to a basic block.
  399. ///
  400. /// A bitreverse idiom normally requires around 2*BW nodes to be searched (where
  401. /// BW is the bitwidth of the integer type). A bswap idiom requires anywhere up
  402. /// to BW / 4 nodes to be searched, so is significantly faster.
  403. ///
  404. /// This function returns true on a successful match or false otherwise.
  405. bool recognizeBSwapOrBitReverseIdiom(
  406. Instruction *I, bool MatchBSwaps, bool MatchBitReversals,
  407. SmallVectorImpl<Instruction *> &InsertedInsts);
  408. //===----------------------------------------------------------------------===//
  409. // Sanitizer utilities
  410. //
  411. /// Given a CallInst, check if it calls a string function known to CodeGen,
  412. /// and mark it with NoBuiltin if so. To be used by sanitizers that intend
  413. /// to intercept string functions and want to avoid converting them to target
  414. /// specific instructions.
  415. void maybeMarkSanitizerLibraryCallNoBuiltin(CallInst *CI,
  416. const TargetLibraryInfo *TLI);
  417. //===----------------------------------------------------------------------===//
  418. // Transform predicates
  419. //
  420. /// Given an instruction, is it legal to set operand OpIdx to a non-constant
  421. /// value?
  422. bool canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx);
  423. //===----------------------------------------------------------------------===//
  424. // Value helper functions
  425. //
  426. /// Invert the given true/false value, possibly reusing an existing copy.
  427. Value *invertCondition(Value *Condition);
  428. //===----------------------------------------------------------------------===//
  429. // Assorted
  430. //
  431. /// If we can infer one attribute from another on the declaration of a
  432. /// function, explicitly materialize the maximal set in the IR.
  433. bool inferAttributesFromOthers(Function &F);
  434. } // end namespace llvm
  435. #endif // LLVM_TRANSFORMS_UTILS_LOCAL_H
  436. #ifdef __GNUC__
  437. #pragma GCC diagnostic pop
  438. #endif