Make JIT::runFunction clean up the generated stub function.
authorJeffrey Yasskin <jyasskin@google.com>
Fri, 12 Feb 2010 23:05:31 +0000 (23:05 +0000)
committerJeffrey Yasskin <jyasskin@google.com>
Fri, 12 Feb 2010 23:05:31 +0000 (23:05 +0000)
Patch by Shivram K!

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

lib/ExecutionEngine/JIT/JIT.cpp

index 59a9a3dfe0bc805291f5f424dead1cd2b686d8a3..3684a27744d62a32a872c00079cd3f26d6d8cd10 100644 (file)
@@ -553,8 +553,12 @@ GenericValue JIT::runFunction(Function *F,
   else
     ReturnInst::Create(F->getContext(), StubBB);           // Just return void.
 
-  // Finally, return the value returned by our nullary stub function.
-  return runFunction(Stub, std::vector<GenericValue>());
+  // Finally, call our nullary stub function.
+  GenericValue Result = runFunction(Stub, std::vector<GenericValue>());
+  // Erase it, since no other function can have a reference to it.
+  Stub->eraseFromParent();
+  // And return the result.
+  return Result;
 }
 
 void JIT::RegisterJITEventListener(JITEventListener *L) {