Merging r259886 and r259888:
[oota-llvm.git] / include / llvm / Analysis / Loads.h
1 //===- Loads.h - Local load analysis --------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares simple local analyses for load instructions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ANALYSIS_LOADS_H
15 #define LLVM_ANALYSIS_LOADS_H
16
17 #include "llvm/Analysis/AliasAnalysis.h"
18 #include "llvm/IR/BasicBlock.h"
19 #include "llvm/Support/CommandLine.h"
20
21 namespace llvm {
22
23 class DataLayout;
24 class MDNode;
25
26 /// isSafeToLoadUnconditionally - Return true if we know that executing a load
27 /// from this value cannot trap.  If it is not obviously safe to load from the
28 /// specified pointer, we do a quick local scan of the basic block containing
29 /// ScanFrom, to determine if the address is already accessed.
30 bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom,
31                                  unsigned Align);
32
33 /// DefMaxInstsToScan - the default number of maximum instructions
34 /// to scan in the block, used by FindAvailableLoadedValue().
35 extern cl::opt<unsigned> DefMaxInstsToScan;
36
37 /// FindAvailableLoadedValue - Scan the ScanBB block backwards (starting at
38 /// the instruction before ScanFrom) checking to see if we have the value at
39 /// the memory address *Ptr locally available within a small number of
40 ///  instructions. If the value is available, return it.
41 ///
42 /// If not, return the iterator for the last validated instruction that the
43 /// value would be live through.  If we scanned the entire block and didn't
44 /// find something that invalidates *Ptr or provides it, ScanFrom would be
45 /// left at begin() and this returns null.  ScanFrom could also be left
46 ///
47 /// MaxInstsToScan specifies the maximum instructions to scan in the block.
48 /// If it is set to 0, it will scan the whole block. You can also optionally
49 /// specify an alias analysis implementation, which makes this more precise.
50 ///
51 /// If AATags is non-null and a load or store is found, the AA tags from the
52 /// load or store are recorded there.  If there are no AA tags or if no access
53 /// is found, it is left unmodified.
54 Value *FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
55                                 BasicBlock::iterator &ScanFrom,
56                                 unsigned MaxInstsToScan = DefMaxInstsToScan,
57                                 AliasAnalysis *AA = nullptr,
58                                 AAMDNodes *AATags = nullptr);
59
60 }
61
62 #endif