[vmkit-commits] [vmkit] r81135 - in /vmkit/trunk: Makefile.rules include/mvm/Allocator.h lib/Mvm/Makefile lib/Mvm/StaticGCPass/ lib/Mvm/StaticGCPass/Makefile lib/Mvm/StaticGCPass/StaticGCPass.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Sep 6 14:38:31 PDT 2009
Author: geoffray
Date: Sun Sep 6 16:38:30 2009
New Revision: 81135
URL: http://llvm.org/viewvc/llvm-project?rev=81135&view=rev
Log:
Output ocaml GC metadata for now when building with llvm-gcc.
Added:
vmkit/trunk/lib/Mvm/StaticGCPass/
vmkit/trunk/lib/Mvm/StaticGCPass/Makefile
vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp
Modified:
vmkit/trunk/Makefile.rules
vmkit/trunk/include/mvm/Allocator.h
vmkit/trunk/lib/Mvm/Makefile
Modified: vmkit/trunk/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/Makefile.rules?rev=81135&r1=81134&r2=81135&view=diff
==============================================================================
--- vmkit/trunk/Makefile.rules (original)
+++ vmkit/trunk/Makefile.rules Sun Sep 6 16:38:30 2009
@@ -110,15 +110,15 @@
$(TOOLNAME).s : $(TOOLNAME).bc
$(Echo) Building $(BuildMode) Assembly file $(notdir $@)
- $(Verb) $(LOPT) -f $(TOOLNAME).bc -o $(TOOLNAME)-optimized.bc
- $(Verb) $(LLC) -disable-fp-elim -f $(TOOLNAME)-optimized.bc -o $(TOOLNAME).s
+ $(Verb) $(LOPT) -load=$(LibDir)/StaticGCPass.so -std-compile-opts -StaticGCPass -f $(TOOLNAME).bc -o vmkitoptimized.bc
+ $(Verb) $(LLC) -disable-fp-elim -f vmkitoptimized.bc -o $(TOOLNAME).s
$(ObjDir)/%.o: %.s $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.s for $(BuildMode) build" $(PIC_FLAG)
$(Verb) $(Compile.C) $< -o $(ObjDir)/$*.o
clean-local::
- $(Verb) $(RM) -f $(TOOLNAME)-optimized.bc $(TOOLNAME).bc $(TOOLNAME).s
+ $(Verb) $(RM) -f vmkitoptimized.bc $(TOOLNAME).bc $(TOOLNAME).s
endif
endif
Modified: vmkit/trunk/include/mvm/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Allocator.h?rev=81135&r1=81134&r2=81135&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Allocator.h (original)
+++ vmkit/trunk/include/mvm/Allocator.h Sun Sep 6 16:38:30 2009
@@ -21,8 +21,8 @@
class VirtualTable;
#ifdef WITH_LLVM_GCC
-extern "C" void __llvm_gcroot(const void*, void*) __attribute__((nothrow));
-#define llvm_gcroot(a, b) __llvm_gcroot(&a, b)
+extern "C" void __llvm_gcroot(const void**, void*) __attribute__((nothrow));
+#define llvm_gcroot(a, b) __llvm_gcroot((const void**)&a, b)
#else
#define llvm_gcroot(a, b)
#endif
Modified: vmkit/trunk/lib/Mvm/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Makefile?rev=81135&r1=81134&r2=81135&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Makefile (original)
+++ vmkit/trunk/lib/Mvm/Makefile Sun Sep 6 16:38:30 2009
@@ -12,6 +12,6 @@
EXTRA_DIST = BoehmGC GCMmap2
-DIRS = Allocator CommonThread $(GCLIB) Runtime Compiler
+DIRS = Allocator CommonThread $(GCLIB) Runtime Compiler StaticGCPass
include $(LEVEL)/Makefile.common
Added: vmkit/trunk/lib/Mvm/StaticGCPass/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/StaticGCPass/Makefile?rev=81135&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/StaticGCPass/Makefile (added)
+++ vmkit/trunk/lib/Mvm/StaticGCPass/Makefile Sun Sep 6 16:38:30 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 = StaticGCPass
+LOADABLE_MODULE = 1
+USEDLIBS =
+
+include $(LEVEL)/Makefile.common
+
Added: vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp?rev=81135&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp (added)
+++ vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp Sun Sep 6 16:38:30 2009
@@ -0,0 +1,63 @@
+//===---- StaticGCPass.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 VISIBILITY_HIDDEN StaticGCPass : public ModulePass {
+ public:
+ static char ID;
+
+ StaticGCPass() : ModulePass((intptr_t)&ID) {}
+
+ virtual bool runOnModule(Module& M);
+
+ /// getAnalysisUsage - We do not modify anything.
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ }
+
+ };
+
+ char StaticGCPass::ID = 0;
+ RegisterPass<StaticGCPass> X("StaticGCPass",
+ "Add GC information in files compiled with llvm-gcc");
+
+bool StaticGCPass::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("ocaml");
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+}
More information about the vmkit-commits
mailing list