LLVM 17.0.0git
AssumeBundleBuilder.h
Go to the documentation of this file.
1//===- AssumeBundleBuilder.h - utils to build assume bundles ----*- 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 file contain tools to preserve informations. They should be used before
10// performing a transformation that may move and delete instructions as those
11// transformation may destroy or worsen information that can be derived from the
12// IR.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_TRANSFORMS_UTILS_ASSUMEBUNDLEBUILDER_H
17#define LLVM_TRANSFORMS_UTILS_ASSUMEBUNDLEBUILDER_H
18
20#include "llvm/IR/PassManager.h"
21
22namespace llvm {
23class AssumeInst;
24class Function;
25class FunctionPass;
26class Instruction;
27class AssumptionCache;
28class DominatorTree;
29
30/// Build a call to llvm.assume to preserve informations that can be derived
31/// from the given instruction.
32/// If no information derived from \p I, this call returns null.
33/// The returned instruction is not inserted anywhere.
34AssumeInst *buildAssumeFromInst(Instruction *I);
35
36/// Calls BuildAssumeFromInst and if the resulting llvm.assume is valid insert
37/// if before I. This is usually what need to be done to salvage the knowledge
38/// contained in the instruction I.
39/// The AssumptionCache must be provided if it is available or the cache may
40/// become silently be invalid.
41/// The DominatorTree can optionally be provided to enable cross-block
42/// reasoning.
43/// This returns if a change was made.
44bool salvageKnowledge(Instruction *I, AssumptionCache *AC = nullptr,
45 DominatorTree *DT = nullptr);
46
47/// Build and return a new assume created from the provided knowledge
48/// if the knowledge in the assume is fully redundant this will return nullptr
49AssumeInst *buildAssumeFromKnowledge(ArrayRef<RetainedKnowledge> Knowledge,
50 Instruction *CtxI,
51 AssumptionCache *AC = nullptr,
52 DominatorTree *DT = nullptr);
53
54/// This pass attempts to minimize the number of assume without loosing any
55/// information.
56struct AssumeSimplifyPass : public PassInfoMixin<AssumeSimplifyPass> {
58};
59
61
62/// This pass will try to build an llvm.assume for every instruction in the
63/// function. Its main purpose is testing.
64struct AssumeBuilderPass : public PassInfoMixin<AssumeBuilderPass> {
66};
67
68/// canonicalize the RetainedKnowledge RK. it is assumed that RK is part of
69/// Assume. This will return an empty RetainedKnowledge if the knowledge is
70/// useless.
74 DominatorTree *DT);
75
76} // namespace llvm
77
78#endif
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This header defines various interfaces for pass management in LLVM.
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:620
This represents the llvm.assume intrinsic.
A cache of @llvm.assume calls within a function.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:311
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
RetainedKnowledge simplifyRetainedKnowledge(AssumeInst *Assume, RetainedKnowledge RK, AssumptionCache *AC, DominatorTree *DT)
canonicalize the RetainedKnowledge RK.
AssumeInst * buildAssumeFromKnowledge(ArrayRef< RetainedKnowledge > Knowledge, Instruction *CtxI, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Build and return a new assume created from the provided knowledge if the knowledge in the assume is f...
bool salvageKnowledge(Instruction *I, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Calls BuildAssumeFromInst and if the resulting llvm.assume is valid insert if before I.
FunctionPass * createAssumeSimplifyPass()
AssumeInst * buildAssumeFromInst(Instruction *I)
Build a call to llvm.assume to preserve informations that can be derived from the given instruction.
This pass will try to build an llvm.assume for every instruction in the function.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
This pass attempts to minimize the number of assume without loosing any information.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:371
Represent one information held inside an operand bundle of an llvm.assume.