Fix references to functions
authorChris Lattner <sabre@nondot.org>
Mon, 13 Jan 2003 00:27:23 +0000 (00:27 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 13 Jan 2003 00:27:23 +0000 (00:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5222 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/InlineSimple.cpp

index 6dbab594e8cad48954196f58d4ab32d5104cc337..afa4890f035e6ed839760a960f52615014f9350b 100644 (file)
@@ -8,13 +8,8 @@
 //   * Is able to inline ANY function call
 //   . Has a smart heuristic for when to inline a function
 //
-// Notice that:
-//   * This pass opens up a lot of opportunities for constant propogation.  It
-//     is a good idea to to run a constant propogation pass, then a DCE pass 
-//     sometime after running this pass.
-//
 // FIXME: This pass should transform alloca instructions in the called function
-//        into malloc/free pairs!
+//        into malloc/free pairs!  Or perhaps it should refuse to inline them!
 //
 //===----------------------------------------------------------------------===//
 
@@ -105,6 +100,13 @@ bool InlineFunction(CallInst *CI) {
   // 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.
+  Module &M = *OrigBB->getParent()->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(OrigBB->getParent(), CalledFunc, ValueMap, Returns, ".i");