summaryrefslogtreecommitdiffstats
path: root/include/llvm/Support
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2011-07-17 15:36:56 +0000
committerdim <dim@FreeBSD.org>2011-07-17 15:36:56 +0000
commit1176aa52646fe641a4243a246aa7f960c708a274 (patch)
treec8086addb211fa670a9d2b1038d8c2e453229755 /include/llvm/Support
parentece02cd5829cea836e9365b0845a8ef042d17b0a (diff)
downloadFreeBSD-src-1176aa52646fe641a4243a246aa7f960c708a274.zip
FreeBSD-src-1176aa52646fe641a4243a246aa7f960c708a274.tar.gz
Vendor import of llvm trunk r135360:
http://llvm.org/svn/llvm-project/llvm/trunk@135360
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/BranchProbability.h16
-rw-r--r--include/llvm/Support/CFG.h16
-rw-r--r--include/llvm/Support/ConstantFolder.h10
-rw-r--r--include/llvm/Support/DebugLoc.h7
-rw-r--r--include/llvm/Support/ELF.h8
-rw-r--r--include/llvm/Support/Endian.h1
-rw-r--r--include/llvm/Support/IRBuilder.h135
-rw-r--r--include/llvm/Support/NoFolder.h12
-rw-r--r--include/llvm/Support/PassManagerBuilder.h13
-rw-r--r--include/llvm/Support/TargetFolder.h11
-rw-r--r--include/llvm/Support/TypeBuilder.h75
-rw-r--r--include/llvm/Support/system_error.h4
12 files changed, 160 insertions, 148 deletions
diff --git a/include/llvm/Support/BranchProbability.h b/include/llvm/Support/BranchProbability.h
index 7ba6491..2e81490 100644
--- a/include/llvm/Support/BranchProbability.h
+++ b/include/llvm/Support/BranchProbability.h
@@ -19,15 +19,9 @@
namespace llvm {
class raw_ostream;
-class BranchProbabilityInfo;
-class MachineBranchProbabilityInfo;
-class MachineBasicBlock;
// This class represents Branch Probability as a non-negative fraction.
class BranchProbability {
- friend class BranchProbabilityInfo;
- friend class MachineBranchProbabilityInfo;
- friend class MachineBasicBlock;
// Numerator
uint32_t N;
@@ -35,9 +29,17 @@ class BranchProbability {
// Denominator
uint32_t D;
+public:
BranchProbability(uint32_t n, uint32_t d);
-public:
+ uint32_t getNumerator() const { return N; }
+ uint32_t getDenominator() const { return D; }
+
+ // Return (1 - Probability).
+ BranchProbability getCompl() {
+ return BranchProbability(D - N, D);
+ }
+
raw_ostream &print(raw_ostream &OS) const;
void dump() const;
diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h
index d2ea123..29313ef 100644
--- a/include/llvm/Support/CFG.h
+++ b/include/llvm/Support/CFG.h
@@ -33,7 +33,7 @@ class PredIterator : public std::iterator<std::forward_iterator_tag,
USE_iterator It;
inline void advancePastNonTerminators() {
- // Loop to ignore non terminator uses (for example PHI nodes).
+ // Loop to ignore non terminator uses (for example BlockAddresses).
while (!It.atEnd() && !isa<TerminatorInst>(*It))
++It;
}
@@ -109,11 +109,18 @@ public:
// TODO: This can be random access iterator, only operator[] missing.
explicit inline SuccIterator(Term_ T) : Term(T), idx(0) {// begin iterator
- assert(T && "getTerminator returned null!");
}
inline SuccIterator(Term_ T, bool) // end iterator
- : Term(T), idx(Term->getNumSuccessors()) {
- assert(T && "getTerminator returned null!");
+ : Term(T) {
+ if (Term)
+ idx = Term->getNumSuccessors();
+ else
+ // Term == NULL happens, if a basic block is not fully constructed and
+ // consequently getTerminator() returns NULL. In this case we construct a
+ // SuccIterator which describes a basic block that has zero successors.
+ // Defining SuccIterator for incomplete and malformed CFGs is especially
+ // useful for debugging.
+ idx = 0;
}
inline const Self &operator=(const Self &I) {
@@ -201,6 +208,7 @@ public:
/// Get the source BB of this iterator.
inline BB_ *getSource() {
+ assert(Term && "Source not available, if basic block was malformed");
return Term->getParent();
}
};
diff --git a/include/llvm/Support/ConstantFolder.h b/include/llvm/Support/ConstantFolder.h
index d0eaa3e..7330235 100644
--- a/include/llvm/Support/ConstantFolder.h
+++ b/include/llvm/Support/ConstantFolder.h
@@ -210,14 +210,14 @@ public:
return ConstantExpr::getShuffleVector(V1, V2, Mask);
}
- Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
- unsigned NumIdx) const {
- return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx);
+ Constant *CreateExtractValue(Constant *Agg,
+ ArrayRef<unsigned> IdxList) const {
+ return ConstantExpr::getExtractValue(Agg, IdxList);
}
Constant *CreateInsertValue(Constant *Agg, Constant *Val,
- const unsigned *IdxList, unsigned NumIdx) const {
- return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx);
+ ArrayRef<unsigned> IdxList) const {
+ return ConstantExpr::getInsertValue(Agg, Val, IdxList);
}
};
diff --git a/include/llvm/Support/DebugLoc.h b/include/llvm/Support/DebugLoc.h
index 98a05a4..2ee9f87 100644
--- a/include/llvm/Support/DebugLoc.h
+++ b/include/llvm/Support/DebugLoc.h
@@ -61,7 +61,10 @@ namespace llvm {
/// getFromDILocation - Translate the DILocation quad into a DebugLoc.
static DebugLoc getFromDILocation(MDNode *N);
-
+
+ /// getFromDILexicalBlock - Translate the DILexicalBlock into a DebugLoc.
+ static DebugLoc getFromDILexicalBlock(MDNode *N);
+
/// isUnknown - Return true if this is an unknown location.
bool isUnknown() const { return ScopeIdx == 0; }
@@ -94,6 +97,8 @@ namespace llvm {
return LineCol == DL.LineCol && ScopeIdx == DL.ScopeIdx;
}
bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
+
+ void dump(const LLVMContext &Ctx) const;
};
template <>
diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h
index cc72bd5..be48112 100644
--- a/include/llvm/Support/ELF.h
+++ b/include/llvm/Support/ELF.h
@@ -487,11 +487,11 @@ enum {
SHT_REL = 9, // Relocation entries; no explicit addends.
SHT_SHLIB = 10, // Reserved.
SHT_DYNSYM = 11, // Symbol table.
- SHT_INIT_ARRAY = 14, // Pointers to initialisation functions.
+ SHT_INIT_ARRAY = 14, // Pointers to initialization functions.
SHT_FINI_ARRAY = 15, // Pointers to termination functions.
SHT_PREINIT_ARRAY = 16, // Pointers to pre-init functions.
SHT_GROUP = 17, // Section group.
- SHT_SYMTAB_SHNDX = 18, // Indicies for SHN_XINDEX entries.
+ SHT_SYMTAB_SHNDX = 18, // Indices for SHN_XINDEX entries.
SHT_LOOS = 0x60000000, // Lowest operating system-specific type.
SHT_HIOS = 0x6fffffff, // Highest operating system-specific type.
SHT_LOPROC = 0x70000000, // Lowest processor architecture-specific type.
@@ -630,7 +630,7 @@ enum {
STT_FUNC = 2, // Symbol is executable code (function, etc.)
STT_SECTION = 3, // Symbol refers to a section
STT_FILE = 4, // Local, absolute symbol that refers to a file
- STT_COMMON = 5, // An uninitialised common block
+ STT_COMMON = 5, // An uninitialized common block
STT_TLS = 6, // Thread local data object
STT_LOPROC = 13, // Lowest processor-specific symbol type
STT_HIPROC = 15 // Highest processor-specific symbol type
@@ -804,7 +804,7 @@ enum {
DT_RELENT = 19, // Size of a Rel relocation entry.
DT_PLTREL = 20, // Type of relocation entry used for linking.
DT_DEBUG = 21, // Reserved for debugger.
- DT_TEXTREL = 22, // Relocations exist for non-writable segements.
+ DT_TEXTREL = 22, // Relocations exist for non-writable segments.
DT_JMPREL = 23, // Address of relocations associated with PLT.
DT_BIND_NOW = 24, // Process all relocations before execution.
DT_INIT_ARRAY = 25, // Pointer to array of initialization functions.
diff --git a/include/llvm/Support/Endian.h b/include/llvm/Support/Endian.h
index f62eab0..af1b506 100644
--- a/include/llvm/Support/Endian.h
+++ b/include/llvm/Support/Endian.h
@@ -14,7 +14,6 @@
#ifndef LLVM_SUPPORT_ENDIAN_H
#define LLVM_SUPPORT_ENDIAN_H
-#include "llvm/Config/config.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/type_traits.h"
diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h
index 6a7c277..91cd78e 100644
--- a/include/llvm/Support/IRBuilder.h
+++ b/include/llvm/Support/IRBuilder.h
@@ -82,7 +82,7 @@ public:
InsertPt = I;
SetCurrentDebugLocation(I->getDebugLoc());
}
-
+
/// SetInsertPoint - This specifies that created instructions should be
/// inserted at the specified point.
void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP) {
@@ -90,6 +90,19 @@ public:
InsertPt = IP;
}
+ /// SetInsertPoint(Use) - Find the nearest point that dominates this use, and
+ /// specify that created instructions should be inserted at this point.
+ void SetInsertPoint(Use &U) {
+ Instruction *UseInst = cast<Instruction>(U.getUser());
+ if (PHINode *Phi = dyn_cast<PHINode>(UseInst)) {
+ BasicBlock *PredBB = Phi->getIncomingBlock(U);
+ assert(U != PredBB->getTerminator() && "critical edge not split");
+ SetInsertPoint(PredBB, PredBB->getTerminator());
+ return;
+ }
+ SetInsertPoint(UseInst);
+ }
+
/// SetCurrentDebugLocation - Set location information used by debugging
/// information.
void SetCurrentDebugLocation(const DebugLoc &L) {
@@ -98,7 +111,7 @@ public:
/// getCurrentDebugLocation - Get location information used by debugging
/// information.
- const DebugLoc &getCurrentDebugLocation() const { return CurDbgLocation; }
+ DebugLoc getCurrentDebugLocation() const { return CurDbgLocation; }
/// SetInstDebugLocation - If this builder has a current debug location, set
/// it on the specified instruction.
@@ -109,8 +122,8 @@ public:
/// getCurrentFunctionReturnType - Get the return type of the current function
/// that we're emitting into.
- const Type *getCurrentFunctionReturnType() const;
-
+ Type *getCurrentFunctionReturnType() const;
+
/// InsertPoint - A saved insertion point.
class InsertPoint {
BasicBlock *Block;
@@ -198,7 +211,7 @@ public:
ConstantInt *getInt64(uint64_t C) {
return ConstantInt::get(getInt64Ty(), C);
}
-
+
/// getInt - Get a constant integer value.
ConstantInt *getInt(const APInt &AI) {
return ConstantInt::get(Context, AI);
@@ -209,46 +222,46 @@ public:
//===--------------------------------------------------------------------===//
/// getInt1Ty - Fetch the type representing a single bit
- const IntegerType *getInt1Ty() {
+ IntegerType *getInt1Ty() {
return Type::getInt1Ty(Context);
}
/// getInt8Ty - Fetch the type representing an 8-bit integer.
- const IntegerType *getInt8Ty() {
+ IntegerType *getInt8Ty() {
return Type::getInt8Ty(Context);
}
/// getInt16Ty - Fetch the type representing a 16-bit integer.
- const IntegerType *getInt16Ty() {
+ IntegerType *getInt16Ty() {
return Type::getInt16Ty(Context);
}
/// getInt32Ty - Fetch the type resepresenting a 32-bit integer.
- const IntegerType *getInt32Ty() {
+ IntegerType *getInt32Ty() {
return Type::getInt32Ty(Context);
}
/// getInt64Ty - Fetch the type representing a 64-bit integer.
- const IntegerType *getInt64Ty() {
+ IntegerType *getInt64Ty() {
return Type::getInt64Ty(Context);
}
/// getFloatTy - Fetch the type representing a 32-bit floating point value.
- const Type *getFloatTy() {
+ Type *getFloatTy() {
return Type::getFloatTy(Context);
}
/// getDoubleTy - Fetch the type representing a 64-bit floating point value.
- const Type *getDoubleTy() {
+ Type *getDoubleTy() {
return Type::getDoubleTy(Context);
}
/// getVoidTy - Fetch the type representing void.
- const Type *getVoidTy() {
+ Type *getVoidTy() {
return Type::getVoidTy(Context);
}
- const PointerType *getInt8PtrTy(unsigned AddrSpace = 0) {
+ PointerType *getInt8PtrTy(unsigned AddrSpace = 0) {
return Type::getInt8PtrTy(Context, AddrSpace);
}
@@ -263,7 +276,7 @@ public:
bool isVolatile = false, MDNode *TBAATag = 0) {
return CreateMemSet(Ptr, Val, getInt64(Size), Align, isVolatile, TBAATag);
}
-
+
CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align,
bool isVolatile = false, MDNode *TBAATag = 0);
@@ -274,7 +287,7 @@ public:
bool isVolatile = false, MDNode *TBAATag = 0) {
return CreateMemCpy(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag);
}
-
+
CallInst *CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align,
bool isVolatile = false, MDNode *TBAATag = 0);
@@ -285,9 +298,9 @@ public:
bool isVolatile = false, MDNode *TBAATag = 0) {
return CreateMemMove(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag);
}
-
+
CallInst *CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align,
- bool isVolatile = false, MDNode *TBAATag = 0);
+ bool isVolatile = false, MDNode *TBAATag = 0);
/// CreateLifetimeStart - Create a lifetime.start intrinsic. If the pointer
/// isn't i8* it will be converted.
@@ -341,7 +354,13 @@ public:
SetInsertPoint(IP);
SetCurrentDebugLocation(IP->getDebugLoc());
}
-
+
+ explicit IRBuilder(Use &U)
+ : IRBuilderBase(U->getContext()), Folder() {
+ SetInsertPoint(U);
+ SetCurrentDebugLocation(cast<Instruction>(U.getUser())->getDebugLoc());
+ }
+
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F)
: IRBuilderBase(TheBB->getContext()), Folder(F) {
SetInsertPoint(TheBB, IP);
@@ -430,34 +449,30 @@ public:
InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
BasicBlock *UnwindDest, const Twine &Name = "") {
- Value *Args[] = { 0 };
- return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args,
- Args), Name);
+ return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest,
+ ArrayRef<Value *>()),
+ Name);
}
InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
BasicBlock *UnwindDest, Value *Arg1,
const Twine &Name = "") {
- Value *Args[] = { Arg1 };
- return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args,
- Args+1), Name);
+ return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Arg1),
+ Name);
}
InvokeInst *CreateInvoke3(Value *Callee, BasicBlock *NormalDest,
BasicBlock *UnwindDest, Value *Arg1,
Value *Arg2, Value *Arg3,
const Twine &Name = "") {
Value *Args[] = { Arg1, Arg2, Arg3 };
- return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args,
- Args+3), Name);
+ return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args),
+ Name);
}
/// CreateInvoke - Create an invoke instruction.
- template<typename RandomAccessIterator>
InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
- BasicBlock *UnwindDest,
- RandomAccessIterator ArgBegin,
- RandomAccessIterator ArgEnd,
+ BasicBlock *UnwindDest, ArrayRef<Value *> Args,
const Twine &Name = "") {
- return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest,
- ArgBegin, ArgEnd), Name);
+ return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args),
+ Name);
}
UnwindInst *CreateUnwind() {
@@ -1107,33 +1122,27 @@ public:
CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2,
const Twine &Name = "") {
Value *Args[] = { Arg1, Arg2 };
- return Insert(CallInst::Create(Callee, Args, Args+2), Name);
+ return Insert(CallInst::Create(Callee, Args), Name);
}
CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
const Twine &Name = "") {
Value *Args[] = { Arg1, Arg2, Arg3 };
- return Insert(CallInst::Create(Callee, Args, Args+3), Name);
+ return Insert(CallInst::Create(Callee, Args), Name);
}
CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
Value *Arg4, const Twine &Name = "") {
Value *Args[] = { Arg1, Arg2, Arg3, Arg4 };
- return Insert(CallInst::Create(Callee, Args, Args+4), Name);
+ return Insert(CallInst::Create(Callee, Args), Name);
}
CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
Value *Arg4, Value *Arg5, const Twine &Name = "") {
Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 };
- return Insert(CallInst::Create(Callee, Args, Args+5), Name);
+ return Insert(CallInst::Create(Callee, Args), Name);
}
- CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Arg,
+ CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args,
const Twine &Name = "") {
- return Insert(CallInst::Create(Callee, Arg.begin(), Arg.end(), Name));
- }
-
- template<typename RandomAccessIterator>
- CallInst *CreateCall(Value *Callee, RandomAccessIterator ArgBegin,
- RandomAccessIterator ArgEnd, const Twine &Name = "") {
- return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd), Name);
+ return Insert(CallInst::Create(Callee, Args, Name));
}
Value *CreateSelect(Value *C, Value *True, Value *False,
@@ -1175,43 +1184,21 @@ public:
return Insert(new ShuffleVectorInst(V1, V2, Mask), Name);
}
- Value *CreateExtractValue(Value *Agg, unsigned Idx,
- const Twine &Name = "") {
- if (Constant *AggC = dyn_cast<Constant>(Agg))
- return Insert(Folder.CreateExtractValue(AggC, &Idx, 1), Name);
- return Insert(ExtractValueInst::Create(Agg, Idx), Name);
- }
-
- template<typename RandomAccessIterator>
Value *CreateExtractValue(Value *Agg,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
+ ArrayRef<unsigned> Idxs,
const Twine &Name = "") {
if (Constant *AggC = dyn_cast<Constant>(Agg))
- return Insert(Folder.CreateExtractValue(AggC, IdxBegin, IdxEnd-IdxBegin),
- Name);
- return Insert(ExtractValueInst::Create(Agg, IdxBegin, IdxEnd), Name);
+ return Insert(Folder.CreateExtractValue(AggC, Idxs), Name);
+ return Insert(ExtractValueInst::Create(Agg, Idxs), Name);
}
- Value *CreateInsertValue(Value *Agg, Value *Val, unsigned Idx,
- const Twine &Name = "") {
- if (Constant *AggC = dyn_cast<Constant>(Agg))
- if (Constant *ValC = dyn_cast<Constant>(Val))
- return Insert(Folder.CreateInsertValue(AggC, ValC, &Idx, 1), Name);
- return Insert(InsertValueInst::Create(Agg, Val, Idx), Name);
- }
-
- template<typename RandomAccessIterator>
Value *CreateInsertValue(Value *Agg, Value *Val,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
+ ArrayRef<unsigned> Idxs,
const Twine &Name = "") {
if (Constant *AggC = dyn_cast<Constant>(Agg))
if (Constant *ValC = dyn_cast<Constant>(Val))
- return Insert(Folder.CreateInsertValue(AggC, ValC, IdxBegin,
- IdxEnd - IdxBegin),
- Name);
- return Insert(InsertValueInst::Create(Agg, Val, IdxBegin, IdxEnd), Name);
+ return Insert(Folder.CreateInsertValue(AggC, ValC, Idxs), Name);
+ return Insert(InsertValueInst::Create(Agg, Val, Idxs), Name);
}
//===--------------------------------------------------------------------===//
@@ -1238,7 +1225,7 @@ public:
Value *CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name = "") {
assert(LHS->getType() == RHS->getType() &&
"Pointer subtraction operand types must match!");
- const PointerType *ArgType = cast<PointerType>(LHS->getType());
+ PointerType *ArgType = cast<PointerType>(LHS->getType());
Value *LHS_int = CreatePtrToInt(LHS, Type::getInt64Ty(Context));
Value *RHS_int = CreatePtrToInt(RHS, Type::getInt64Ty(Context));
Value *Difference = CreateSub(LHS_int, RHS_int);
diff --git a/include/llvm/Support/NoFolder.h b/include/llvm/Support/NoFolder.h
index 5ead26e..94359a5 100644
--- a/include/llvm/Support/NoFolder.h
+++ b/include/llvm/Support/NoFolder.h
@@ -22,6 +22,7 @@
#ifndef LLVM_SUPPORT_NOFOLDER_H
#define LLVM_SUPPORT_NOFOLDER_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
@@ -269,15 +270,14 @@ public:
return new ShuffleVectorInst(V1, V2, Mask);
}
- Instruction *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
- unsigned NumIdx) const {
- return ExtractValueInst::Create(Agg, IdxList, IdxList+NumIdx);
+ Instruction *CreateExtractValue(Constant *Agg,
+ ArrayRef<unsigned> IdxList) const {
+ return ExtractValueInst::Create(Agg, IdxList);
}
Instruction *CreateInsertValue(Constant *Agg, Constant *Val,
- const unsigned *IdxList,
- unsigned NumIdx) const {
- return InsertValueInst::Create(Agg, Val, IdxList, IdxList+NumIdx);
+ ArrayRef<unsigned> IdxList) const {
+ return InsertValueInst::Create(Agg, Val, IdxList);
}
};
diff --git a/include/llvm/Support/PassManagerBuilder.h b/include/llvm/Support/PassManagerBuilder.h
index 513bb88..b0cec6e 100644
--- a/include/llvm/Support/PassManagerBuilder.h
+++ b/include/llvm/Support/PassManagerBuilder.h
@@ -67,7 +67,12 @@ public:
/// EP_LoopOptimizerEnd - This extension point allows adding loop passes to
/// the end of the loop optimizer.
- EP_LoopOptimizerEnd
+ EP_LoopOptimizerEnd,
+
+ /// EP_ScalarOptimizerLate - This extension point allows adding optimization
+ /// passes after most of the main optimizations, but before the last
+ /// cleanup-ish optimizations.
+ EP_ScalarOptimizerLate
};
/// The Optimization Level - Specify the basic optimization level.
@@ -147,6 +152,7 @@ public:
FPM.add(createCFGSimplificationPass());
FPM.add(createScalarReplAggregatesPass());
FPM.add(createEarlyCSEPass());
+ FPM.add(createLowerExpectIntrinsicPass());
}
/// populateModulePassManager - This sets up the primary pass manager.
@@ -223,13 +229,16 @@ public:
MPM.add(createJumpThreadingPass()); // Thread jumps
MPM.add(createCorrelatedValuePropagationPass());
MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
+
+ addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
+
MPM.add(createAggressiveDCEPass()); // Delete dead instructions
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
MPM.add(createInstructionCombiningPass()); // Clean up after everything.
if (!DisableUnitAtATime) {
+ // FIXME: We shouldn't bother with this anymore.
MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
- MPM.add(createDeadTypeEliminationPass()); // Eliminate dead types
// GlobalOpt already deletes dead functions and globals, at -O3 try a
// late pass of GlobalDCE. It is capable of deleting dead cycles.
diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h
index 20ca557..3233a98 100644
--- a/include/llvm/Support/TargetFolder.h
+++ b/include/llvm/Support/TargetFolder.h
@@ -21,6 +21,7 @@
#include "llvm/Constants.h"
#include "llvm/InstrTypes.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/Analysis/ConstantFolding.h"
namespace llvm {
@@ -226,14 +227,14 @@ public:
return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask));
}
- Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
- unsigned NumIdx) const {
- return Fold(ConstantExpr::getExtractValue(Agg, IdxList, NumIdx));
+ Constant *CreateExtractValue(Constant *Agg,
+ ArrayRef<unsigned> IdxList) const {
+ return Fold(ConstantExpr::getExtractValue(Agg, IdxList));
}
Constant *CreateInsertValue(Constant *Agg, Constant *Val,
- const unsigned *IdxList, unsigned NumIdx) const {
- return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx));
+ ArrayRef<unsigned> IdxList) const {
+ return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList));
}
};
diff --git a/include/llvm/Support/TypeBuilder.h b/include/llvm/Support/TypeBuilder.h
index ea63da0..1800778 100644
--- a/include/llvm/Support/TypeBuilder.h
+++ b/include/llvm/Support/TypeBuilder.h
@@ -18,6 +18,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/LLVMContext.h"
#include <limits.h>
+#include <vector>
namespace llvm {
@@ -50,7 +51,7 @@ namespace llvm {
/// namespace llvm {
/// template<bool xcompile> class TypeBuilder<MyType, xcompile> {
/// public:
-/// static const StructType *get(LLVMContext &Context) {
+/// static StructType *get(LLVMContext &Context) {
/// // If you cache this result, be sure to cache it separately
/// // for each LLVMContext.
/// return StructType::get(
@@ -103,7 +104,7 @@ template<typename T, bool cross> class TypeBuilder<const volatile T, cross>
// Pointers
template<typename T, bool cross> class TypeBuilder<T*, cross> {
public:
- static const PointerType *get(LLVMContext &Context) {
+ static PointerType *get(LLVMContext &Context) {
return PointerType::getUnqual(TypeBuilder<T,cross>::get(Context));
}
};
@@ -114,14 +115,14 @@ template<typename T, bool cross> class TypeBuilder<T&, cross> {};
// Arrays
template<typename T, size_t N, bool cross> class TypeBuilder<T[N], cross> {
public:
- static const ArrayType *get(LLVMContext &Context) {
+ static ArrayType *get(LLVMContext &Context) {
return ArrayType::get(TypeBuilder<T, cross>::get(Context), N);
}
};
/// LLVM uses an array of length 0 to represent an unknown-length array.
template<typename T, bool cross> class TypeBuilder<T[], cross> {
public:
- static const ArrayType *get(LLVMContext &Context) {
+ static ArrayType *get(LLVMContext &Context) {
return ArrayType::get(TypeBuilder<T, cross>::get(Context), 0);
}
};
@@ -151,7 +152,7 @@ public:
#define DEFINE_INTEGRAL_TYPEBUILDER(T) \
template<> class TypeBuilder<T, false> { \
public: \
- static const IntegerType *get(LLVMContext &Context) { \
+ static IntegerType *get(LLVMContext &Context) { \
return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \
} \
}; \
@@ -180,14 +181,14 @@ DEFINE_INTEGRAL_TYPEBUILDER(unsigned long long);
template<uint32_t num_bits, bool cross>
class TypeBuilder<types::i<num_bits>, cross> {
public:
- static const IntegerType *get(LLVMContext &C) {
+ static IntegerType *get(LLVMContext &C) {
return IntegerType::get(C, num_bits);
}
};
template<> class TypeBuilder<float, false> {
public:
- static const Type *get(LLVMContext& C) {
+ static Type *get(LLVMContext& C) {
return Type::getFloatTy(C);
}
};
@@ -195,7 +196,7 @@ template<> class TypeBuilder<float, true> {};
template<> class TypeBuilder<double, false> {
public:
- static const Type *get(LLVMContext& C) {
+ static Type *get(LLVMContext& C) {
return Type::getDoubleTy(C);
}
};
@@ -203,32 +204,32 @@ template<> class TypeBuilder<double, true> {};
template<bool cross> class TypeBuilder<types::ieee_float, cross> {
public:
- static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); }
+ static Type *get(LLVMContext& C) { return Type::getFloatTy(C); }
};
template<bool cross> class TypeBuilder<types::ieee_double, cross> {
public:
- static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); }
+ static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); }
};
template<bool cross> class TypeBuilder<types::x86_fp80, cross> {
public:
- static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); }
+ static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); }
};
template<bool cross> class TypeBuilder<types::fp128, cross> {
public:
- static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); }
+ static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); }
};
template<bool cross> class TypeBuilder<types::ppc_fp128, cross> {
public:
- static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); }
+ static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); }
};
template<bool cross> class TypeBuilder<types::x86_mmx, cross> {
public:
- static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); }
+ static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); }
};
template<bool cross> class TypeBuilder<void, cross> {
public:
- static const Type *get(LLVMContext &C) {
+ static Type *get(LLVMContext &C) {
return Type::getVoidTy(C);
}
};
@@ -246,14 +247,14 @@ template<> class TypeBuilder<const volatile void*, false>
template<typename R, bool cross> class TypeBuilder<R(), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
+ static FunctionType *get(LLVMContext &Context) {
return FunctionType::get(TypeBuilder<R, cross>::get(Context), false);
}
};
template<typename R, typename A1, bool cross> class TypeBuilder<R(A1), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(1);
params.push_back(TypeBuilder<A1, cross>::get(Context));
return FunctionType::get(TypeBuilder<R, cross>::get(Context),
@@ -263,8 +264,8 @@ public:
template<typename R, typename A1, typename A2, bool cross>
class TypeBuilder<R(A1, A2), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(2);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
@@ -275,8 +276,8 @@ public:
template<typename R, typename A1, typename A2, typename A3, bool cross>
class TypeBuilder<R(A1, A2, A3), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(3);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
@@ -290,8 +291,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
bool cross>
class TypeBuilder<R(A1, A2, A3, A4), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(4);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
@@ -306,8 +307,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, bool cross>
class TypeBuilder<R(A1, A2, A3, A4, A5), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(5);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
@@ -321,15 +322,15 @@ public:
template<typename R, bool cross> class TypeBuilder<R(...), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
+ static FunctionType *get(LLVMContext &Context) {
return FunctionType::get(TypeBuilder<R, cross>::get(Context), true);
}
};
template<typename R, typename A1, bool cross>
class TypeBuilder<R(A1, ...), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(1);
params.push_back(TypeBuilder<A1, cross>::get(Context));
return FunctionType::get(TypeBuilder<R, cross>::get(Context), params, true);
@@ -338,8 +339,8 @@ public:
template<typename R, typename A1, typename A2, bool cross>
class TypeBuilder<R(A1, A2, ...), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(2);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
@@ -350,8 +351,8 @@ public:
template<typename R, typename A1, typename A2, typename A3, bool cross>
class TypeBuilder<R(A1, A2, A3, ...), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(3);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
@@ -365,8 +366,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
bool cross>
class TypeBuilder<R(A1, A2, A3, A4, ...), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(4);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
@@ -381,8 +382,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, bool cross>
class TypeBuilder<R(A1, A2, A3, A4, A5, ...), cross> {
public:
- static const FunctionType *get(LLVMContext &Context) {
- std::vector<const Type*> params;
+ static FunctionType *get(LLVMContext &Context) {
+ std::vector<Type*> params;
params.reserve(5);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
diff --git a/include/llvm/Support/system_error.h b/include/llvm/Support/system_error.h
index 47759b9..2c15b69 100644
--- a/include/llvm/Support/system_error.h
+++ b/include/llvm/Support/system_error.h
@@ -222,7 +222,7 @@ template <> struct hash<std::error_code>;
*/
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#include "llvm/Support/type_traits.h"
#include <cerrno>
#include <string>
@@ -669,7 +669,7 @@ const error_category& generic_category();
const error_category& system_category();
/// Get the error_category used for errno values from POSIX functions. This is
-/// the same as the system_category on POISIX systems, but is the same as the
+/// the same as the system_category on POSIX systems, but is the same as the
/// generic_category on Windows.
const error_category& posix_category();
OpenPOWER on IntegriCloud