forked from OSchip/llvm-project
- Remove a use of std::vector.
- Make sure that we're not recalculating the size of a vector that never changes. llvm-svn: 52803
This commit is contained in:
parent
c758698d2c
commit
f96d046d7c
|
@ -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,32 +552,34 @@ 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 isDefinition() const { return IsDefinition; }
|
bool isStatic() const { return IsStatic; }
|
||||||
void setContext(DebugInfoDesc *C) { Context = C; }
|
bool isDefinition() const { return IsDefinition; }
|
||||||
void setName(const std::string &N) { Name = N; }
|
|
||||||
void setFullName(const std::string &N) { FullName = N; }
|
void setContext(DebugInfoDesc *C) { Context = C; }
|
||||||
void setLinkageName(const std::string &N) { LinkageName = N; }
|
void setName(const std::string &N) { Name = 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.
|
||||||
///
|
///
|
||||||
|
@ -593,8 +595,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.
|
||||||
|
@ -673,8 +675,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.
|
||||||
///
|
///
|
||||||
|
|
|
@ -591,7 +591,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(std::vector<unsigned> &TyIds);
|
int getFilterIDFor(SmallVectorImpl<unsigned> &TyIds);
|
||||||
|
|
||||||
/// TidyLandingPads - Remap landing pad labels and remove any deleted landing
|
/// TidyLandingPads - Remap landing pad labels and remove any deleted landing
|
||||||
/// pads.
|
/// pads.
|
||||||
|
|
|
@ -513,8 +513,8 @@ const PointerType *DISerializer::getEmptyStructPtrType() {
|
||||||
// If not already defined.
|
// If not already defined.
|
||||||
if (!EmptyStructPtrTy) {
|
if (!EmptyStructPtrTy) {
|
||||||
// Construct the empty structure type.
|
// Construct the empty structure type.
|
||||||
const StructType *EmptyStructTy =
|
const StructType *EmptyStructTy = StructType::get(NULL, NULL);
|
||||||
StructType::get(std::vector<const Type*>());
|
|
||||||
// Construct the pointer to empty structure type.
|
// Construct the pointer to empty structure type.
|
||||||
EmptyStructPtrTy = PointerType::getUnqual(EmptyStructTy);
|
EmptyStructPtrTy = PointerType::getUnqual(EmptyStructTy);
|
||||||
}
|
}
|
||||||
|
@ -532,6 +532,7 @@ 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,22 +552,27 @@ 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];
|
||||||
|
|
||||||
// Return Constant if previously defined.
|
// Return Constant if previously defined.
|
||||||
if (Slot) return Slot;
|
if (Slot) return Slot;
|
||||||
|
|
||||||
// If empty string then use a sbyte* null instead.
|
// If empty string then use a sbyte* null instead.
|
||||||
if (String.empty()) {
|
if (String.empty()) {
|
||||||
Slot = ConstantPointerNull::get(getStrPtrType());
|
Slot = ConstantPointerNull::get(getStrPtrType());
|
||||||
} else {
|
} else {
|
||||||
// Construct string as an llvm constant.
|
// Construct string as an llvm constant.
|
||||||
Constant *ConstStr = ConstantArray::get(String);
|
Constant *ConstStr = ConstantArray::get(String);
|
||||||
|
|
||||||
// Otherwise create and return a new string global.
|
// Otherwise create and return a new string global.
|
||||||
GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true,
|
GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true,
|
||||||
GlobalVariable::InternalLinkage,
|
GlobalVariable::InternalLinkage,
|
||||||
ConstStr, ".str", M);
|
ConstStr, ".str", M);
|
||||||
StrGV->setSection("llvm.metadata");
|
StrGV->setSection("llvm.metadata");
|
||||||
|
|
||||||
// Convert to generic string pointer.
|
// Convert to generic string pointer.
|
||||||
Slot = ConstantExpr::getBitCast(StrGV, getStrPtrType());
|
Slot = ConstantExpr::getBitCast(StrGV, getStrPtrType());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Slot;
|
return Slot;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -593,6 +599,7 @@ 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);
|
||||||
|
@ -996,9 +1003,11 @@ 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);
|
||||||
std::vector<unsigned> IdsInFilter (TyInfo.size());
|
SmallVector<unsigned, 32> 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,13 +1075,14 @@ 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(std::vector<unsigned> &TyIds) {
|
int MachineModuleInfo::getFilterIDFor(SmallVectorImpl<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 = TyIds.size();
|
unsigned i = *I, j = TyIDSize;
|
||||||
|
|
||||||
while (i && j)
|
while (i && j)
|
||||||
if (FilterIds[--i] != TyIds[--j])
|
if (FilterIds[--i] != TyIds[--j])
|
||||||
|
@ -1081,16 +1091,18 @@ int MachineModuleInfo::getFilterIDFor(std::vector<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.
|
||||||
int FilterID = -(1 + FilterIds.size());
|
unsigned FilterIDSize = FilterIds.size();
|
||||||
FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
|
int FilterID = -(1 + FilterIDSize);
|
||||||
for (unsigned I = 0, N = TyIds.size(); I != N; ++I)
|
FilterIds.reserve(FilterIDSize + TyIDSize + 1);
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
@ -1108,13 +1120,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; i != LandingPads.size(); ++i)
|
for (unsigned i = 0, e = LandingPads.size(); i != e; ++i)
|
||||||
if (LandingPads[i].Personality) {
|
if (LandingPads[i].Personality) {
|
||||||
Personality = LandingPads[i].Personality;
|
Personality = LandingPads[i].Personality;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < Personalities.size(); ++i) {
|
for (unsigned i = 0, e = Personalities.size(); i < e; ++i) {
|
||||||
if (Personalities[i] == Personality)
|
if (Personalities[i] == Personality)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue