summaryrefslogtreecommitdiffstats
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
commitfe36eaebda5caffe447e72878a0068c5ec808639 (patch)
treea116d10d4765f583d407a75b276dc0e6e8c8b3e1
parent14215c36b655b6cd5736c27f21e1a1d075a3fa3d (diff)
downloadbcm5719-llvm-fe36eaebda5caffe447e72878a0068c5ec808639.tar.gz
bcm5719-llvm-fe36eaebda5caffe447e72878a0068c5ec808639.zip
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 llvm-svn: 27941
-rw-r--r--llvm/lib/ExecutionEngine/ExecutionEngine.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index ab56f592b04..5cd83ff51a3 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/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.
OpenPOWER on IntegriCloud