diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2009-11-04 14:58:56 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2009-11-04 14:58:56 +0000 |
commit | 7ff99155c39edd73ebf1c6adfa023b1048fee9a4 (patch) | |
tree | b4dc751bcee540346911aa4115729eff2f991657 /include/llvm/Support | |
parent | d1f06de484602e72707476a6152974847bac1570 (diff) | |
download | FreeBSD-src-7ff99155c39edd73ebf1c6adfa023b1048fee9a4.zip FreeBSD-src-7ff99155c39edd73ebf1c6adfa023b1048fee9a4.tar.gz |
Update LLVM to r86025.
Diffstat (limited to 'include/llvm/Support')
-rw-r--r-- | include/llvm/Support/Allocator.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/ConstantRange.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/Debug.h | 67 | ||||
-rw-r--r-- | include/llvm/Support/ELF.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/IRBuilder.h | 24 | ||||
-rw-r--r-- | include/llvm/Support/InstVisitor.h | 5 | ||||
-rw-r--r-- | include/llvm/Support/MathExtras.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/MemoryBuffer.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/MemoryObject.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/PointerLikeTypeTraits.h | 4 | ||||
-rw-r--r-- | include/llvm/Support/SlowOperationInformer.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/StandardPasses.h | 39 | ||||
-rw-r--r-- | include/llvm/Support/TargetFolder.h | 10 | ||||
-rw-r--r-- | include/llvm/Support/Timer.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/raw_ostream.h | 2 |
15 files changed, 98 insertions, 69 deletions
diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index 4c84878..b0ed33d 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -15,7 +15,7 @@ #define LLVM_SUPPORT_ALLOCATOR_H #include "llvm/Support/AlignOf.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" #include <cassert> #include <cstdlib> diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h index e9c8c7c..3846d46 100644 --- a/include/llvm/Support/ConstantRange.h +++ b/include/llvm/Support/ConstantRange.h @@ -33,7 +33,7 @@ #define LLVM_SUPPORT_CONSTANT_RANGE_H #include "llvm/ADT/APInt.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" namespace llvm { diff --git a/include/llvm/Support/Debug.h b/include/llvm/Support/Debug.h index 6f82ea7..afa828c 100644 --- a/include/llvm/Support/Debug.h +++ b/include/llvm/Support/Debug.h @@ -28,39 +28,47 @@ namespace llvm { -// DebugFlag - This boolean is set to true if the '-debug' command line option -// is specified. This should probably not be referenced directly, instead, use -// the DEBUG macro below. -// -#ifndef NDEBUG -extern bool DebugFlag; +/// DEBUG_TYPE macro - Files can specify a DEBUG_TYPE as a string, which causes +/// all of their DEBUG statements to be activatable with -debug-only=thatstring. +#ifndef DEBUG_TYPE +#define DEBUG_TYPE "" #endif - -// isCurrentDebugType - Return true if the specified string is the debug type -// specified on the command line, or if none was specified on the command line -// with the -debug-only=X option. -// + #ifndef NDEBUG +/// DebugFlag - This boolean is set to true if the '-debug' command line option +/// is specified. This should probably not be referenced directly, instead, use +/// the DEBUG macro below. +/// +extern bool DebugFlag; + +/// isCurrentDebugType - Return true if the specified string is the debug type +/// specified on the command line, or if none was specified on the command line +/// with the -debug-only=X option. +/// bool isCurrentDebugType(const char *Type); -#else -#define isCurrentDebugType(X) (false) -#endif - -// DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug -// information. In the '-debug' option is specified on the commandline, and if -// this is a debug build, then the code specified as the option to the macro -// will be executed. Otherwise it will not be. Example: -// -// DEBUG_WITH_TYPE("bitset", errs() << "Bitset contains: " << Bitset << "\n"); -// -// This will emit the debug information if -debug is present, and -debug-only is -// not specified, or is specified as "bitset". -#ifdef NDEBUG -#define DEBUG_WITH_TYPE(TYPE, X) do { } while (0) -#else +/// SetCurrentDebugType - Set the current debug type, as if the -debug-only=X +/// option were specified. Note that DebugFlag also needs to be set to true for +/// debug output to be produced. +/// +void SetCurrentDebugType(const char *Type); + +/// DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug +/// information. In the '-debug' option is specified on the commandline, and if +/// this is a debug build, then the code specified as the option to the macro +/// will be executed. Otherwise it will not be. Example: +/// +/// DEBUG_WITH_TYPE("bitset", errs() << "Bitset contains: " << Bitset << "\n"); +/// +/// This will emit the debug information if -debug is present, and -debug-only +/// is not specified, or is specified as "bitset". #define DEBUG_WITH_TYPE(TYPE, X) \ do { if (DebugFlag && isCurrentDebugType(TYPE)) { X; } } while (0) + +#else +#define isCurrentDebugType(X) (false) +#define SetCurrentDebugType(X) +#define DEBUG_WITH_TYPE(TYPE, X) do { } while (0) #endif // DEBUG macro - This macro should be used by passes to emit debug information. @@ -70,11 +78,6 @@ bool isCurrentDebugType(const char *Type); // // DEBUG(errs() << "Bitset contains: " << Bitset << "\n"); // - -#ifndef DEBUG_TYPE -#define DEBUG_TYPE "" -#endif - #define DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X) } // End llvm namespace diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index aa27946..e747c7a 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -21,7 +21,7 @@ #ifndef LLVM_SUPPORT_ELF_H #define LLVM_SUPPORT_ELF_H -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" #include <cstring> namespace llvm { diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 83df9ed..4652e8f 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -253,6 +253,13 @@ public: return Insert(SwitchInst::Create(V, Dest, NumCases)); } + /// CreateIndirectBr - Create an indirect branch instruction with the + /// specified address operand, with an optional hint for the number of + /// destinations that will be added (for efficient allocation). + IndirectBrInst *CreateIndirectBr(Value *Addr, unsigned NumDests = 10) { + return Insert(IndirectBrInst::Create(Addr, NumDests)); + } + /// CreateInvoke - Create an invoke instruction. template<typename InputIterator> InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, @@ -383,15 +390,21 @@ public: return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name); } Value *CreateAnd(Value *LHS, Value *RHS, const Twine &Name = "") { - if (Constant *LC = dyn_cast<Constant>(LHS)) - if (Constant *RC = dyn_cast<Constant>(RHS)) + if (Constant *RC = dyn_cast<Constant>(RHS)) { + if (isa<ConstantInt>(RC) && cast<ConstantInt>(RC)->isAllOnesValue()) + return LHS; // LHS & -1 -> LHS + if (Constant *LC = dyn_cast<Constant>(LHS)) return Folder.CreateAnd(LC, RC); + } return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name); } Value *CreateOr(Value *LHS, Value *RHS, const Twine &Name = "") { - if (Constant *LC = dyn_cast<Constant>(LHS)) - if (Constant *RC = dyn_cast<Constant>(RHS)) + if (Constant *RC = dyn_cast<Constant>(RHS)) { + if (RC->isNullValue()) + return LHS; // LHS | 0 -> LHS + if (Constant *LC = dyn_cast<Constant>(LHS)) return Folder.CreateOr(LC, RC); + } return Insert(BinaryOperator::CreateOr(LHS, RHS), Name); } Value *CreateXor(Value *LHS, Value *RHS, const Twine &Name = "") { @@ -433,9 +446,6 @@ public: const Twine &Name = "") { return Insert(new AllocaInst(Ty, ArraySize), Name); } - FreeInst *CreateFree(Value *Ptr) { - return Insert(new FreeInst(Ptr)); - } // Provided to resolve 'CreateLoad(Ptr, "...")' correctly, instead of // converting the string to 'bool' for the isVolatile parameter. LoadInst *CreateLoad(Value *Ptr, const char *Name) { diff --git a/include/llvm/Support/InstVisitor.h b/include/llvm/Support/InstVisitor.h index 440657c..b2e5d58 100644 --- a/include/llvm/Support/InstVisitor.h +++ b/include/llvm/Support/InstVisitor.h @@ -160,13 +160,13 @@ public: RetTy visitReturnInst(ReturnInst &I) { DELEGATE(TerminatorInst);} RetTy visitBranchInst(BranchInst &I) { DELEGATE(TerminatorInst);} RetTy visitSwitchInst(SwitchInst &I) { DELEGATE(TerminatorInst);} + RetTy visitIndirectBrInst(IndirectBrInst &I) { DELEGATE(TerminatorInst);} RetTy visitInvokeInst(InvokeInst &I) { DELEGATE(TerminatorInst);} RetTy visitUnwindInst(UnwindInst &I) { DELEGATE(TerminatorInst);} RetTy visitUnreachableInst(UnreachableInst &I) { DELEGATE(TerminatorInst);} RetTy visitICmpInst(ICmpInst &I) { DELEGATE(CmpInst);} RetTy visitFCmpInst(FCmpInst &I) { DELEGATE(CmpInst);} - RetTy visitAllocaInst(AllocaInst &I) { DELEGATE(AllocationInst);} - RetTy visitFreeInst(FreeInst &I) { DELEGATE(Instruction); } + RetTy visitAllocaInst(AllocaInst &I) { DELEGATE(Instruction); } RetTy visitLoadInst(LoadInst &I) { DELEGATE(Instruction); } RetTy visitStoreInst(StoreInst &I) { DELEGATE(Instruction); } RetTy visitGetElementPtrInst(GetElementPtrInst &I){ DELEGATE(Instruction); } @@ -198,7 +198,6 @@ public: // RetTy visitTerminatorInst(TerminatorInst &I) { DELEGATE(Instruction); } RetTy visitBinaryOperator(BinaryOperator &I) { DELEGATE(Instruction); } - RetTy visitAllocationInst(AllocationInst &I) { DELEGATE(Instruction); } RetTy visitCmpInst(CmpInst &I) { DELEGATE(Instruction); } RetTy visitCastInst(CastInst &I) { DELEGATE(Instruction); } diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index 6fa618e..438b021e 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -14,7 +14,7 @@ #ifndef LLVM_SUPPORT_MATHEXTRAS_H #define LLVM_SUPPORT_MATHEXTRAS_H -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" namespace llvm { diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index eb4784c..f9a4d6d 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -15,7 +15,7 @@ #define LLVM_SUPPORT_MEMORYBUFFER_H #include "llvm/ADT/StringRef.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" #include <string> namespace llvm { diff --git a/include/llvm/Support/MemoryObject.h b/include/llvm/Support/MemoryObject.h index dec0f13..e193ca2 100644 --- a/include/llvm/Support/MemoryObject.h +++ b/include/llvm/Support/MemoryObject.h @@ -10,7 +10,7 @@ #ifndef MEMORYOBJECT_H #define MEMORYOBJECT_H -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" namespace llvm { diff --git a/include/llvm/Support/PointerLikeTypeTraits.h b/include/llvm/Support/PointerLikeTypeTraits.h index d64993f..b851404 100644 --- a/include/llvm/Support/PointerLikeTypeTraits.h +++ b/include/llvm/Support/PointerLikeTypeTraits.h @@ -15,7 +15,7 @@ #ifndef LLVM_SUPPORT_POINTERLIKETYPETRAITS_H #define LLVM_SUPPORT_POINTERLIKETYPETRAITS_H -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" namespace llvm { @@ -38,7 +38,7 @@ public: return static_cast<T*>(P); } - /// Note, we assume here that malloc returns objects at least 8-byte aligned. + /// Note, we assume here that malloc returns objects at least 4-byte aligned. /// However, this may be wrong, or pointers may be from something other than /// malloc. In this case, you should specialize this template to reduce this. /// diff --git a/include/llvm/Support/SlowOperationInformer.h b/include/llvm/Support/SlowOperationInformer.h index b30aa98..524049c 100644 --- a/include/llvm/Support/SlowOperationInformer.h +++ b/include/llvm/Support/SlowOperationInformer.h @@ -31,7 +31,7 @@ #include <string> #include <cassert> -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" namespace llvm { class SlowOperationInformer { diff --git a/include/llvm/Support/StandardPasses.h b/include/llvm/Support/StandardPasses.h index c71e6b9..1a6d06b 100644 --- a/include/llvm/Support/StandardPasses.h +++ b/include/llvm/Support/StandardPasses.h @@ -96,41 +96,43 @@ namespace llvm { return; } - if (UnitAtATime) - PM->add(createRaiseAllocationsPass()); // call %malloc -> malloc inst - PM->add(createCFGSimplificationPass()); // Clean up disgusting code if (UnitAtATime) { PM->add(createGlobalOptimizerPass()); // Optimize out global vars - PM->add(createGlobalDCEPass()); // Remove unused fns and globs - // IP Constant Propagation - PM->add(createIPConstantPropagationPass()); + + PM->add(createIPSCCPPass()); // IP SCCP PM->add(createDeadArgEliminationPass()); // Dead argument elimination } PM->add(createInstructionCombiningPass()); // Clean up after IPCP & DAE PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE - if (UnitAtATime) { - if (HaveExceptions) - PM->add(createPruneEHPass()); // Remove dead EH info - PM->add(createFunctionAttrsPass()); // Set readonly/readnone attrs - } + + // Start of CallGraph SCC passes. + if (UnitAtATime && HaveExceptions) + PM->add(createPruneEHPass()); // Remove dead EH info if (InliningPass) PM->add(InliningPass); + if (UnitAtATime) + PM->add(createFunctionAttrsPass()); // Set readonly/readnone attrs if (OptimizationLevel > 2) PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args + + // Start of function pass. + + PM->add(createScalarReplAggregatesPass()); // Break up aggregate allocas if (SimplifyLibCalls) PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations PM->add(createInstructionCombiningPass()); // Cleanup for scalarrepl. PM->add(createJumpThreadingPass()); // Thread jumps. PM->add(createCFGSimplificationPass()); // Merge & remove BBs - PM->add(createScalarReplAggregatesPass()); // Break up aggregate allocas PM->add(createInstructionCombiningPass()); // Combine silly seq's + + // FIXME: CondProp breaks critical edges, which is slow. PM->add(createCondPropagationPass()); // Propagate conditionals PM->add(createTailCallEliminationPass()); // Eliminate tail calls PM->add(createCFGSimplificationPass()); // Merge & remove BBs PM->add(createReassociatePass()); // Reassociate expressions PM->add(createLoopRotatePass()); // Rotate Loop PM->add(createLICMPass()); // Hoist loop invariants - PM->add(createLoopUnswitchPass(OptimizeSize)); + PM->add(createLoopUnswitchPass(OptimizeSize || OptimizationLevel < 3)); PM->add(createInstructionCombiningPass()); PM->add(createIndVarSimplifyPass()); // Canonicalize indvars PM->add(createLoopDeletionPass()); // Delete dead loops @@ -152,10 +154,15 @@ namespace llvm { if (UnitAtATime) { PM->add(createStripDeadPrototypesPass()); // Get rid of dead prototypes PM->add(createDeadTypeEliminationPass()); // Eliminate dead types - } - if (OptimizationLevel > 1 && UnitAtATime) - PM->add(createConstantMergePass()); // Merge dup global constants + // GlobalOpt already deletes dead functions and globals, at -O3 try a + // late pass of GlobalDCE. It is capable of deleting dead cycles. + if (OptimizationLevel > 2) + PM->add(createGlobalDCEPass()); // Remove dead fns and globals. + + if (OptimizationLevel > 1) + PM->add(createConstantMergePass()); // Merge dup global constants + } } static inline void addOnePass(PassManager *PM, Pass *P, bool AndVerify) { diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h index 8e28632..46ad9b6 100644 --- a/include/llvm/Support/TargetFolder.h +++ b/include/llvm/Support/TargetFolder.h @@ -179,6 +179,16 @@ public: Constant *CreatePtrToInt(Constant *C, const Type *DestTy) const { return CreateCast(Instruction::PtrToInt, C, DestTy); } + Constant *CreateZExtOrBitCast(Constant *C, const Type *DestTy) const { + if (C->getType() == DestTy) + return C; // avoid calling Fold + return Fold(ConstantExpr::getZExtOrBitCast(C, DestTy)); + } + Constant *CreateSExtOrBitCast(Constant *C, const Type *DestTy) const { + if (C->getType() == DestTy) + return C; // avoid calling Fold + return Fold(ConstantExpr::getSExtOrBitCast(C, DestTy)); + } Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const { if (C->getType() == DestTy) return C; // avoid calling Fold diff --git a/include/llvm/Support/Timer.h b/include/llvm/Support/Timer.h index 54f1da9..8a0f55d 100644 --- a/include/llvm/Support/Timer.h +++ b/include/llvm/Support/Timer.h @@ -15,7 +15,7 @@ #ifndef LLVM_SUPPORT_TIMER_H #define LLVM_SUPPORT_TIMER_H -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" #include "llvm/System/Mutex.h" #include <string> #include <vector> diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index e67ff85..66d6aaa 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -15,7 +15,7 @@ #define LLVM_SUPPORT_RAW_OSTREAM_H #include "llvm/ADT/StringRef.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" namespace llvm { class format_object_base; |