Reverting broken patch r52803.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52806 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling
2008-06-27 01:27:56 +00:00
parent b827c26e1e
commit 914c970899
3 changed files with 60 additions and 91 deletions

View File

@@ -407,10 +407,10 @@ public:
SubrangeDesc(); SubrangeDesc();
// Accessors // Accessors
int64_t getLo() const { return Lo; } int64_t getLo() const { return Lo; }
int64_t getHi() const { return Hi; } int64_t getHi() const { return Hi; }
void setLo(int64_t L) { Lo = L; } void setLo(int64_t L) { Lo = L; }
void setHi(int64_t H) { Hi = H; } void setHi(int64_t H) { Hi = H; }
/// ApplyToFields - Target the visitor to the fields of the SubrangeDesc. /// ApplyToFields - Target the visitor to the fields of the SubrangeDesc.
/// ///
@@ -552,34 +552,32 @@ protected:
explicit GlobalDesc(unsigned T); explicit GlobalDesc(unsigned T);
public: public:
// Accessors // Accessors
DebugInfoDesc *getContext() const { return Context; } DebugInfoDesc *getContext() const { return Context; }
const std::string &getName() const { return Name; } const std::string &getName() const { return Name; }
const std::string &getFullName() const { return FullName; } const std::string &getFullName() const { return FullName; }
const std::string &getLinkageName() const { return LinkageName; } const std::string &getLinkageName() const { return LinkageName; }
CompileUnitDesc *getFile() const { CompileUnitDesc *getFile() const {
return static_cast<CompileUnitDesc *>(File); return static_cast<CompileUnitDesc *>(File);
} }
unsigned getLine() const { return Line; } unsigned getLine() const { return Line; }
TypeDesc *getType() const { TypeDesc *getType() const {
return static_cast<TypeDesc *>(TyDesc); return static_cast<TypeDesc *>(TyDesc);
} }
bool isStatic() const { return IsStatic; }
bool isStatic() const { return IsStatic; } bool isDefinition() const { return IsDefinition; }
bool isDefinition() const { return IsDefinition; } void setContext(DebugInfoDesc *C) { Context = C; }
void setName(const std::string &N) { Name = N; }
void setContext(DebugInfoDesc *C) { Context = C; } void setFullName(const std::string &N) { FullName = N; }
void setName(const std::string &N) { Name = N; } void setLinkageName(const std::string &N) { LinkageName = N; }
void setFullName(const std::string &N) { FullName = N; }
void setLinkageName(const std::string &N) { LinkageName = N; }
void setFile(CompileUnitDesc *U) { void setFile(CompileUnitDesc *U) {
File = static_cast<DebugInfoDesc *>(U); File = static_cast<DebugInfoDesc *>(U);
} }
void setLine(unsigned L) { Line = L; } void setLine(unsigned L) { Line = L; }
void setType(TypeDesc *T) { void setType(TypeDesc *T) {
TyDesc = static_cast<DebugInfoDesc *>(T); TyDesc = static_cast<DebugInfoDesc *>(T);
} }
void setIsStatic(bool IS) { IsStatic = IS; } void setIsStatic(bool IS) { IsStatic = IS; }
void setIsDefinition(bool ID) { IsDefinition = ID; } void setIsDefinition(bool ID) { IsDefinition = ID; }
/// ApplyToFields - Target the visitor to the fields of the GlobalDesc. /// ApplyToFields - Target the visitor to the fields of the GlobalDesc.
/// ///
@@ -595,8 +593,8 @@ public:
GlobalVariableDesc(); GlobalVariableDesc();
// Accessors. // Accessors.
GlobalVariable *getGlobalVariable() const { return Global; } GlobalVariable *getGlobalVariable() const { return Global; }
void setGlobalVariable(GlobalVariable *GV) { Global = GV; } void setGlobalVariable(GlobalVariable *GV) { Global = GV; }
/// ApplyToFields - Target the visitor to the fields of the /// ApplyToFields - Target the visitor to the fields of the
/// GlobalVariableDesc. /// GlobalVariableDesc.
@@ -675,8 +673,8 @@ public:
BlockDesc(); BlockDesc();
// Accessors // Accessors
DebugInfoDesc *getContext() const { return Context; } DebugInfoDesc *getContext() const { return Context; }
void setContext(DebugInfoDesc *C) { Context = C; } void setContext(DebugInfoDesc *C) { Context = C; }
/// ApplyToFields - Target the visitor to the fields of the BlockDesc. /// ApplyToFields - Target the visitor to the fields of the BlockDesc.
/// ///

