Avoid doing pointless work. Amazingly, this makes us go faster.
authorChris Lattner <sabre@nondot.org>
Mon, 6 Oct 2003 15:23:43 +0000 (15:23 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 6 Oct 2003 15:23:43 +0000 (15:23 +0000)
Running the inliner on 252.eon used to take 48.4763s, now it takes 14.4148s.

In release mode, it went from taking 25.8741s to taking 11.5712s.

This also fixes a FIXME.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8890 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/InlineFunction.cpp
lib/Transforms/Utils/ValueMapper.cpp

index 22377b759c8ad3597e48e716632e6c2acefa92e0..01ffb253e4bd120a7ccb068f446b304a657e0571 100644 (file)
@@ -124,14 +124,6 @@ bool InlineFunction(CallSite CS) {
   // Make a vector to capture the return instructions in the cloned function...
   std::vector<ReturnInst*> Returns;
 
-  // Populate the value map with all of the globals in the program.
-  // FIXME: This should be the default for CloneFunctionInto!
-  Module &M = *Caller->getParent();
-  for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
-    ValueMap[I] = I;
-  for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I)
-    ValueMap[I] = I;
-
   // Do all of the hard part of cloning the callee into the caller...
   CloneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i");
 
index 484765a7e25a19b0d51db3a005e016f88c8fd404..d79c21f474ebf31a3a3d42b7a0f76419d4d45f3b 100644 (file)
@@ -13,6 +13,11 @@ Value *MapValue(const Value *V, std::map<const Value*, Value*> &VM) {
   Value *&VMSlot = VM[V];
   if (VMSlot) return VMSlot;      // Does it exist in the map yet?
   
+  // Global values do not need to be seeded into the ValueMap if they are using
+  // the identity mapping.
+  if (isa<GlobalValue>(V))
+    return VMSlot = const_cast<Value*>(V);
+
   if (Constant *C = const_cast<Constant*>(dyn_cast<Constant>(V))) {
     if (isa<ConstantIntegral>(C) || isa<ConstantFP>(C) ||
         isa<ConstantPointerNull>(C))