[vmkit-commits] [vmkit] r86489 - in /vmkit/trunk/lib/Mvm/JITGCPass: ./ JITGCPass.cpp Makefile

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Nov 8 15:13:46 PST 2009


Author: geoffray
Date: Sun Nov  8 17:13:46 2009
New Revision: 86489

URL: http://llvm.org/viewvc/llvm-project?rev=86489&view=rev
Log:
Add forgotten files from previous commit.


Added:
    vmkit/trunk/lib/Mvm/JITGCPass/
    vmkit/trunk/lib/Mvm/JITGCPass/JITGCPass.cpp
    vmkit/trunk/lib/Mvm/JITGCPass/Makefile

Added: vmkit/trunk/lib/Mvm/JITGCPass/JITGCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JITGCPass/JITGCPass.cpp?rev=86489&view=auto

==============================================================================
--- vmkit/trunk/lib/Mvm/JITGCPass/JITGCPass.cpp (added)
+++ vmkit/trunk/lib/Mvm/JITGCPass/JITGCPass.cpp Sun Nov  8 17:13:46 2009
@@ -0,0 +1,63 @@
+//===------ JITGCPass.cpp - Put GC information in functions compiled ---------//
+//===----------------------- with llvm-gcc --------------------------------===//
+//
+//                     The VMKit project
+//
+// This file is distributed under the University of Illinois Open Source 
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include "llvm/Intrinsics.h"
+#include "llvm/Module.h"
+#include "llvm/Pass.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+namespace {
+
+  class JITGCPass : public ModulePass {
+  public:
+    static char ID;
+    
+    JITGCPass() : ModulePass((intptr_t)&ID) {}
+
+    virtual bool runOnModule(Module& M);
+
+    /// getAnalysisUsage - We do not modify anything.
+    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+      AU.setPreservesAll();
+    } 
+
+  };
+
+  char JITGCPass::ID = 0;
+  RegisterPass<JITGCPass> X("JITGCPass",
+                      "Add GC information in files compiled with llvm-gcc");
+
+bool JITGCPass::runOnModule(Module& M) {
+
+  Function* F = M.getFunction("__llvm_gcroot");
+  if (F) {
+    Function *gcrootFun = Intrinsic::getDeclaration(&M, Intrinsic::gcroot);
+
+    F->replaceAllUsesWith(gcrootFun);
+    F->eraseFromParent();
+
+    for (Value::use_iterator I = gcrootFun->use_begin(),
+         E = gcrootFun->use_end(); I != E; ++I) {
+      if (Instruction* II = dyn_cast<Instruction>(I)) {
+        Function* F = II->getParent()->getParent();
+        if (!F->hasGC()) F->setGC("vmkit");
+      }
+    }
+
+    return true;
+  }
+
+  return false;
+}
+
+}

Added: vmkit/trunk/lib/Mvm/JITGCPass/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JITGCPass/Makefile?rev=86489&view=auto

==============================================================================
--- vmkit/trunk/lib/Mvm/JITGCPass/Makefile (added)
+++ vmkit/trunk/lib/Mvm/JITGCPass/Makefile Sun Nov  8 17:13:46 2009
@@ -0,0 +1,16 @@
+##===- lib/Mvm/StaticGCPass/Makefile -----------------------*- Makefile -*-===##
+#
+#                            The VMKit project
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../../..
+LIBRARYNAME = JITGCPass
+LOADABLE_MODULE = 1
+USEDLIBS =
+
+include $(LEVEL)/Makefile.common
+





More information about the vmkit-commits mailing list