[llvm-commits] [poolalloc] r117017 - /poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
John Criswell
criswell at uiuc.edu
Thu Oct 21 08:53:17 PDT 2010
Author: criswell
Date: Thu Oct 21 10:53:17 2010
New Revision: 117017
URL: http://llvm.org/viewvc/llvm-project?rev=117017&view=rev
Log:
Make order of global initializers work for both Mac OS X and Linux.
Modified:
poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=117017&r1=117016&r2=117017&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Thu Oct 21 10:53:17 2010
@@ -145,11 +145,9 @@
//
// Get the current set of static global constructors and add the new ctor
- // to the end of the list (the list seems to be initialized in reverse
- // order).
+ // to the list.
//
std::vector<Constant *> CurrentCtors;
- CurrentCtors.push_back (RuntimeCtorInit);
GlobalVariable * GVCtor = M.getNamedGlobal ("llvm.global_ctors");
if (GVCtor) {
if (Constant * C = GVCtor->getInitializer()) {
@@ -166,6 +164,16 @@
}
//
+ // The ctor list seems to be initialized in different orders on different
+ // platforms, and the priority settings don't seem to work. Examine the
+ // module's platform string and take a best guess to the order.
+ //
+ if (M.getTargetTriple().find ("linux") == std::string::npos)
+ CurrentCtors.insert (CurrentCtors.begin(), RuntimeCtorInit);
+ else
+ CurrentCtors.push_back (RuntimeCtorInit);
+
+ //
// Create a new initializer.
//
const ArrayType * AT = ArrayType::get (RuntimeCtorInit-> getType(),
More information about the llvm-commits
mailing list