- Treat a live range defined by an implicit_def as a zero-sized one.
[oota-llvm.git] / include / llvm / CodeGen / MachineModuleInfo.h
index 791b8669489e6e09022b02ceca27c5e5dee27c67..f798e50c4338a4f0bcbcd886e7101514ae4373b2 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by James M. Laskey and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -33,7 +33,9 @@
 
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/UniqueVector.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/GlobalValue.h"
 #include "llvm/Pass.h"
 
@@ -96,7 +98,7 @@ private:
                                         // Dwarf writers.
   
 protected:
-  DebugInfoDesc(unsigned T) : Tag(T | LLVMDebugVersion) {}
+  explicit DebugInfoDesc(unsigned T) : Tag(T | LLVMDebugVersion) {}
   
 public:
   virtual ~DebugInfoDesc() {}
@@ -160,7 +162,7 @@ private:
   
 public:
   AnchorDesc();
-  AnchorDesc(AnchoredDesc *D);
+  explicit AnchorDesc(AnchoredDesc *D);
   
   // Accessors
   unsigned getAnchorTag() const { return AnchorTag; }
@@ -200,7 +202,7 @@ private:
 
 protected:
 
-  AnchoredDesc(unsigned T);
+  explicit AnchoredDesc(unsigned T);
 
 public:  
   // Accessors.
@@ -263,7 +265,7 @@ public:
   
   /// getAnchorString - Return a string used to label this descriptor's anchor.
   ///
-  static const char *AnchorString;
+  static const char *const AnchorString;
   virtual const char *getAnchorString() const;
     
 #ifndef NDEBUG
@@ -290,7 +292,7 @@ private:
   unsigned Flags;                       // Miscellaneous flags.
 
 public:
-  TypeDesc(unsigned T);
+  explicit TypeDesc(unsigned T);
 
   // Accessors
   DebugInfoDesc *getContext()                const { return Context; }
@@ -381,7 +383,7 @@ private:
   DebugInfoDesc *FromType;              // Type derived from.
 
 public:
-  DerivedTypeDesc(unsigned T);
+  explicit DerivedTypeDesc(unsigned T);
   
   // Accessors
   TypeDesc *getFromType() const {
@@ -420,7 +422,7 @@ private:
   std::vector<DebugInfoDesc *> Elements;// Information used to compose type.
 
 public:
-  CompositeTypeDesc(unsigned T);
+  explicit CompositeTypeDesc(unsigned T);
   
   // Accessors
   std::vector<DebugInfoDesc *> &getElements() { return Elements; }
@@ -535,7 +537,7 @@ private:
   DebugInfoDesc *TyDesc;                // Type of variable.
 
 public:
-  VariableDesc(unsigned T);
+  explicit VariableDesc(unsigned T);
 
   // Accessors
   DebugInfoDesc *getContext()                const { return Context; }
@@ -594,7 +596,7 @@ private:
   bool IsDefinition;                    // Is the global defined in context.
   
 protected:
-  GlobalDesc(unsigned T);
+  explicit GlobalDesc(unsigned T);
 
 public:
   // Accessors
@@ -662,7 +664,7 @@ public:
   
   /// getAnchorString - Return a string used to label this descriptor's anchor.
   ///
-  static const char *AnchorString;
+  static const char *const AnchorString;
   virtual const char *getAnchorString() const;
     
 #ifndef NDEBUG
@@ -699,7 +701,7 @@ public:
   
   /// getAnchorString - Return a string used to label this descriptor's anchor.
   ///
-  static const char *AnchorString;
+  static const char *const AnchorString;
   virtual const char *getAnchorString() const;
     
 #ifndef NDEBUG
@@ -754,6 +756,10 @@ public:
   DIDeserializer() {}
   ~DIDeserializer() {}
   
+  const std::map<GlobalVariable *, DebugInfoDesc *> &getGlobalDescs() const {
+    return GlobalDescs;
+  }
+
   /// Deserialize - Reconstitute a GlobalVariable into it's component
   /// DebugInfoDesc objects.
   DebugInfoDesc *Deserialize(Value *V);
@@ -809,6 +815,9 @@ public:
   /// Serialize - Recursively cast the specified descriptor into a
   /// GlobalVariable so that it can be serialized to a .bc or .ll file.
   GlobalVariable *Serialize(DebugInfoDesc *DD);
+
+  /// addDescriptor - Directly connect DD with existing GV.
+  void addDescriptor(DebugInfoDesc *DD, GlobalVariable *GV);
 };
 
 //===----------------------------------------------------------------------===//
