From 516d70399e8d83b10039d59d9c7f8d3aedf5b980 Mon Sep 17 00:00:00 2001 From: Michael Ilseman Date: Fri, 1 Mar 2013 18:48:54 +0000 Subject: Cache the result of Function::getIntrinsicID() in a DenseMap attached to the LLVMContext. This reduces the time actually spent doing string to ID conversion and shows a 10% improvement in compile time for a particularly bad case that involves ARM Neon intrinsics (these have many overloads). Patch by Jean-Luc Duprat! llvm-svn: 176365 --- llvm/lib/IR/Value.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'llvm/lib/IR/Value.cpp') diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 5bdce2b5425..adc702e05e6 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -195,6 +195,9 @@ void Value::setName(const Twine &NewName) { if (getSymTab(this, ST)) return; // Cannot set a name on this value (e.g. constant). + if (Function *F = dyn_cast(this)) + getContext().pImpl->IntrinsicIDCache.erase(F); + if (!ST) { // No symbol table to update? Just do the change. if (NameRef.empty()) { // Free the name for this value. @@ -307,7 +310,7 @@ void Value::replaceAllUsesWith(Value *New) { // Notify all ValueHandles (if present) that this value is going away. if (HasValueHandle) ValueHandleBase::ValueIsRAUWd(this, New); - + while (!use_empty()) { Use &U = *UseList; // Must handle Constants specially, we cannot call replaceUsesOfWith on a @@ -318,10 +321,10 @@ void Value::replaceAllUsesWith(Value *New) { continue; } } - + U.set(New); } - + if (BasicBlock *BB = dyn_cast(this)) BB->replaceSuccessorsPhiUsesWith(cast(New)); } -- cgit v1.2.3