[PATCH] Avoid JIT recursive compilation

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


Calling getSimpleAliasee twice is not needed either.

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
@@ -691,9 +691,9 @@
 
   if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
     // We can only handle simple cases.
-    if (GlobalValue *GV = getSimpleAliasee(GA->getAliasee()))
-      return TheJIT->getPointerToGlobal(GV);
-    return nullptr;
+    V = getSimpleAliasee(GA->getAliasee());
+    if (!V)
+      return nullptr;
   }
 
   // If we have already compiled the function, return a pointer to its body.
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.10728.patch
Type: text/x-patch
Size: 1402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140622/d26b15bf/attachment.bin>


More information about the llvm-commits mailing list