[cfe-commits] r63576 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CGCall.h CodeGenTypes.h
Daniel Dunbar
daniel at zuster.org
Mon Feb 2 16:07:12 PST 2009
Author: ddunbar
Date: Mon Feb 2 18:07:12 2009
New Revision: 63576
URL: http://llvm.org/viewvc/llvm-project?rev=63576&view=rev
Log:
Memoize CGFunctionInfo construction.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCall.h
cfe/trunk/lib/CodeGen/CodeGenTypes.h
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=63576&r1=63575&r2=63576&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Feb 2 18:07:12 2009
@@ -86,7 +86,18 @@
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
const llvm::SmallVector<QualType, 16> &ArgTys) {
- return *new CGFunctionInfo(ResTy, ArgTys);
+ // Lookup or create unique function info.
+ llvm::FoldingSetNodeID ID;
+ CGFunctionInfo::Profile(ID, ResTy, ArgTys.begin(), ArgTys.end());
+
+ void *InsertPos = 0;
+ CGFunctionInfo *FI = FunctionInfos.FindNodeOrInsertPos(ID, InsertPos);
+ if (FI)
+ return *FI;
+
+ FI = new CGFunctionInfo(ResTy, ArgTys);
+ FunctionInfos.InsertNode(FI, InsertPos);
+ return *FI;
}
/***/
Modified: cfe/trunk/lib/CodeGen/CGCall.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.h?rev=63576&r1=63575&r2=63576&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.h (original)
+++ cfe/trunk/lib/CodeGen/CGCall.h Mon Feb 2 18:07:12 2009
@@ -15,6 +15,7 @@
#ifndef CLANG_CODEGEN_CGCALL_H
#define CLANG_CODEGEN_CGCALL_H
+#include <llvm/ADT/FoldingSet.h>
#include "clang/AST/Type.h"
#include "CGValue.h"
@@ -49,7 +50,7 @@
/// CGFunctionInfo - Class to encapsulate the information about a
/// function definition.
- class CGFunctionInfo {
+ class CGFunctionInfo : public llvm::FoldingSetNode {
llvm::SmallVector<QualType, 16> ArgTypes;
public:
@@ -62,6 +63,19 @@
arg_iterator arg_end() const;
QualType getReturnType() const { return ArgTypes[0]; }
+
+ void Profile(llvm::FoldingSetNodeID &ID) {
+ Profile(ID, getReturnType(), arg_begin(), arg_end());
+ }
+ template<class Iterator>
+ static void Profile(llvm::FoldingSetNodeID &ID,
+ QualType ResTy,
+ Iterator begin,
+ Iterator end) {
+ ResTy.Profile(ID);
+ for (; begin != end; ++begin)
+ begin->Profile(ID);
+ }
};
} // end namespace CodeGen
} // end namespace clang
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=63576&r1=63575&r2=63576&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Mon Feb 2 18:07:12 2009
@@ -100,6 +100,9 @@
/// field no. This info is populated by record organizer.
llvm::DenseMap<const FieldDecl *, unsigned> FieldInfo;
+ /// FunctionInfos - Hold memoized CGFunctionInfo results.
+ llvm::FoldingSet<CGFunctionInfo> FunctionInfos;
+
public:
class BitFieldInfo {
public:
More information about the cfe-commits
mailing list