[llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Apr 21 22:02:58 PDT 2006



Changes in directory llvm/lib/ExecutionEngine:

ExecutionEngine.cpp updated: 1.78 -> 1.79
---
Log message:

Fix JIT support for static ctors, which was apparently completely broken!

This allows Prolangs-C++/city and probably a bunch of other stuff to work
well with the new front-end


---
Diffs of the changes:  (+5 -1)

 ExecutionEngine.cpp |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.78 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.79
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.78	Wed Mar 22 23:43:58 2006
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp	Sat Apr 22 00:02:46 2006
@@ -103,7 +103,11 @@
 void ExecutionEngine::runStaticConstructorsDestructors(bool isDtors) {
   const char *Name = isDtors ? "llvm.global_dtors" : "llvm.global_ctors";
   GlobalVariable *GV = CurMod.getNamedGlobal(Name);
-  if (!GV || GV->isExternal() || !GV->hasInternalLinkage()) return;
+
+  // If this global has internal linkage, or if it has a use, then it must be
+  // an old-style (llvmgcc3) static ctor with __main linked in and in use.  If
+  // this is the case, don't execute any of the global ctors, __main will do it.
+  if (!GV || GV->isExternal() || GV->hasInternalLinkage()) return;
   
   // Should be an array of '{ int, void ()* }' structs.  The first value is the
   // init priority, which we ignore.






More information about the llvm-commits mailing list