[cfe-commits] r67431 - /cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Chris Lattner
sabre at nondot.org
Fri Mar 20 23:31:09 PDT 2009
Author: lattner
Date: Sat Mar 21 01:31:09 2009
New Revision: 67431
URL: http://llvm.org/viewvc/llvm-project?rev=67431&view=rev
Log:
Add a fast path to CodeGenModule::getMangledName for almost all C functions,
speeding up the testcase in PR3810 by 60%.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=67431&r1=67430&r2=67431&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Mar 21 01:31:09 2009
@@ -156,8 +156,8 @@
/// \brief Retrieves the mangled name for the given declaration.
///
/// If the given declaration requires a mangled name, returns an
-/// IdentifierInfo* containing the mangled name. Otherwise, returns
-/// the name of the declaration as an identifier.
+/// const char* containing the mangled name. Otherwise, returns
+/// the unmangled name.
///
/// FIXME: Returning an IdentifierInfo* here is a total hack. We
/// really need some kind of string abstraction that either stores a
@@ -171,6 +171,12 @@
/// caching mangled names. However, we should fix the problem above
/// first.
const char *CodeGenModule::getMangledName(const NamedDecl *ND) {
+ // In C, functions with no attributes never need to be mangled. Fastpath them.
+ if (!getLangOptions().CPlusPlus && !ND->hasAttrs()) {
+ assert(ND->getIdentifier() && "Attempt to mangle unnamed decl.");
+ return ND->getIdentifier()->getName();
+ }
+
llvm::SmallString<256> Name;
llvm::raw_svector_ostream Out(Name);
if (!mangleName(ND, Context, Out)) {
More information about the cfe-commits
mailing list