aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ExecutionEngine
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-04-22 05:02:46 +0000
committerChris Lattner <sabre@nondot.org>2006-04-22 05:02:46 +0000
commitb003d76cb3cf353264f2f0b8cb658371dd7b3181 (patch)
treee7916c4d5f9e74d047b4be697f1ce7dfb6385ab1 /lib/ExecutionEngine
parentba05f728b57264836aa0837de1744355f3237572 (diff)
downloadexternal_llvm-b003d76cb3cf353264f2f0b8cb658371dd7b3181.zip
external_llvm-b003d76cb3cf353264f2f0b8cb658371dd7b3181.tar.gz
external_llvm-b003d76cb3cf353264f2f0b8cb658371dd7b3181.tar.bz2
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r--lib/ExecutionEngine/ExecutionEngine.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index ab56f59..5cd83ff 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -103,7 +103,11 @@ static void *CreateArgv(ExecutionEngine *EE,
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.