From f190d3805519beb3ec9afe4adfda30e82dcd2995 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 28 Jun 2006 21:38:54 +0000 Subject: Use hidden visibility to reduce the sizes of some .o files. This chops 60K off a release llvm-dis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28969 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/ConstantFold.cpp | 29 +++++++++++++++++------------ lib/VMCore/Constants.cpp | 35 +++++++++++++++++++++++++---------- lib/VMCore/Type.cpp | 3 ++- lib/VMCore/Verifier.cpp | 4 +++- 4 files changed, 47 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 8c1398132f..e5ca2b37bc 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -25,12 +25,13 @@ #include "llvm/Function.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/Visibility.h" #include #include using namespace llvm; namespace { - struct ConstRules { + struct VISIBILITY_HIDDEN ConstRules { ConstRules() {} virtual ~ConstRules() {} @@ -88,7 +89,7 @@ namespace { // namespace { template -class TemplateRules : public ConstRules { +class VISIBILITY_HIDDEN TemplateRules : public ConstRules { //===--------------------------------------------------------------------===// @@ -221,7 +222,8 @@ public: // EmptyRules provides a concrete base class of ConstRules that does nothing // namespace { -struct EmptyRules : public TemplateRules { +struct VISIBILITY_HIDDEN EmptyRules + : public TemplateRules { static Constant *EqualTo(const Constant *V1, const Constant *V2) { if (V1 == V2) return ConstantBool::True; return 0; @@ -238,7 +240,8 @@ struct EmptyRules : public TemplateRules { // BoolRules provides a concrete base class of ConstRules for the 'bool' type. // namespace { -struct BoolRules : public TemplateRules { +struct VISIBILITY_HIDDEN BoolRules + : public TemplateRules { static Constant *LessThan(const ConstantBool *V1, const ConstantBool *V2) { return ConstantBool::get(V1->getValue() < V2->getValue()); @@ -290,8 +293,8 @@ struct BoolRules : public TemplateRules { // pointers. // namespace { -struct NullPointerRules : public TemplateRules { +struct VISIBILITY_HIDDEN NullPointerRules + : public TemplateRules { static Constant *EqualTo(const Constant *V1, const Constant *V2) { return ConstantBool::True; // Null pointers are always equal } @@ -357,7 +360,7 @@ static Constant *EvalVectorOp(const ConstantPacked *V1, /// ConstantPacked operands. /// namespace { -struct ConstantPackedRules +struct VISIBILITY_HIDDEN ConstantPackedRules : public TemplateRules { static Constant *Add(const ConstantPacked *V1, const ConstantPacked *V2) { @@ -417,7 +420,8 @@ struct ConstantPackedRules /// cause for this is that one operand is a ConstantAggregateZero. /// namespace { -struct GeneralPackedRules : public TemplateRules { +struct VISIBILITY_HIDDEN GeneralPackedRules + : public TemplateRules { }; } // end anonymous namespace @@ -432,7 +436,8 @@ struct GeneralPackedRules : public TemplateRules { // namespace { template -struct DirectRules : public TemplateRules { +struct VISIBILITY_HIDDEN DirectRules + : public TemplateRules { static Constant *Add(const ConstantClass *V1, const ConstantClass *V2) { BuiltinType R = (BuiltinType)V1->getValue() + (BuiltinType)V2->getValue(); return ConstantClass::get(*Ty, R); @@ -502,7 +507,7 @@ struct DirectRules : public TemplateRules { // namespace { template -struct DirectIntRules +struct VISIBILITY_HIDDEN DirectIntRules : public DirectRules > { @@ -560,7 +565,7 @@ struct DirectIntRules /// namespace { template -struct DirectFPRules +struct VISIBILITY_HIDDEN DirectFPRules : public DirectRules > { static Constant *Rem(const ConstantClass *V1, const ConstantClass *V2) { @@ -1472,7 +1477,7 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, dyn_cast(CE->getOperand(0)->getType())) if (const ArrayType *SAT = dyn_cast(SPT->getElementType())) if (const ArrayType *CAT = - dyn_cast(cast(C->getType())->getElementType())) + dyn_cast(cast(C->getType())->getElementType())) if (CAT->getElementType() == SAT->getElementType()) return ConstantExpr::getGetElementPtr( (Constant*)CE->getOperand(0), IdxList); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 3b55b652c0..080ae0d2fa 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -20,6 +20,7 @@ #include "llvm/Module.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/Visibility.h" #include #include using namespace llvm; @@ -308,12 +309,14 @@ ConstantPacked::~ConstantPacked() { /// UnaryConstantExpr - This class is private to Constants.cpp, and is used /// behind the scenes to implement unary constant exprs. -class UnaryConstantExpr : public ConstantExpr { +namespace { +class VISIBILITY_HIDDEN UnaryConstantExpr : public ConstantExpr { Use Op; public: UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) : ConstantExpr(Ty, Opcode, &Op, 1), Op(C, this) {} }; +} static bool isSetCC(unsigned Opcode) { return Opcode == Instruction::SetEQ || Opcode == Instruction::SetNE || @@ -323,7 +326,8 @@ static bool isSetCC(unsigned Opcode) { /// BinaryConstantExpr - This class is private to Constants.cpp, and is used /// behind the scenes to implement binary constant exprs. -class BinaryConstantExpr : public ConstantExpr { +namespace { +class VISIBILITY_HIDDEN BinaryConstantExpr : public ConstantExpr { Use Ops[2]; public: BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) @@ -333,10 +337,12 @@ public: Ops[1].init(C2, this); } }; +} /// SelectConstantExpr - This class is private to Constants.cpp, and is used /// behind the scenes to implement select constant exprs. -class SelectConstantExpr : public ConstantExpr { +namespace { +class VISIBILITY_HIDDEN SelectConstantExpr : public ConstantExpr { Use Ops[3]; public: SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) @@ -346,11 +352,13 @@ public: Ops[2].init(C3, this); } }; +} /// ExtractElementConstantExpr - This class is private to /// Constants.cpp, and is used behind the scenes to implement /// extractelement constant exprs. -class ExtractElementConstantExpr : public ConstantExpr { +namespace { +class VISIBILITY_HIDDEN ExtractElementConstantExpr : public ConstantExpr { Use Ops[2]; public: ExtractElementConstantExpr(Constant *C1, Constant *C2) @@ -360,11 +368,13 @@ public: Ops[1].init(C2, this); } }; +} /// InsertElementConstantExpr - This class is private to /// Constants.cpp, and is used behind the scenes to implement /// insertelement constant exprs. -class InsertElementConstantExpr : public ConstantExpr { +namespace { +class VISIBILITY_HIDDEN InsertElementConstantExpr : public ConstantExpr { Use Ops[3]; public: InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3) @@ -375,11 +385,13 @@ public: Ops[2].init(C3, this); } }; +} /// ShuffleVectorConstantExpr - This class is private to /// Constants.cpp, and is used behind the scenes to implement /// shufflevector constant exprs. -class ShuffleVectorConstantExpr : public ConstantExpr { +namespace { +class VISIBILITY_HIDDEN ShuffleVectorConstantExpr : public ConstantExpr { Use Ops[3]; public: ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3) @@ -390,10 +402,12 @@ public: Ops[2].init(C3, this); } }; +} /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is /// used behind the scenes to implement getelementpr constant exprs. -struct GetElementPtrConstantExpr : public ConstantExpr { +namespace { +struct VISIBILITY_HIDDEN GetElementPtrConstantExpr : public ConstantExpr { GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList, const Type *DestTy) : ConstantExpr(DestTy, Instruction::GetElementPtr, @@ -406,6 +420,7 @@ struct GetElementPtrConstantExpr : public ConstantExpr { delete [] OperandList; } }; +} /// ConstantExpr::get* - Return some common constants without having to /// specify the full Instruction::OPCODE identifier. @@ -541,14 +556,14 @@ bool ConstantFP::isValueValidForType(const Type *Ty, double Val) { // namespace llvm { template - struct ConstantCreator { + struct VISIBILITY_HIDDEN ConstantCreator { static ConstantClass *create(const TypeClass *Ty, const ValType &V) { return new ConstantClass(Ty, V); } }; template - struct ConvertConstantType { + struct VISIBILITY_HIDDEN ConvertConstantType { static void convert(ConstantClass *OldC, const TypeClass *NewTy) { assert(0 && "This type cannot be converted!\n"); abort(); @@ -559,7 +574,7 @@ namespace llvm { namespace { template - class ValueMap : public AbstractTypeUser { + class VISIBILITY_HIDDEN ValueMap : public AbstractTypeUser { public: typedef std::pair MapKey; typedef std::map MapTy; diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index a96efad744..a393556bc6 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -20,6 +20,7 @@ #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/Visibility.h" #include #include using namespace llvm; @@ -366,7 +367,7 @@ const Type *StructType::getTypeAtIndex(const Value *V) const { //===----------------------------------------------------------------------===// namespace { - struct PrimType : public Type { + struct VISIBILITY_HIDDEN PrimType : public Type { PrimType(const char *S, TypeID ID) : Type(S, ID) {} }; } diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 8a4cf2c0d5..d07345e932 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -57,6 +57,7 @@ #include "llvm/Support/InstVisitor.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Visibility.h" #include #include #include @@ -65,7 +66,8 @@ using namespace llvm; namespace { // Anonymous namespace for class - struct Verifier : public FunctionPass, InstVisitor { + struct VISIBILITY_HIDDEN + Verifier : public FunctionPass, InstVisitor { bool Broken; // Is this module found to be broken? bool RealPass; // Are we not being run by a PassManager? VerifierFailureAction action; -- cgit v1.2.3