[vmkit-commits] [vmkit] r86495 - in /vmkit/trunk/lib/Mvm/Compiler: InlineMalloc.cpp JIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Nov 8 16:12:54 PST 2009
Author: geoffray
Date: Sun Nov 8 18:12:53 2009
New Revision: 86495
URL: http://llvm.org/viewvc/llvm-project?rev=86495&view=rev
Log:
Provide initial stub for inlining gcmalloc calls.
Added:
vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp
Modified:
vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
Added: vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp?rev=86495&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp (added)
+++ vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp Sun Nov 8 18:12:53 2009
@@ -0,0 +1,62 @@
+//===------------- InlineMalloc.cpp - Inline allocations -----------------===//
+//
+// The VMKit project
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Constants.h"
+#include "llvm/GlobalVariable.h"
+#include "llvm/Pass.h"
+#include "llvm/Function.h"
+#include "llvm/Instructions.h"
+#include "llvm/Support/CallSite.h"
+#include "llvm/Support/Debug.h"
+
+using namespace llvm;
+
+namespace mvm {
+
+ class InlineMalloc : public FunctionPass {
+ public:
+ static char ID;
+ InlineMalloc() : FunctionPass((intptr_t)&ID) {}
+
+ virtual bool runOnFunction(Function &F);
+ private:
+ };
+ char InlineMalloc::ID = 0;
+
+#if 0
+ static RegisterPass<InlineMalloc> X("InlineMalloc",
+ "Inline calls to gcmalloc");
+#endif
+
+
+bool InlineMalloc::runOnFunction(Function& F) {
+ bool Changed = false;
+ for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; BI++) {
+ BasicBlock *Cur = BI;
+ for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) {
+ Instruction *I = II;
+ II++;
+ CallSite Call = CallSite::get(I);
+ Instruction* CI = Call.getInstruction();
+ if (CI) {
+ Function* F = Call.getCalledFunction();
+ if (F && F->getName() == "gcmalloc") {
+ }
+ }
+ }
+ }
+ return Changed;
+}
+
+
+FunctionPass* createInlineMallocPass() {
+ return new InlineMalloc();
+}
+
+}
Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=86495&r1=86494&r2=86495&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Nov 8 18:12:53 2009
@@ -465,6 +465,10 @@
PM->add(P);
}
+namespace mvm {
+ llvm::FunctionPass* createInlineMallocPass();
+}
+
// This is equivalent to:
// opt -simplifycfg -mem2reg -instcombine -jump-threading -simplifycfg
// -scalarrepl -instcombine -condprop -simplifycfg -predsimplify
@@ -481,6 +485,11 @@
FunctionPassManager* PM = globalFunctionPasses;
PM->add(new TargetData(*MvmModule::TheTargetData));
+#ifdef WITH_MMTK
+ addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code
+ addPass(PM, createInlineMallocPass());
+#endif
+
addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code
addPass(PM, createPromoteMemoryToRegisterPass());// Kill useless allocas
More information about the vmkit-commits
mailing list