From 044eb2f6afba375a914ac9d8024f8f5142bb912e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 18 Dec 2017 20:10:56 +0000 Subject: Vendor import of llvm trunk r321017: https://llvm.org/svn/llvm-project/llvm/trunk@321017 --- include/llvm/Analysis/MemoryBuiltins.h | 59 ++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 21 deletions(-) (limited to 'include/llvm/Analysis/MemoryBuiltins.h') diff --git a/include/llvm/Analysis/MemoryBuiltins.h b/include/llvm/Analysis/MemoryBuiltins.h index 23ab372703ee..7d53e34938b7 100644 --- a/include/llvm/Analysis/MemoryBuiltins.h +++ b/include/llvm/Analysis/MemoryBuiltins.h @@ -1,4 +1,4 @@ -//===- llvm/Analysis/MemoryBuiltins.h- Calls to memory builtins -*- C++ -*-===// +//==- llvm/Analysis/MemoryBuiltins.h - Calls to memory builtins --*- C++ -*-==// // // The LLVM Compiler Infrastructure // @@ -15,21 +15,42 @@ #ifndef LLVM_ANALYSIS_MEMORYBUILTINS_H #define LLVM_ANALYSIS_MEMORYBUILTINS_H +#include "llvm/ADT/APInt.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Analysis/TargetFolder.h" +#include "llvm/IR/CallSite.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InstVisitor.h" -#include "llvm/IR/Operator.h" #include "llvm/IR/ValueHandle.h" -#include "llvm/Support/DataTypes.h" +#include +#include namespace llvm { + +class AllocaInst; +class Argument; class CallInst; -class PointerType; +class ConstantInt; +class ConstantPointerNull; class DataLayout; +class ExtractElementInst; +class ExtractValueInst; +class GEPOperator; +class GlobalAlias; +class GlobalVariable; +class Instruction; +class IntegerType; +class IntrinsicInst; +class IntToPtrInst; +class LLVMContext; +class LoadInst; +class PHINode; +class PointerType; +class SelectInst; class TargetLibraryInfo; class Type; +class UndefValue; class Value; /// \brief Tests if a value is a call or invoke to a library function that @@ -71,8 +92,7 @@ bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI, /// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we /// ignore InvokeInst here. const CallInst *extractMallocCall(const Value *I, const TargetLibraryInfo *TLI); -static inline CallInst *extractMallocCall(Value *I, - const TargetLibraryInfo *TLI) { +inline CallInst *extractMallocCall(Value *I, const TargetLibraryInfo *TLI) { return const_cast(extractMallocCall((const Value*)I, TLI)); } @@ -106,8 +126,7 @@ Value *getMallocArraySize(CallInst *CI, const DataLayout &DL, /// extractCallocCall - Returns the corresponding CallInst if the instruction /// is a calloc call. const CallInst *extractCallocCall(const Value *I, const TargetLibraryInfo *TLI); -static inline CallInst *extractCallocCall(Value *I, - const TargetLibraryInfo *TLI) { +inline CallInst *extractCallocCall(Value *I, const TargetLibraryInfo *TLI) { return const_cast(extractCallocCall((const Value*)I, TLI)); } @@ -119,11 +138,10 @@ static inline CallInst *extractCallocCall(Value *I, /// isFreeCall - Returns non-null if the value is a call to the builtin free() const CallInst *isFreeCall(const Value *I, const TargetLibraryInfo *TLI); -static inline CallInst *isFreeCall(Value *I, const TargetLibraryInfo *TLI) { +inline CallInst *isFreeCall(Value *I, const TargetLibraryInfo *TLI) { return const_cast(isFreeCall((const Value*)I, TLI)); } - //===----------------------------------------------------------------------===// // Utility functions to compute size of objects. // @@ -169,13 +187,12 @@ ConstantInt *lowerObjectSizeCall(IntrinsicInst *ObjectSize, const TargetLibraryInfo *TLI, bool MustSucceed); -typedef std::pair SizeOffsetType; +using SizeOffsetType = std::pair; /// \brief Evaluate the size and offset of an object pointed to by a Value* /// statically. Fails if size or offset are not known at compile time. class ObjectSizeOffsetVisitor : public InstVisitor { - const DataLayout &DL; const TargetLibraryInfo *TLI; ObjectSizeOpts Options; @@ -229,18 +246,16 @@ private: bool CheckedZextOrTrunc(APInt &I); }; -typedef std::pair SizeOffsetEvalType; - +using SizeOffsetEvalType = std::pair; /// \brief Evaluate the size and offset of an object pointed to by a Value*. /// May create code to compute the result at run-time. class ObjectSizeOffsetEvaluator : public InstVisitor { - - typedef IRBuilder BuilderTy; - typedef std::pair WeakEvalType; - typedef DenseMap CacheMapTy; - typedef SmallPtrSet PtrSetTy; + using BuilderTy = IRBuilder; + using WeakEvalType = std::pair; + using CacheMapTy = DenseMap; + using PtrSetTy = SmallPtrSet; const DataLayout &DL; const TargetLibraryInfo *TLI; @@ -255,11 +270,13 @@ class ObjectSizeOffsetEvaluator SizeOffsetEvalType unknown() { return std::make_pair(nullptr, nullptr); } + SizeOffsetEvalType compute_(Value *V); public: ObjectSizeOffsetEvaluator(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, bool RoundToAlign = false); + SizeOffsetEvalType compute(Value *V); bool knownSize(SizeOffsetEvalType SizeOffset) { @@ -291,6 +308,6 @@ public: SizeOffsetEvalType visitInstruction(Instruction &I); }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_ANALYSIS_MEMORYBUILTINS_H -- cgit v1.2.3