Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 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 | |||
19 | #include "llvm/Analysis/AssumeBundleQueries.h" |
||
20 | #include "llvm/IR/PassManager.h" |
||
21 | |||
22 | namespace llvm { |
||
23 | class AssumeInst; |
||
24 | class Function; |
||
25 | class FunctionPass; |
||
26 | class Instruction; |
||
27 | class AssumptionCache; |
||
28 | class 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. |
||
34 | AssumeInst *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 | void salvageKnowledge(Instruction *I, AssumptionCache *AC = nullptr, |
||
44 | DominatorTree *DT = nullptr); |
||
45 | |||
46 | /// Build and return a new assume created from the provided knowledge |
||
47 | /// if the knowledge in the assume is fully redundant this will return nullptr |
||
48 | AssumeInst *buildAssumeFromKnowledge(ArrayRef<RetainedKnowledge> Knowledge, |
||
49 | Instruction *CtxI, |
||
50 | AssumptionCache *AC = nullptr, |
||
51 | DominatorTree *DT = nullptr); |
||
52 | |||
53 | /// This pass attempts to minimize the number of assume without loosing any |
||
54 | /// information. |
||
55 | struct AssumeSimplifyPass : public PassInfoMixin<AssumeSimplifyPass> { |
||
56 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
||
57 | }; |
||
58 | |||
59 | FunctionPass *createAssumeSimplifyPass(); |
||
60 | |||
61 | /// This pass will try to build an llvm.assume for every instruction in the |
||
62 | /// function. Its main purpose is testing. |
||
63 | struct AssumeBuilderPass : public PassInfoMixin<AssumeBuilderPass> { |
||
64 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
||
65 | }; |
||
66 | |||
67 | /// canonicalize the RetainedKnowledge RK. it is assumed that RK is part of |
||
68 | /// Assume. This will return an empty RetainedKnowledge if the knowledge is |
||
69 | /// useless. |
||
70 | RetainedKnowledge simplifyRetainedKnowledge(AssumeInst *Assume, |
||
71 | RetainedKnowledge RK, |
||
72 | AssumptionCache *AC, |
||
73 | DominatorTree *DT); |
||
74 | |||
75 | } // namespace llvm |
||
76 | |||
77 | #endif |