• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/IR/Attributes.h"
20 #include "llvm/IR/Instruction.h"
21 #include "llvm/IR/PassManager.h"
22 
23 namespace llvm {
24 class IntrinsicInst;
25 class AssumptionCache;
26 class DominatorTree;
27 
28 /// Build a call to llvm.assume to preserve informations that can be derived
29 /// from the given instruction.
30 /// If no information derived from \p I, this call returns null.
31 /// The returned instruction is not inserted anywhere.
32 IntrinsicInst *buildAssumeFromInst(Instruction *I);
33 
34 /// Calls BuildAssumeFromInst and if the resulting llvm.assume is valid insert
35 /// if before I. This is usually what need to be done to salvage the knowledge
36 /// contained in the instruction I.
37 /// The AssumptionCache must be provided if it is available or the cache may
38 /// become silently be invalid.
39 /// The DominatorTree can optionally be provided to enable cross-block
40 /// reasoning.
41 void salvageKnowledge(Instruction *I, AssumptionCache *AC = nullptr,
42                       DominatorTree *DT = nullptr);
43 
44 /// This pass attempts to minimize the number of assume without loosing any
45 /// information.
46 struct AssumeSimplifyPass : public PassInfoMixin<AssumeSimplifyPass> {
47   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
48 };
49 
50 FunctionPass *createAssumeSimplifyPass();
51 
52 /// This pass will try to build an llvm.assume for every instruction in the
53 /// function. Its main purpose is testing.
54 struct AssumeBuilderPass : public PassInfoMixin<AssumeBuilderPass> {
55   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
56 };
57 
58 } // namespace llvm
59 
60 #endif
61