[PATCH] Avoid JIT recursive compilation

Yaron Keren yaron.keren at gmail.com
Sun Jun 22 02:42:02 PDT 2014


JITEmitter::getPointerToGlobal is called while in compilation, it should not call upon TheJIT->getPointerToGlobal since it may start another recursive compilation. Instead, it should call itself and generate a stub.

http://reviews.llvm.org/D4244

Files:
  lib/ExecutionEngine/JIT/JITEmitter.cpp
  test/ExecutionEngine/test-alias.ll

Index: lib/ExecutionEngine/JIT/JITEmitter.cpp
===================================================================
--- lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -692,7 +692,7 @@
   if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
     // We can only handle simple cases.
     if (GlobalValue *GV = getSimpleAliasee(GA->getAliasee()))
-      return TheJIT->getPointerToGlobal(GV);
+      return getPointerToGlobal(GV, Reference, MayNeedFarStub);
     return nullptr;
   }
 
Index: test/ExecutionEngine/test-alias.ll
===================================================================
--- test/ExecutionEngine/test-alias.ll
+++ test/ExecutionEngine/test-alias.ll
@@ -0,0 +1,23 @@
+; RUN: %lli %s > /dev/null
+
+%class.C = type { i32 (...)** }
+
+ at _ZN1CD1Ev = alias void (%class.C*)* @_ZN1CD2Ev
+
+define x86_thiscallcc void @_ZN1CD2Ev(%class.C* %this) unnamed_addr #0 align 2 {
+entry:
+  %this.addr = alloca %class.C*, align 4
+  store %class.C* %this, %class.C** %this.addr, align 4
+  %this1 = load %class.C** %this.addr
+  ret void
+}
+
+define i32 @main() #1 {
+entry:
+  %retval = alloca i32, align 4
+  %c = alloca %class.C, align 4
+  call x86_thiscallcc void @_ZN1CD1Ev(%class.C* %c)
+  store i32 0, i32* %retval
+  %0 = load i32* %retval
+  ret i32 %0
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4244.10726.patch
Type: text/x-patch
Size: 1306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140622/85822531/attachment.bin>


More information about the llvm-commits mailing list