View File

@@ -33,6 +33,7 @@
#include "llvm/GlobalValue.h" #include "llvm/GlobalValue.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/UniqueVector.h" #include "llvm/ADT/UniqueVector.h"
@@ -85,15 +86,10 @@ public:
/// DIDeserializer - This class is responsible for casting GlobalVariables /// DIDeserializer - This class is responsible for casting GlobalVariables
/// into DebugInfoDesc objects. /// into DebugInfoDesc objects.
class DIDeserializer { class DIDeserializer {
private: // Previously defined gloabls.
std::map<GlobalVariable *, DebugInfoDesc *> GlobalDescs; DenseMap<GlobalVariable*, DebugInfoDesc*> GlobalDescs;
// Previously defined gloabls.
public: public:
DIDeserializer() {} const DenseMap<GlobalVariable *, DebugInfoDesc *> &getGlobalDescs() const {
~DIDeserializer() {}
const std::map<GlobalVariable *, DebugInfoDesc *> &getGlobalDescs() const {
return GlobalDescs; return GlobalDescs;
} }
@@ -107,27 +103,23 @@ public:
/// DISerializer - This class is responsible for casting DebugInfoDesc objects /// DISerializer - This class is responsible for casting DebugInfoDesc objects
/// into GlobalVariables. /// into GlobalVariables.
class DISerializer { class DISerializer {
private:
Module *M; // Definition space module. Module *M; // Definition space module.
PointerType *StrPtrTy; // A "i8*" type. Created lazily. PointerType *StrPtrTy; // A "i8*" type. Created lazily.
PointerType *EmptyStructPtrTy; // A "{ }*" type. Created lazily. PointerType *EmptyStructPtrTy; // A "{ }*" type. Created lazily.
// Types per Tag. Created lazily.
std::map<unsigned, StructType *> TagTypes; std::map<unsigned, StructType *> TagTypes;
// Types per Tag. Created lazily.
std::map<DebugInfoDesc *, GlobalVariable *> DescGlobals; // Previously defined descriptors.
// Previously defined descriptors. DenseMap<DebugInfoDesc *, GlobalVariable *> DescGlobals;
std::map<const std::string, Constant *> StringCache;
// Previously defined strings. // Previously defined strings.
DenseMap<const char *, Constant*> StringCache;
public: public:
DISerializer() DISerializer()
: M(NULL) : M(NULL), StrPtrTy(NULL), EmptyStructPtrTy(NULL), TagTypes(),
, StrPtrTy(NULL) DescGlobals(), StringCache()
, EmptyStructPtrTy(NULL)
, TagTypes()
, DescGlobals()
, StringCache()
{} {}
~DISerializer() {}
// Accessors // Accessors
Module *getModule() const { return M; }; Module *getModule() const { return M; };
@@ -161,21 +153,17 @@ public:
/// DIVerifier - This class is responsible for verifying the given network of /// DIVerifier - This class is responsible for verifying the given network of
/// GlobalVariables are valid as DebugInfoDesc objects. /// GlobalVariables are valid as DebugInfoDesc objects.
class DIVerifier { class DIVerifier {
private:
enum { enum {
Unknown = 0, Unknown = 0,
Invalid, Invalid,
Valid Valid
}; };
std::map<GlobalVariable *, unsigned> Validity;// Tracks prior results. DenseMap<GlobalVariable *, unsigned> Validity; // Tracks prior results.
std::map<unsigned, unsigned> Counts; // Count of fields per Tag type. std::map<unsigned, unsigned> Counts; // Count of fields per Tag type.
public: public:
DIVerifier() DIVerifier()
: Validity() : Validity(), Counts()
, Counts()
{} {}
~DIVerifier() {}
/// Verify - Return true if the GlobalVariable appears to be a valid /// Verify - Return true if the GlobalVariable appears to be a valid
/// serialization of a DebugInfoDesc. /// serialization of a DebugInfoDesc.
@@ -191,12 +179,10 @@ public:
/// SourceLineInfo - This class is used to record source line correspondence. /// SourceLineInfo - This class is used to record source line correspondence.
/// ///
class SourceLineInfo { class SourceLineInfo {
private:
unsigned Line; // Source line number. unsigned Line; // Source line number.
unsigned Column; // Source column. unsigned Column; // Source column.
unsigned SourceID; // Source ID number. unsigned SourceID; // Source ID number.
unsigned LabelID; // Label in code ID number. unsigned LabelID; // Label in code ID number.
public: public:
SourceLineInfo(unsigned L, unsigned C, unsigned S, unsigned I) SourceLineInfo(unsigned L, unsigned C, unsigned S, unsigned I)
: Line(L), Column(C), SourceID(S), LabelID(I) {} : Line(L), Column(C), SourceID(S), LabelID(I) {}
@@ -212,10 +198,8 @@ public:
/// SourceFileInfo - This class is used to track source information. /// SourceFileInfo - This class is used to track source information.
/// ///
class SourceFileInfo { class SourceFileInfo {
private:
unsigned DirectoryID; // Directory ID number. unsigned DirectoryID; // Directory ID number.
std::string Name; // File name (not including directory.) std::string Name; // File name (not including directory.)
public: public:
SourceFileInfo(unsigned D, const std::string &N) : DirectoryID(D), Name(N) {} SourceFileInfo(unsigned D, const std::string &N) : DirectoryID(D), Name(N) {}
@@ -591,7 +575,7 @@ public:
/// getFilterIDFor - Return the id of the filter encoded by TyIds. This is /// getFilterIDFor - Return the id of the filter encoded by TyIds. This is
/// function wide. /// function wide.
int getFilterIDFor(SmallVectorImpl<unsigned> &TyIds); int getFilterIDFor(std::vector<unsigned> &TyIds);
/// TidyLandingPads - Remap landing pad labels and remove any deleted landing /// TidyLandingPads - Remap landing pad labels and remove any deleted landing
/// pads. /// pads.

View File

@@ -38,7 +38,7 @@ char MachineModuleInfo::ID = 0;
/// getGlobalVariablesUsing - Return all of the GlobalVariables which have the /// getGlobalVariablesUsing - Return all of the GlobalVariables which have the
/// specified value in their initializer somewhere. /// specified value in their initializer somewhere.
static void static void
getGlobalVariablesUsing(Value *V, std::vector<GlobalVariable*> &Result) { getGlobalVariablesUsing(Value *V, SmallVectorImpl<GlobalVariable*> &Result) {
// Scan though value users. // Scan though value users.
for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I) { for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(*I)) { if (GlobalVariable *GV = dyn_cast<GlobalVariable>(*I)) {
@@ -55,7 +55,7 @@ getGlobalVariablesUsing(Value *V, std::vector<GlobalVariable*> &Result) {
/// named GlobalVariable. /// named GlobalVariable.
static void static void
getGlobalVariablesUsing(Module &M, const std::string &RootName, getGlobalVariablesUsing(Module &M, const std::string &RootName,
std::vector<GlobalVariable*> &Result) { SmallVectorImpl<GlobalVariable*> &Result) {
std::vector<const Type*> FieldTypes; std::vector<const Type*> FieldTypes;
FieldTypes.push_back(Type::Int32Ty); FieldTypes.push_back(Type::Int32Ty);
FieldTypes.push_back(Type::Int32Ty); FieldTypes.push_back(Type::Int32Ty);
@@ -180,10 +180,7 @@ private:
public: public:
DIDeserializeVisitor(DIDeserializer &D, GlobalVariable *GV) DIDeserializeVisitor(DIDeserializer &D, GlobalVariable *GV)
: DIVisitor() : DIVisitor(), DR(D), I(0), CI(cast<ConstantStruct>(GV->getInitializer()))
, DR(D)
, I(0)
, CI(cast<ConstantStruct>(GV->getInitializer()))
{} {}
/// Apply - Set the value of each of the fields. /// Apply - Set the value of each of the fields.
@@ -276,7 +273,7 @@ public:
Elements.push_back(ConstantInt::get(Type::Int1Ty, Field)); Elements.push_back(ConstantInt::get(Type::Int1Ty, Field));
} }
virtual void Apply(std::string &Field) { virtual void Apply(std::string &Field) {
Elements.push_back(SR.getString(Field)); Elements.push_back(SR.getString(Field));
} }
virtual void Apply(DebugInfoDesc *&Field) { virtual void Apply(DebugInfoDesc *&Field) {
GlobalVariable *GV = NULL; GlobalVariable *GV = NULL;
@@ -511,14 +508,11 @@ const PointerType *DISerializer::getStrPtrType() {
/// ///
const PointerType *DISerializer::getEmptyStructPtrType() { const PointerType *DISerializer::getEmptyStructPtrType() {
// If not already defined. // If not already defined.
if (!EmptyStructPtrTy) { if (EmptyStructPtrTy) return EmptyStructPtrTy;
// Construct the empty structure type.
const StructType *EmptyStructTy = StructType::get(NULL, NULL);
// Construct the pointer to empty structure type. // Construct the pointer to empty structure type.
EmptyStructPtrTy = PointerType::getUnqual(EmptyStructTy); const StructType *EmptyStructTy =
} StructType::get(std::vector<const Type*>());
return EmptyStructPtrTy; return EmptyStructPtrTy;
} }
@@ -532,7 +526,6 @@ const StructType *DISerializer::getTagType(DebugInfoDesc *DD) {
if (!Ty) { if (!Ty) {
// Set up fields vector. // Set up fields vector.
std::vector<const Type*> Fields; std::vector<const Type*> Fields;
// Get types of fields. // Get types of fields.
DIGetTypesVisitor GTAM(*this, Fields); DIGetTypesVisitor GTAM(*this, Fields);
GTAM.ApplyToFields(DD); GTAM.ApplyToFields(DD);
@@ -551,7 +544,7 @@ const StructType *DISerializer::getTagType(DebugInfoDesc *DD) {
/// ///
Constant *DISerializer::getString(const std::string &String) { Constant *DISerializer::getString(const std::string &String) {
// Check string cache for previous edition. // Check string cache for previous edition.
Constant *&Slot = StringCache[String]; Constant *&Slot = StringCache[String.c_str()];
// Return Constant if previously defined. // Return Constant if previously defined.
if (Slot) return Slot; if (Slot) return Slot;
@@ -599,7 +592,6 @@ GlobalVariable *DISerializer::Serialize(DebugInfoDesc *DD) {
// Set up elements vector // Set up elements vector
std::vector<Constant*> Elements; std::vector<Constant*> Elements;
// Add fields. // Add fields.
DISerializeVisitor SRAM(*this, Elements); DISerializeVisitor SRAM(*this, Elements);
SRAM.ApplyToFields(DD); SRAM.ApplyToFields(DD);
@@ -839,7 +831,7 @@ const UniqueVector<CompileUnitDesc *> MachineModuleInfo::getCompileUnits()const{
void void
MachineModuleInfo::getAnchoredDescriptors(Module &M, const AnchoredDesc *Desc, MachineModuleInfo::getAnchoredDescriptors(Module &M, const AnchoredDesc *Desc,
std::vector<void*> &AnchoredDescs) { std::vector<void*> &AnchoredDescs) {
std::vector<GlobalVariable*> Globals; SmallVector<GlobalVariable*, 64> Globals;
getGlobalVariablesUsing(M, Desc->getAnchorString(), Globals); getGlobalVariablesUsing(M, Desc->getAnchorString(), Globals);
for (unsigned i = 0, N = Globals.size(); i < N; ++i) { for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
@@ -1003,11 +995,9 @@ void MachineModuleInfo::addCatchTypeInfo(MachineBasicBlock *LandingPad,
void MachineModuleInfo::addFilterTypeInfo(MachineBasicBlock *LandingPad, void MachineModuleInfo::addFilterTypeInfo(MachineBasicBlock *LandingPad,
std::vector<GlobalVariable *> &TyInfo) { std::vector<GlobalVariable *> &TyInfo) {
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad); LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
SmallVector<unsigned, 32> IdsInFilter(TyInfo.size()); std::vector<unsigned> IdsInFilter (TyInfo.size());
for (unsigned I = 0, E = TyInfo.size(); I != E; ++I) for (unsigned I = 0, E = TyInfo.size(); I != E; ++I)
IdsInFilter[I] = getTypeIDFor(TyInfo[I]); IdsInFilter[I] = getTypeIDFor(TyInfo[I]);
LP.TypeIds.push_back(getFilterIDFor(IdsInFilter)); LP.TypeIds.push_back(getFilterIDFor(IdsInFilter));
} }
@@ -1075,14 +1065,13 @@ unsigned MachineModuleInfo::getTypeIDFor(GlobalVariable *TI) {
/// getFilterIDFor - Return the filter id for the specified typeinfos. This is /// getFilterIDFor - Return the filter id for the specified typeinfos. This is
/// function wide. /// function wide.
int MachineModuleInfo::getFilterIDFor(SmallVectorImpl<unsigned> &TyIds) { int MachineModuleInfo::getFilterIDFor(std::vector<unsigned> &TyIds) {
// If the new filter coincides with the tail of an existing filter, then // If the new filter coincides with the tail of an existing filter, then
// re-use the existing filter. Folding filters more than this requires // re-use the existing filter. Folding filters more than this requires
// re-ordering filters and/or their elements - probably not worth it. // re-ordering filters and/or their elements - probably not worth it.
unsigned TyIDSize = TyIds.size();
for (std::vector<unsigned>::iterator I = FilterEnds.begin(), for (std::vector<unsigned>::iterator I = FilterEnds.begin(),
E = FilterEnds.end(); I != E; ++I) { E = FilterEnds.end(); I != E; ++I) {
unsigned i = *I, j = TyIDSize; unsigned i = *I, j = TyIds.size();
while (i && j) while (i && j)
if (FilterIds[--i] != TyIds[--j]) if (FilterIds[--i] != TyIds[--j])
@@ -1091,18 +1080,16 @@ int MachineModuleInfo::getFilterIDFor(SmallVectorImpl<unsigned> &TyIds) {
if (!j) if (!j)
// The new filter coincides with range [i, end) of the existing filter. // The new filter coincides with range [i, end) of the existing filter.
return -(1 + i); return -(1 + i);
try_next:; try_next:;
} }
// Add the new filter. // Add the new filter.
unsigned FilterIDSize = FilterIds.size(); int FilterID = -(1 + FilterIds.size());
int FilterID = -(1 + FilterIDSize); FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
FilterIds.reserve(FilterIDSize + TyIDSize + 1); for (unsigned I = 0, N = TyIds.size(); I != N; ++I)
for (unsigned I = 0, N = TyIDSize; I != N; ++I)
FilterIds.push_back(TyIds[I]); FilterIds.push_back(TyIds[I]);
FilterEnds.push_back(FilterIds.size());
FilterEnds.push_back(FilterIDSize);
FilterIds.push_back(0); // terminator FilterIds.push_back(0); // terminator
return FilterID; return FilterID;
} }
@@ -1120,13 +1107,13 @@ unsigned MachineModuleInfo::getPersonalityIndex() const {
const Function* Personality = NULL; const Function* Personality = NULL;
// Scan landing pads. If there is at least one non-NULL personality - use it. // Scan landing pads. If there is at least one non-NULL personality - use it.
for (unsigned i = 0, e = LandingPads.size(); i != e; ++i) for (unsigned i = 0; i != LandingPads.size(); ++i)
if (LandingPads[i].Personality) { if (LandingPads[i].Personality) {
Personality = LandingPads[i].Personality; Personality = LandingPads[i].Personality;
break; break;
} }
for (unsigned i = 0, e = Personalities.size(); i < e; ++i) { for (unsigned i = 0; i < Personalities.size(); ++i) {
if (Personalities[i] == Personality) if (Personalities[i] == Personality)
return i; return i;
} }