LLVM  14.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/Attributes.h"
21 #include "llvm/IR/Instruction.h"
22 #include "llvm/IR/PassManager.h"
23 
24 namespace llvm {
25 class IntrinsicInst;
26 class AssumptionCache;
27 class DominatorTree;
28 
29 /// Build a call to llvm.assume to preserve informations that can be derived
30 /// from the given instruction.
31 /// If no information derived from \p I, this call returns null.
32 /// The returned instruction is not inserted anywhere.
33 AssumeInst *buildAssumeFromInst(Instruction *I);
34 
35 /// Calls BuildAssumeFromInst and if the resulting llvm.assume is valid insert
36 /// if before I. This is usually what need to be done to salvage the knowledge
37 /// contained in the instruction I.
38 /// The AssumptionCache must be provided if it is available or the cache may
39 /// become silently be invalid.
40 /// The DominatorTree can optionally be provided to enable cross-block
41 /// reasoning.
42 void salvageKnowledge(Instruction *I, AssumptionCache *AC = nullptr,
43  DominatorTree *DT = nullptr);
44 
45 /// Build and return a new assume created from the provided knowledge
46 /// if the knowledge in the assume is fully redundant this will return nullptr
47 AssumeInst *buildAssumeFromKnowledge(ArrayRef<RetainedKnowledge> Knowledge,
48  Instruction *CtxI,
49  AssumptionCache *AC = nullptr,
50  DominatorTree *DT = nullptr);
51 
52 /// This pass attempts to minimize the number of assume without loosing any
53 /// information.
54 struct AssumeSimplifyPass : public PassInfoMixin<AssumeSimplifyPass> {
56 };
57 
59 
60 /// This pass will try to build an llvm.assume for every instruction in the
61 /// function. Its main purpose is testing.
62 struct AssumeBuilderPass : public PassInfoMixin<AssumeBuilderPass> {
64 };
65 
66 /// canonicalize the RetainedKnowledge RK. it is assumed that RK is part of
67 /// Assume. This will return an empty RetainedKnowledge if the knowledge is
68 /// useless.
71  AssumptionCache *AC,
72  DominatorTree *DT);
73 
74 } // namespace llvm
75 
76 #endif
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm::createAssumeSimplifyPass
FunctionPass * createAssumeSimplifyPass()
Definition: AssumeBundleBuilder.cpp:605
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:374
llvm::Function
Definition: Function.h:61
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:151
llvm::AssumeInst
This represents the llvm.assume intrinsic.
Definition: IntrinsicInst.h:1319
llvm::simplifyRetainedKnowledge
RetainedKnowledge simplifyRetainedKnowledge(AssumeInst *Assume, RetainedKnowledge RK, AssumptionCache *AC, DominatorTree *DT)
canonicalize the RetainedKnowledge RK.
Definition: AssumeBundleBuilder.cpp:315
F
#define F(x, y, z)
Definition: MD5.cpp:56
Instruction.h
llvm::AssumeSimplifyPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: AssumeBundleBuilder.cpp:561
AssumeBundleQueries.h
llvm::buildAssumeFromInst
AssumeInst * buildAssumeFromInst(Instruction *I)
Build a call to llvm.assume to preserve informations that can be derived from the given instruction.
Definition: AssumeBundleBuilder.cpp:284
llvm::AssumeBuilderPass
This pass will try to build an llvm.assume for every instruction in the function.
Definition: AssumeBundleBuilder.h:62
llvm::AssumeBuilderPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: AssumeBundleBuilder.cpp:609
llvm::AssumeSimplifyPass
This pass attempts to minimize the number of assume without loosing any information.
Definition: AssumeBundleBuilder.h:54
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::salvageKnowledge
void salvageKnowledge(Instruction *I, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Calls BuildAssumeFromInst and if the resulting llvm.assume is valid insert if before I.
Definition: AssumeBundleBuilder.cpp:292
llvm::AssumptionCache
A cache of @llvm.assume calls within a function.
Definition: AssumptionCache.h:41
llvm::RetainedKnowledge
Represent one information held inside an operand bundle of an llvm.assume.
Definition: AssumeBundleQueries.h:101
Attributes.h
PassManager.h
llvm::buildAssumeFromKnowledge
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...
Definition: AssumeBundleBuilder.cpp:306
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298