LLVM 23.0.0git
CodeMoverUtils.h
Go to the documentation of this file.
1//===- Transform/Utils/CodeMoverUtils.h - CodeMover Utils -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This family of functions determine movements are safe on basic blocks, and
10// instructions contained within a function.
11//
12// Please note that this is work in progress, and the functionality is not
13// ready for broader production use.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_TRANSFORMS_UTILS_CODEMOVERUTILS_H
18#define LLVM_TRANSFORMS_UTILS_CODEMOVERUTILS_H
19
21
22namespace llvm {
23
24class BasicBlock;
25class DependenceInfo;
26class DominatorTree;
27class Instruction;
29class ScalarEvolution;
30
31/// Return true if \p I can be safely moved before \p InsertPoint.
33 DominatorTree &DT,
34 const PostDominatorTree *PDT = nullptr,
35 DependenceInfo *DI = nullptr,
36 bool CheckForEntireBlock = false);
37
38/// Return true if all instructions (except the terminator) in \p BB can be
39/// safely moved before \p InsertPoint.
41 DominatorTree &DT,
42 const PostDominatorTree *PDT = nullptr,
43 DependenceInfo *DI = nullptr);
44
45/// Move instructions, in an order-preserving manner, from \p FromBB to the
46/// beginning of \p ToBB when proven safe.
47LLVM_ABI void
49 DominatorTree &DT, const PostDominatorTree &PDT,
51/// Move instructions, in an order-preserving manner, from \p FromBB to the end
52/// of \p ToBB when proven safe.
54 DominatorTree &DT,
55 const PostDominatorTree &PDT,
57
58/// In case that two BBs \p ThisBlock and \p OtherBlock are control flow
59/// equivalent but they do not strictly dominate and post-dominate each
60/// other, we determine if \p ThisBlock is reached after \p OtherBlock
61/// in the control flow.
62LLVM_ABI bool nonStrictlyPostDominate(const BasicBlock *ThisBlock,
63 const BasicBlock *OtherBlock,
64 const DominatorTree *DT,
65 const PostDominatorTree *PDT);
66
67// Check if I0 is reached before I1 in the control flow.
68LLVM_ABI bool isReachedBefore(const Instruction *I0, const Instruction *I1,
69 const DominatorTree *DT,
70 const PostDominatorTree *PDT);
71
72} // end namespace llvm
73
74#endif // LLVM_TRANSFORMS_UTILS_CODEMOVERUTILS_H
#define LLVM_ABI
Definition Compiler.h:213
#define I(x, y, z)
Definition MD5.cpp:57
LLVM Basic Block Representation.
Definition BasicBlock.h:62
DependenceInfo - This class is the main dependence-analysis driver.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:159
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
The main scalar evolution driver.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void moveInstructionsToTheEnd(BasicBlock &FromBB, BasicBlock &ToBB, DominatorTree &DT, const PostDominatorTree &PDT, DependenceInfo &DI, ScalarEvolution &SE)
Move instructions, in an order-preserving manner, from FromBB to the end of ToBB when proven safe.
LLVM_ABI void moveInstructionsToTheBeginning(BasicBlock &FromBB, BasicBlock &ToBB, DominatorTree &DT, const PostDominatorTree &PDT, DependenceInfo &DI, ScalarEvolution &SE)
Move instructions, in an order-preserving manner, from FromBB to the beginning of ToBB when proven sa...
LLVM_ABI bool isReachedBefore(const Instruction *I0, const Instruction *I1, const DominatorTree *DT, const PostDominatorTree *PDT)
LLVM_ABI bool nonStrictlyPostDominate(const BasicBlock *ThisBlock, const BasicBlock *OtherBlock, const DominatorTree *DT, const PostDominatorTree *PDT)
In case that two BBs ThisBlock and OtherBlock are control flow equivalent but they do not strictly do...
LLVM_ABI bool isSafeToMoveBefore(Instruction &I, Instruction &InsertPoint, DominatorTree &DT, const PostDominatorTree *PDT=nullptr, DependenceInfo *DI=nullptr, bool CheckForEntireBlock=false)
Return true if I can be safely moved before InsertPoint.