[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Constants.cpp Type.cpp Verifier.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Jun 28 14:39:06 PDT 2006



Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.88 -> 1.89
Constants.cpp updated: 1.154 -> 1.155
Type.cpp updated: 1.140 -> 1.141
Verifier.cpp updated: 1.156 -> 1.157
---
Log message:

Use hidden visibility to reduce the sizes of some .o files.  This chops 60K off a release llvm-dis.


---
Diffs of the changes:  (+47 -24)

 ConstantFolding.cpp |   29 +++++++++++++++++------------
 Constants.cpp       |   35 +++++++++++++++++++++++++----------
 Type.cpp            |    3 ++-
 Verifier.cpp        |    4 +++-
 4 files changed, 47 insertions(+), 24 deletions(-)


Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.88 llvm/lib/VMCore/ConstantFolding.cpp:1.89
--- llvm/lib/VMCore/ConstantFolding.cpp:1.88	Wed Jun 21 13:13:36 2006
+++ llvm/lib/VMCore/ConstantFolding.cpp	Wed Jun 28 16:38:54 2006
@@ -25,12 +25,13 @@
 #include "llvm/Function.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Visibility.h"
 #include <limits>
 #include <cmath>
 using namespace llvm;
 
 namespace {
-  struct ConstRules {
+  struct VISIBILITY_HIDDEN ConstRules {
     ConstRules() {}
     virtual ~ConstRules() {}
 
@@ -88,7 +89,7 @@
 //
 namespace {
 template<class ArgType, class SubClassName>
-class TemplateRules : public ConstRules {
+class VISIBILITY_HIDDEN TemplateRules : public ConstRules {
 
 
   //===--------------------------------------------------------------------===//
@@ -221,7 +222,8 @@
 // EmptyRules provides a concrete base class of ConstRules that does nothing
 //
 namespace {
-struct EmptyRules : public TemplateRules<Constant, EmptyRules> {
+struct VISIBILITY_HIDDEN EmptyRules
+  : public TemplateRules<Constant, EmptyRules> {
   static Constant *EqualTo(const Constant *V1, const Constant *V2) {
     if (V1 == V2) return ConstantBool::True;
     return 0;
@@ -238,7 +240,8 @@
 // BoolRules provides a concrete base class of ConstRules for the 'bool' type.
 //
 namespace {
-struct BoolRules : public TemplateRules<ConstantBool, BoolRules> {
+struct VISIBILITY_HIDDEN BoolRules
+  : public TemplateRules<ConstantBool, BoolRules> {
 
   static Constant *LessThan(const ConstantBool *V1, const ConstantBool *V2) {
     return ConstantBool::get(V1->getValue() < V2->getValue());
@@ -290,8 +293,8 @@
 // pointers.
 //
 namespace {
-struct NullPointerRules : public TemplateRules<ConstantPointerNull,
-                                               NullPointerRules> {
+struct VISIBILITY_HIDDEN NullPointerRules
+  : public TemplateRules<ConstantPointerNull, NullPointerRules> {
   static Constant *EqualTo(const Constant *V1, const Constant *V2) {
     return ConstantBool::True;  // Null pointers are always equal
   }
@@ -357,7 +360,7 @@
 /// ConstantPacked operands.
 ///
 namespace {
-struct ConstantPackedRules
+struct VISIBILITY_HIDDEN ConstantPackedRules
   : public TemplateRules<ConstantPacked, ConstantPackedRules> {
   
   static Constant *Add(const ConstantPacked *V1, const ConstantPacked *V2) {
@@ -417,7 +420,8 @@
 /// cause for this is that one operand is a ConstantAggregateZero.
 ///
 namespace {
-struct GeneralPackedRules : public TemplateRules<Constant, GeneralPackedRules> {
+struct VISIBILITY_HIDDEN GeneralPackedRules
+  : public TemplateRules<Constant, GeneralPackedRules> {
 };
 }  // end anonymous namespace
 
@@ -432,7 +436,8 @@
 //
 namespace {
 template<class ConstantClass, class BuiltinType, Type **Ty, class SuperClass>
-struct DirectRules : public TemplateRules<ConstantClass, SuperClass> {
+struct VISIBILITY_HIDDEN DirectRules
+  : public TemplateRules<ConstantClass, SuperClass> {
   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 @@
 //
 namespace {
 template <class ConstantClass, class BuiltinType, Type **Ty>
-struct DirectIntRules
+struct VISIBILITY_HIDDEN DirectIntRules
   : public DirectRules<ConstantClass, BuiltinType, Ty,
                        DirectIntRules<ConstantClass, BuiltinType, Ty> > {
 
@@ -560,7 +565,7 @@
 ///
 namespace {
 template <class ConstantClass, class BuiltinType, Type **Ty>
-struct DirectFPRules
+struct VISIBILITY_HIDDEN DirectFPRules
   : public DirectRules<ConstantClass, BuiltinType, Ty,
                        DirectFPRules<ConstantClass, BuiltinType, Ty> > {
   static Constant *Rem(const ConstantClass *V1, const ConstantClass *V2) {
@@ -1472,7 +1477,7 @@
           dyn_cast<PointerType>(CE->getOperand(0)->getType()))
         if (const ArrayType *SAT = dyn_cast<ArrayType>(SPT->getElementType()))
           if (const ArrayType *CAT =
-              dyn_cast<ArrayType>(cast<PointerType>(C->getType())->getElementType()))
+        dyn_cast<ArrayType>(cast<PointerType>(C->getType())->getElementType()))
             if (CAT->getElementType() == SAT->getElementType())
               return ConstantExpr::getGetElementPtr(
                       (Constant*)CE->getOperand(0), IdxList);


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.154 llvm/lib/VMCore/Constants.cpp:1.155
--- llvm/lib/VMCore/Constants.cpp:1.154	Fri Jun  9 23:16:23 2006
+++ llvm/lib/VMCore/Constants.cpp	Wed Jun 28 16:38:54 2006
@@ -20,6 +20,7 @@
 #include "llvm/Module.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Visibility.h"
 #include <algorithm>
 #include <iostream>
 using namespace llvm;
@@ -308,12 +309,14 @@
 
 /// 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 @@
 
 /// 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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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<Constant*> &IdxList,
                             const Type *DestTy)
     : ConstantExpr(DestTy, Instruction::GetElementPtr,
@@ -406,6 +420,7 @@
     delete [] OperandList;
   }
 };
+}
 
 /// ConstantExpr::get* - Return some common constants without having to
 /// specify the full Instruction::OPCODE identifier.
@@ -541,14 +556,14 @@
 //
 namespace llvm {
   template<class ConstantClass, class TypeClass, class ValType>
-  struct ConstantCreator {
+  struct VISIBILITY_HIDDEN ConstantCreator {
     static ConstantClass *create(const TypeClass *Ty, const ValType &V) {
       return new ConstantClass(Ty, V);
     }
   };
 
   template<class ConstantClass, class TypeClass>
-  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 {
   template<class ValType, class TypeClass, class ConstantClass,
            bool HasLargeKey = false  /*true for arrays and structs*/ >
-  class ValueMap : public AbstractTypeUser {
+  class VISIBILITY_HIDDEN ValueMap : public AbstractTypeUser {
   public:
     typedef std::pair<const TypeClass*, ValType> MapKey;
     typedef std::map<MapKey, ConstantClass *> MapTy;


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.140 llvm/lib/VMCore/Type.cpp:1.141
--- llvm/lib/VMCore/Type.cpp:1.140	Sun May 28 21:34:34 2006
+++ llvm/lib/VMCore/Type.cpp	Wed Jun 28 16:38:54 2006
@@ -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 <algorithm>
 #include <iostream>
 using namespace llvm;
@@ -366,7 +367,7 @@
 //===----------------------------------------------------------------------===//
 
 namespace {
-  struct PrimType : public Type {
+  struct VISIBILITY_HIDDEN PrimType : public Type {
     PrimType(const char *S, TypeID ID) : Type(S, ID) {}
   };
 }


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.156 llvm/lib/VMCore/Verifier.cpp:1.157
--- llvm/lib/VMCore/Verifier.cpp:1.156	Fri May 19 16:25:17 2006
+++ llvm/lib/VMCore/Verifier.cpp	Wed Jun 28 16:38:54 2006
@@ -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 <algorithm>
 #include <iostream>
 #include <sstream>
@@ -65,7 +66,8 @@
 
 namespace {  // Anonymous namespace for class
 
-  struct Verifier : public FunctionPass, InstVisitor<Verifier> {
+  struct VISIBILITY_HIDDEN
+     Verifier : public FunctionPass, InstVisitor<Verifier> {
     bool Broken;          // Is this module found to be broken?
     bool RealPass;        // Are we not being run by a PassManager?
     VerifierFailureAction action;






More information about the llvm-commits mailing list