@@ -835,6 +844,10 @@ public:
   /// serialization of a DebugInfoDesc.
   bool Verify(Value *V);
   bool Verify(GlobalVariable *GV);
+
+  /// isVerified - Return true if the specified GV has already been
+  /// verified as a debug information descriptor.
+  bool isVerified(GlobalVariable *GV);
 };
 
 //===----------------------------------------------------------------------===//
@@ -955,21 +968,16 @@ public:
 ///
 struct LandingPadInfo {
   MachineBasicBlock *LandingPadBlock;   // Landing pad block.
-  unsigned BeginLabel;                  // Label prior to invoke.
-  unsigned EndLabel;                    // Label after invoke.
+  SmallVector<unsigned, 1> BeginLabels; // Labels prior to invoke.
+  SmallVector<unsigned, 1> EndLabels;   // Labels after invoke.
   unsigned LandingPadLabel;             // Label at beginning of landing pad.
   Function *Personality;                // Personality function.
-  std::vector<unsigned> TypeIds;        // List of type ids.
-  bool IsFilter;                        // Indicate if the landing pad is a
-                                        // throw filter.
-  
-  LandingPadInfo(MachineBasicBlock *MBB)
+  std::vector<int> TypeIds;             // List of type ids (filters negative)
+
+  explicit LandingPadInfo(MachineBasicBlock *MBB)
   : LandingPadBlock(MBB)
-  , BeginLabel(0)
-  , EndLabel(0)
   , LandingPadLabel(0)
-  , TypeIds()
-  , IsFilter(false)
+  , Personality(NULL)  
   {}
 };
 
@@ -1021,8 +1029,27 @@ private:
   //
   std::vector<GlobalVariable *> TypeInfos;
 
+  // FilterIds - List of typeids encoding filters used in the current function.
+  //
+  std::vector<unsigned> FilterIds;
+
+  // FilterEnds - List of the indices in FilterIds corresponding to filter
+  // terminators.
+  //
+  std::vector<unsigned> FilterEnds;
+
+  // Personalities - Vector of all personality functions ever seen. Used to emit
+  // common EH frames.
+  std::vector<Function *> Personalities;
+
+  // UsedFunctions - the functions in the llvm.used list in a more easily
+  // searchable format.
+  SmallPtrSet<const Function *, 32> UsedFunctions;
+
+  bool CallsEHReturn;
+  bool CallsUnwindInit;
 public:
-  static const char ID; // Pass identifcation, replacement for typeid
+  static char ID; // Pass identification, replacement for typeid
 
   MachineModuleInfo();
   ~MachineModuleInfo();
@@ -1050,7 +1077,11 @@ public:
   
   /// Verify - Verify that a Value is debug information descriptor.
   ///
-  bool Verify(Value *V);
+  bool Verify(Value *V) { return VR.Verify(V); }
+
+  /// isVerified - Return true if the specified GV has already been
+  /// verified as a debug information descriptor.
+  bool isVerified(GlobalVariable *GV) { return VR.isVerified(GV); }
   
   /// AnalyzeModule - Scan the module for global debug information.
   ///
@@ -1060,9 +1091,11 @@ public:
   ///
   bool hasDebugInfo() const { return !CompileUnits.empty(); }
   
-  /// needsFrameInfo - Returns true if we need to gather callee-saved register
-  /// move info for the frame.
-  bool needsFrameInfo() const;
+  bool callsEHReturn() const { return CallsEHReturn; }
+  void setCallsEHReturn(bool b) { CallsEHReturn = b; }
+
+  bool callsUnwindInit() const { return CallsUnwindInit; }
+  void setCallsUnwindInit(bool b) { CallsUnwindInit = b; }
   
   /// NextLabelID - Return the next unique label id.
   ///
@@ -1072,10 +1105,10 @@ public:
     return ID;
   }
   
