[llvm-commits] [llvm] r53123 - in /llvm/trunk: include/llvm/CodeGen/MachineModuleInfo.h lib/CodeGen/DwarfWriter.cpp lib/CodeGen/MachineModuleInfo.cpp
Bill Wendling
isanbard at gmail.com
Thu Jul 3 16:13:02 PDT 2008
Author: void
Date: Thu Jul 3 18:13:02 2008
New Revision: 53123
URL: http://llvm.org/viewvc/llvm-project?rev=53123&view=rev
Log:
Don't return std::vector by value, but pass it in by reference to be filled.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
llvm/trunk/lib/CodeGen/DwarfWriter.cpp
llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=53123&r1=53122&r2=53123&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Thu Jul 3 18:13:02 2008
@@ -1152,16 +1152,17 @@
/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
/// named GlobalVariable.
- std::vector<GlobalVariable*>
- getGlobalVariablesUsing(Module &M, const std::string &RootName);
+ void getGlobalVariablesUsing(Module &M, const std::string &RootName,
+ std::vector<GlobalVariable*> &Result);
/// getAnchoredDescriptors - Return a vector of anchored debug descriptors.
///
- template <class T>std::vector<T *> getAnchoredDescriptors(Module &M) {
+ template <class T>
+ void getAnchoredDescriptors(Module &M, std::vector<T*> &AnchoredDescs) {
T Desc;
- std::vector<GlobalVariable *> Globals =
- getGlobalVariablesUsing(M, Desc.getAnchorString());
- std::vector<T *> AnchoredDescs;
+ std::vector<GlobalVariable *> Globals;
+ getGlobalVariablesUsing(M, Desc.getAnchorString(), Globals);
+
for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
GlobalVariable *GV = Globals[i];
@@ -1171,8 +1172,6 @@
AnchoredDescs.push_back(cast<T>(DR.Deserialize(GV)));
}
}
-
- return AnchoredDescs;
}
/// RecordRegionStart - Indicate the start of a region.
Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=53123&r1=53122&r2=53123&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Thu Jul 3 18:13:02 2008
@@ -2630,8 +2630,8 @@
/// ConstructGlobalDIEs - Create DIEs for each of the externally visible
/// global variables.
void ConstructGlobalDIEs() {
- std::vector<GlobalVariableDesc *> GlobalVariables =
- MMI->getAnchoredDescriptors<GlobalVariableDesc>(*M);
+ std::vector<GlobalVariableDesc *> GlobalVariables;
+ MMI->getAnchoredDescriptors<GlobalVariableDesc>(*M, GlobalVariables);
for (unsigned i = 0, N = GlobalVariables.size(); i < N; ++i) {
GlobalVariableDesc *GVD = GlobalVariables[i];
@@ -2642,8 +2642,8 @@
/// ConstructSubprogramDIEs - Create DIEs for each of the externally visible
/// subprograms.
void ConstructSubprogramDIEs() {
- std::vector<SubprogramDesc *> Subprograms =
- MMI->getAnchoredDescriptors<SubprogramDesc>(*M);
+ std::vector<SubprogramDesc *> Subprograms;
+ MMI->getAnchoredDescriptors<SubprogramDesc>(*M, Subprograms);
for (unsigned i = 0, N = Subprograms.size(); i < N; ++i) {
SubprogramDesc *SPD = Subprograms[i];
Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=53123&r1=53122&r2=53123&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Thu Jul 3 18:13:02 2008
@@ -52,10 +52,9 @@
/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
/// named GlobalVariable.
-static std::vector<GlobalVariable*>
-getGlobalVariablesUsing(Module &M, const std::string &RootName) {
- std::vector<GlobalVariable*> Result; // GlobalVariables matching criteria.
-
+static void
+getGlobalVariablesUsing(Module &M, const std::string &RootName,
+ std::vector<GlobalVariable*> &Result) {
std::vector<const Type*> FieldTypes;
FieldTypes.push_back(Type::Int32Ty);
FieldTypes.push_back(Type::Int32Ty);
@@ -65,11 +64,8 @@
StructType::get(FieldTypes));
// If present and linkonce then scan for users.
- if (UseRoot && UseRoot->hasLinkOnceLinkage()) {
+ if (UseRoot && UseRoot->hasLinkOnceLinkage())
getGlobalVariablesUsing(UseRoot, Result);
- }
-
- return Result;
}
/// isStringValue - Return true if the given value can be coerced to a string.
@@ -1593,7 +1589,8 @@
/// SetupCompileUnits - Set up the unique vector of compile units.
///
void MachineModuleInfo::SetupCompileUnits(Module &M) {
- std::vector<CompileUnitDesc *>CU = getAnchoredDescriptors<CompileUnitDesc>(M);
+ std::vector<CompileUnitDesc *> CU;
+ getAnchoredDescriptors<CompileUnitDesc>(M, CU);
for (unsigned i = 0, N = CU.size(); i < N; i++) {
CompileUnits.insert(CU[i]);
@@ -1608,10 +1605,11 @@
/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
/// named GlobalVariable.
-std::vector<GlobalVariable*>
+void
MachineModuleInfo::getGlobalVariablesUsing(Module &M,
- const std::string &RootName) {
- return ::getGlobalVariablesUsing(M, RootName);
+ const std::string &RootName,
+ std::vector<GlobalVariable*>&Result){
+ return ::getGlobalVariablesUsing(M, RootName, Result);
}
/// RecordSourceLine - Records location information and associates it with a
More information about the llvm-commits
mailing list