summaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/MemoryBuiltins.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:10:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:10:56 +0000
commit044eb2f6afba375a914ac9d8024f8f5142bb912e (patch)
tree1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /include/llvm/Analysis/MemoryBuiltins.h
parenteb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff)
Notes
Diffstat (limited to 'include/llvm/Analysis/MemoryBuiltins.h')
-rw-r--r--include/llvm/Analysis/MemoryBuiltins.h59
1 files changed, 38 insertions, 21 deletions
diff --git a/include/llvm/Analysis/MemoryBuiltins.h b/include/llvm/Analysis/MemoryBuiltins.h
index 23ab372703eea..7d53e34938b79 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 <cstdint>
+#include <utility>
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<CallInst*>(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<CallInst*>(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<CallInst*>(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<APInt, APInt> SizeOffsetType;
+using SizeOffsetType = std::pair<APInt, APInt>;
/// \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<ObjectSizeOffsetVisitor, SizeOffsetType> {
-
const DataLayout &DL;
const TargetLibraryInfo *TLI;
ObjectSizeOpts Options;
@@ -229,18 +246,16 @@ private:
bool CheckedZextOrTrunc(APInt &I);
};
-typedef std::pair<Value*, Value*> SizeOffsetEvalType;
-
+using SizeOffsetEvalType = std::pair<Value *, Value *>;
/// \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<ObjectSizeOffsetEvaluator, SizeOffsetEvalType> {
-
- typedef IRBuilder<TargetFolder> BuilderTy;
- typedef std::pair<WeakTrackingVH, WeakTrackingVH> WeakEvalType;
- typedef DenseMap<const Value*, WeakEvalType> CacheMapTy;
- typedef SmallPtrSet<const Value*, 8> PtrSetTy;
+ using BuilderTy = IRBuilder<TargetFolder>;
+ using WeakEvalType = std::pair<WeakTrackingVH, WeakTrackingVH>;
+ using CacheMapTy = DenseMap<const Value *, WeakEvalType>;
+ using PtrSetTy = SmallPtrSet<const Value *, 8>;
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