[pypy-svn] r65032 - pypy/branch/pyjitpl5/pypy/jit/backend/llvm

arigo at codespeak.net arigo at codespeak.net
Mon May 4 19:18:02 CEST 2009


Author: arigo
Date: Mon May  4 19:18:00 2009
New Revision: 65032

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/llvm/demo2.cpp
   pypy/branch/pyjitpl5/pypy/jit/backend/llvm/demo2.h
   pypy/branch/pyjitpl5/pypy/jit/backend/llvm/llvm_rffi.py
   pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py
Log:
I'm hitting a wall.  Checking in anyway for reference.
The code produced by LLVM seems buggy, but only if
PerformTailCallOpt is set to true.


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llvm/demo2.cpp
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llvm/demo2.cpp	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llvm/demo2.cpp	Mon May  4 19:18:00 2009
@@ -3,19 +3,27 @@
 #include "llvm-c/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/GenericValue.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/Target/TargetOptions.h"
 #include "demo2.h"
 
 using namespace llvm;
 
 
-/* Missing pieces of the C interface...
+/* Set the flag to true.
+ */
+void _LLVM_SetFlags(void)
+{
+  PerformTailCallOpt = true;
+}
+
+/* This piece of code regroups conveniently a part of the initialization.
  */
 LLVMExecutionEngineRef _LLVM_EE_Create(LLVMModuleRef M)
 {
   LLVMModuleProviderRef mp = LLVMCreateModuleProviderForExistingModule(M);
   LLVMExecutionEngineRef ee;
   char* errormsg;
-  int error = LLVMCreateJITCompiler(&ee, mp, 1 /*Fast*/, &errormsg);
+  int error = LLVMCreateJITCompiler(&ee, mp, 0 /*Fast*/, &errormsg);
   if (error)
     {
       fprintf(stderr, "Error creating the JIT compiler:\n%s", errormsg);
@@ -24,6 +32,8 @@
   return ee;
 }
 
+/* Missing pieces of the C interface...
+ */
 void *_LLVM_EE_getPointerToFunction(LLVMExecutionEngineRef EE,
                                     LLVMValueRef F)
 {

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llvm/demo2.h
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llvm/demo2.h	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llvm/demo2.h	Mon May  4 19:18:00 2009
@@ -2,7 +2,8 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-  
+
+void _LLVM_SetFlags(void);
 LLVMExecutionEngineRef _LLVM_EE_Create(LLVMModuleRef M);
 void *_LLVM_EE_getPointerToFunction(LLVMExecutionEngineRef EE,
                                     LLVMValueRef F);

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llvm/llvm_rffi.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llvm/llvm_rffi.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llvm/llvm_rffi.py	Mon May  4 19:18:00 2009
@@ -43,7 +43,7 @@
 
 # ____________________________________________________________
 
-Debug = False
+Debug = True
 
 def llexternal(name, args, result, **kwds):
     ll = rffi.llexternal(name, args, result,
@@ -279,6 +279,7 @@
                               rffi.CArrayPtr(LLVMGenericValueRef)], # args
                              LLVMGenericValueRef)   # return value
 
+LLVM_SetFlags = llexternal('_LLVM_SetFlags', [], lltype.Void)
 LLVM_EE_Create = llexternal('_LLVM_EE_Create', [LLVMModuleRef],
                             LLVMExecutionEngineRef)
 LLVM_EE_getPointerToFunction = llexternal('_LLVM_EE_getPointerToFunction',

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py	Mon May  4 19:18:00 2009
@@ -26,6 +26,7 @@
     def setup_once(self):
         if not we_are_translated():
             teardown_now()
+        llvm_rffi.LLVM_SetFlags()
         self.module = llvm_rffi.LLVMModuleCreateWithName("pypyjit")
         if sys.maxint == 2147483647:
             self.ty_int = llvm_rffi.LLVMInt32Type()
@@ -267,7 +268,10 @@
         p[0] = intvalue
 
     def execute_operations(self, loop):
+        print 'execute_operations: %s' % (loop._llvm_func_addr,)
+        import time; time.sleep(2)
         res = loop._llvm_entry_stub(loop._llvm_func_addr)
+        print '\t--->', res
         return self.fail_ops[res]
 
     def get_latest_value_int(self, index):



More information about the Pypy-commit mailing list