[oe-commits] Xerxes Rånby : llvm2.7: workaround llvm pr5201 / icedtea6 pr399 for ARM and PPC

git version control git at git.openembedded.org
Mon Jul 12 14:01:41 UTC 2010


Module: openembedded.git
Branch: org.openembedded.dev
Commit: 605dee9cbbff33645c23f475224d6fc4a97aa159
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=605dee9cbbff33645c23f475224d6fc4a97aa159

Author: Xerxes Rånby <xerxes at zafena.se>
Date:   Mon Jul 12 15:38:47 2010 +0200

llvm2.7: workaround llvm pr5201 / icedtea6 pr399 for ARM and PPC

---

 recipes/llvm/llvm2.7/arm_ppc.patch |  172 ++++++++++++++++++++++++++++++++++++
 recipes/llvm/llvm2.7_2.7.bb        |    3 +-
 2 files changed, 174 insertions(+), 1 deletions(-)

diff --git a/recipes/llvm/llvm2.7/arm_ppc.patch b/recipes/llvm/llvm2.7/arm_ppc.patch
new file mode 100644
index 0000000..d55230d
--- /dev/null
+++ b/recipes/llvm/llvm2.7/arm_ppc.patch
@@ -0,0 +1,172 @@
+Index: llvm-2.7/lib/ExecutionEngine/JIT/JIT.cpp
+===================================================================
+--- llvm-2.7.orig/lib/ExecutionEngine/JIT/JIT.cpp	2010-02-16 12:11:14.000000000 +0100
++++ llvm-2.7/lib/ExecutionEngine/JIT/JIT.cpp	2010-07-12 11:03:03.047811849 +0200
+@@ -254,7 +254,12 @@
+     MutexGuard guard(Lock);
+     JITs.erase(jit);
+   }
+-  void *getPointerToNamedFunction(const char *Name) const {
++  bool empty() {
++    MutexGuard guard(Lock);
++    return JITs.empty();
++  }
++  void *getPointerToNamedFunction(const char *Name,
++                                  bool AbortOnFailure = true) const {
+     MutexGuard guard(Lock);
+     assert(JITs.size() != 0 && "No Jit registered");
+     //search function in every instance of JIT
+@@ -266,7 +271,19 @@
+     }
+     // The function is not available : fallback on the first created (will
+     // search in symbol of the current program/library)
+-    return (*JITs.begin())->getPointerToNamedFunction(Name);
++    return (*JITs.begin())->getPointerToNamedFunction(Name, AbortOnFailure);
++  }
++  void *getPointerToGlobalIfAvailable(GlobalValue *V) const {
++    MutexGuard guard(Lock);
++    assert(JITs.size() != 0 && "No Jit registered");
++    //search function in every instance of JIT
++    for (SmallPtrSet<JIT*, 1>::const_iterator Jit = JITs.begin(),
++           end = JITs.end();
++         Jit != end; ++Jit) {
++      if (void *Ptr = (*Jit)->getPointerToGlobalIfAvailable(V))
++	return Ptr;
++    }
++    return 0;
+   }
+ };
+ ManagedStatic<JitPool> AllJits;
+@@ -282,6 +299,22 @@
+   }
+ }
+ 
++extern "C" {
++  // getPointerToNamedFunctionOrNull - same as the above, but returns
++  // NULL instead of aborting if the function cannot be found.
++  void *getPointerToNamedFunctionOrNull(const char *Name) {
++    return !AllJits->empty() ? AllJits->getPointerToNamedFunction(Name, false) : 0;
++  }
++}
++
++extern "C" {
++  // getPointerToGlobalIfAvailable - same as the above, but for global
++  // variables, and only for those that have been codegened already.
++  void *getPointerToGlobalIfAvailable(GlobalValue *V) {
++    return !AllJits->empty() ? AllJits->getPointerToGlobalIfAvailable(V) : 0;
++  }
++}
++
+ JIT::JIT(Module *M, TargetMachine &tm, TargetJITInfo &tji,
+          JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode)
+   : ExecutionEngine(M), TM(tm), TJI(tji), AllocateGVsWithCode(GVsWithCode),
+Index: llvm-2.7/lib/Target/PowerPC/PPCISelLowering.cpp
+===================================================================
+--- llvm-2.7.orig/lib/Target/PowerPC/PPCISelLowering.cpp	2010-03-02 02:55:18.000000000 +0100
++++ llvm-2.7/lib/Target/PowerPC/PPCISelLowering.cpp	2010-07-12 11:03:03.047811849 +0200
+@@ -2450,6 +2450,9 @@
+   InFlag = Chain.getValue(1);
+ }
+ 
++extern "C" void *getPointerToNamedFunctionOrNull(const char *Name);
++extern "C" void *getPointerToGlobalIfAvailable(GlobalValue *Value);
++
+ static
+ unsigned PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag,
+                      SDValue &Chain, DebugLoc dl, int SPDiff, bool isTailCall,
+@@ -2462,6 +2465,29 @@
+ 
+   unsigned CallOpc = isSVR4ABI ? PPCISD::CALL_SVR4 : PPCISD::CALL_Darwin;
+ 
++  // XXX Work around for http://llvm.org/bugs/show_bug.cgi?id=5201
++  // and http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=399
++  // for Shark.
++  //
++  // If the callee is an ExternalSymbol node, and the symbol can be
++  // resolved to a function pointer, then insert that pointer as a
++  // constant.  This causes the next block of code to fall into the
++  // block that emits an indirect call.  This works around
++  //
++  // This works for Shark because the only kinds of call that Shark
++  // makes that do not already fall into the indirect call block are
++  // calls to pre-existing external functions.
++  if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {
++    void *FuncPtr = getPointerToNamedFunctionOrNull(S->getSymbol());
++    if (FuncPtr)
++      Callee = DAG.getConstant((uint64_t) FuncPtr, PtrVT);
++  }
++  if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
++    void *FuncPtr = getPointerToGlobalIfAvailable(G->getGlobal());
++    if (FuncPtr)
++      Callee = DAG.getConstant((uint64_t) FuncPtr, PtrVT);
++  }
++
+   // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
+   // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
+   // node so that legalize doesn't hack it.
+Index: llvm-2.7/lib/Target/ARM/ARMISelLowering.cpp
+===================================================================
+--- llvm-2.7.orig/lib/Target/ARM/ARMISelLowering.cpp	2010-03-02 02:55:18.000000000 +0100
++++ llvm-2.7/lib/Target/ARM/ARMISelLowering.cpp	2010-07-12 11:03:03.057827385 +0200
+@@ -895,6 +895,9 @@
+   }
+ }
+ 
++extern "C" void *getPointerToNamedFunctionOrNull(const char *Name);
++extern "C" void *getPointerToGlobalIfAvailable(GlobalValue *Value);
++
+ /// LowerCall - Lowering a call into a callseq_start <-
+ /// ARMISD:CALL <- callseq_end chain. Also add input and output parameter
+ /// nodes.
+@@ -1004,6 +1007,31 @@
+     InFlag = Chain.getValue(1);
+   }
+ 
++  EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
++
++  // XXX Work around for http://llvm.org/bugs/show_bug.cgi?id=5201
++  // and http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=399
++  // for Shark.
++  //
++  // If the callee is an ExternalSymbol node, and the symbol can be
++  // resolved to a function pointer, then insert that pointer as a
++  // constant.  This causes the next block of code to fall into the
++  // block that emits an indirect call.  This works around
++  //
++  // This works for Shark because the only kinds of call that Shark
++  // makes that do not already fall into the indirect call block are
++  // calls to pre-existing external functions.
++  if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {
++    void *FuncPtr = getPointerToNamedFunctionOrNull(S->getSymbol());
++    if (FuncPtr)
++      Callee = DAG.getConstant((uint64_t) FuncPtr, PtrVT);
++  }
++  if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
++    void *FuncPtr = getPointerToGlobalIfAvailable(G->getGlobal());
++    if (FuncPtr)
++      Callee = DAG.getConstant((uint64_t) FuncPtr, PtrVT);
++  }
++
+   // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
+   // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
+   // node so that legalize doesn't hack it.
+Index: llvm-2.7/tools/llc/CMakeLists.txt
+===================================================================
+--- llvm-2.7.orig/tools/llc/CMakeLists.txt	2009-09-03 00:45:31.000000000 +0200
++++ llvm-2.7/tools/llc/CMakeLists.txt	2010-07-12 11:03:03.057827385 +0200
+@@ -1,4 +1,4 @@
+-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} bitreader asmparser)
++set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} jit bitreader asmparser)
+ 
+ add_llvm_tool(llc
+   llc.cpp
+Index: llvm-2.7/tools/llvm-mc/CMakeLists.txt
+===================================================================
+--- llvm-2.7.orig/tools/llvm-mc/CMakeLists.txt	2010-07-12 11:07:09.417811782 +0200
++++ llvm-2.7/tools/llvm-mc/CMakeLists.txt	2010-07-12 11:07:19.866561599 +0200
+@@ -1,4 +1,4 @@
+-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} support MC MCParser)
++set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} jit support MC MCParser)
+ 
+ add_llvm_tool(llvm-mc
+   llvm-mc.cpp
diff --git a/recipes/llvm/llvm2.7_2.7.bb b/recipes/llvm/llvm2.7_2.7.bb
index 68a950a..36d0ffc 100644
--- a/recipes/llvm/llvm2.7_2.7.bb
+++ b/recipes/llvm/llvm2.7_2.7.bb
@@ -1,11 +1,12 @@
 require llvm.inc
 
-PR = "r4"
+PR = "r5"
 
 DEPENDS = "llvm-common llvm2.7-native"
 
 SRC_URI = "\
   http://llvm.org/releases/${PV}/llvm-${PV}.tgz \
+  file://arm_ppc.patch \
   file://BX_to_BLX.patch \
   "
 





More information about the Openembedded-commits mailing list