-  /// RecordLabel - Records location information and associates it with a
+  /// RecordSourceLine - Records location information and associates it with a
   /// label.  Returns a unique label ID used to generate a label and 
   /// provide correspondence to the source line list.
-  unsigned RecordLabel(unsigned Line, unsigned Column, unsigned Source);
+  unsigned RecordSourceLine(unsigned Line, unsigned Column, unsigned Source);
   
   /// InvalidateLabel - Inhibit use of the specified label # from
   /// MachineModuleInfo, for example because the code was deleted.
@@ -1147,7 +1180,7 @@ public:
     std::vector<T *> AnchoredDescs;
     for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
       GlobalVariable *GV = Globals[i];
-      
+
       // FIXME - In the short term, changes are too drastic to continue.
       if (DebugInfoDesc::TagFromGlobal(GV) == Desc.getTag() &&
           DebugInfoDesc::VersionFromGlobal(GV) == LLVMDebugVersion) {
@@ -1168,7 +1201,7 @@ public:
 
   /// RecordVariable - Indicate the declaration of  a local variable.
   ///
-  void RecordVariable(Value *V, unsigned FrameIndex);
+  void RecordVariable(GlobalValue *GV, unsigned FrameIndex);
   
   /// getRootScope - Return current functions root scope.
   ///
@@ -1201,25 +1234,48 @@ public:
   /// addPersonality - Provide the personality function for the exception
   /// information.
   void addPersonality(MachineBasicBlock *LandingPad, Function *Personality);
-  
+
+  /// getPersonalityIndex - Get index of the current personality function inside
+  /// Personalitites array
+  unsigned getPersonalityIndex() const;
+
+  /// getPersonalities - Return array of personality functions ever seen.
+  const std::vector<Function *>& getPersonalities() const {
+    return Personalities;
+  }
+
+  // UsedFunctions - Return set of the functions in the llvm.used list.
+  const SmallPtrSet<const Function *, 32>& getUsedFunctions() const {
+    return UsedFunctions;
+  }
+
   /// addCatchTypeInfo - Provide the catch typeinfo for a landing pad.
   ///
   void addCatchTypeInfo(MachineBasicBlock *LandingPad,
                         std::vector<GlobalVariable *> &TyInfo);
-                        
-  /// setIsFilterLandingPad - Indicates that the landing pad is a throw filter.
+
+  /// addFilterTypeInfo - Provide the filter typeinfo for a landing pad.
   ///
-  void setIsFilterLandingPad(MachineBasicBlock *LandingPad);
-                        
+  void addFilterTypeInfo(MachineBasicBlock *LandingPad,
+                         std::vector<GlobalVariable *> &TyInfo);
+
+  /// addCleanup - Add a cleanup action for a landing pad.
+  ///
+  void addCleanup(MachineBasicBlock *LandingPad);
+
   /// getTypeIDFor - Return the type id for the specified typeinfo.  This is 
   /// function wide.
   unsigned getTypeIDFor(GlobalVariable *TI);
-  
+
+  /// getFilterIDFor - Return the id of the filter encoded by TyIds.  This is
+  /// function wide.
+  int getFilterIDFor(std::vector<unsigned> &TyIds);
+
   /// TidyLandingPads - Remap landing pad labels and remove any deleted landing
   /// pads.
   void TidyLandingPads();
                         
-  /// getLandingPadInfos - Return a reference to the landing pad info for the
+  /// getLandingPads - Return a reference to the landing pad info for the
   /// current function.
   const std::vector<LandingPadInfo> &getLandingPads() const {
     return LandingPads;
@@ -1230,11 +1286,18 @@ public:
   const std::vector<GlobalVariable *> &getTypeInfos() const {
     return TypeInfos;
   }
-  
+
+  /// getFilterIds - Return a reference to the typeids encoding filters used in
+  /// the current function.
+  const std::vector<unsigned> &getFilterIds() const {
+    return FilterIds;
+  }
+
   /// getPersonality - Return a personality function if available.  The presence
   /// of one is required to emit exception handling info.
   Function *getPersonality() const;
 
+  DIDeserializer *getDIDeserializer() { return &DR; }
 }; // End class MachineModuleInfo
 
 } // End llvm namespace