LLVM API Documentation

Loads.h
Go to the documentation of this file.
00001 //===- Loads.h - Local load analysis --------------------------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares simple local analyses for load instructions.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_ANALYSIS_LOADS_H
00015 #define LLVM_ANALYSIS_LOADS_H
00016 
00017 #include "llvm/IR/BasicBlock.h"
00018 
00019 namespace llvm {
00020 
00021 class AliasAnalysis;
00022 class DataLayout;
00023 class MDNode;
00024 
00025 /// isSafeToLoadUnconditionally - Return true if we know that executing a load
00026 /// from this value cannot trap.  If it is not obviously safe to load from the
00027 /// specified pointer, we do a quick local scan of the basic block containing
00028 /// ScanFrom, to determine if the address is already accessed.
00029 bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom,
00030                                  unsigned Align,
00031                                  const DataLayout *TD = nullptr);
00032 
00033 /// FindAvailableLoadedValue - Scan the ScanBB block backwards (starting at
00034 /// the instruction before ScanFrom) checking to see if we have the value at
00035 /// the memory address *Ptr locally available within a small number of
00036 ///  instructions. If the value is available, return it.
00037 ///
00038 /// If not, return the iterator for the last validated instruction that the 
00039 /// value would be live through.  If we scanned the entire block and didn't
00040 /// find something that invalidates *Ptr or provides it, ScanFrom would be
00041 /// left at begin() and this returns null.  ScanFrom could also be left 
00042 ///
00043 /// MaxInstsToScan specifies the maximum instructions to scan in the block.
00044 /// If it is set to 0, it will scan the whole block. You can also optionally
00045 /// specify an alias analysis implementation, which makes this more precise.
00046 ///
00047 /// If AATags is non-null and a load or store is found, the AA tags from the
00048 /// load or store are recorded there.  If there are no AA tags or if no access
00049 /// is found, it is left unmodified.
00050 Value *FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
00051                                 BasicBlock::iterator &ScanFrom,
00052                                 unsigned MaxInstsToScan = 6,
00053                                 AliasAnalysis *AA = nullptr,
00054                                 AAMDNodes *AATags = nullptr);
00055 
00056 }
00057 
00058 #endif