aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-21 06:31:09 +0000
committerChris Lattner <sabre@nondot.org>2009-03-21 06:31:09 +0000
commitc50689bd1e8788a7fc8f19070b7505ff95034979 (patch)
treeee808cff455fc301dfad16664bbaada00c04febd /lib/CodeGen/CodeGenModule.cpp
parent81abbdd848aa02c30242bd22dcc6ffe024ae2957 (diff)
Add a fast path to CodeGenModule::getMangledName for almost all C functions,
speeding up the testcase in PR3810 by 60%. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67431 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index cc460c5959..b03513a014 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -156,8 +156,8 @@ static void setGlobalVisibility(llvm::GlobalValue *GV,
/// \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 @@ static void setGlobalVisibility(llvm::GlobalValue *GV,
/// 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)) {