Commit 7d53825c by Jim Stichnoth

Subzero: Make thread_local work under MacOS 10.6.

MacOS doesn't support the thread_local keyword until 10.7 or later, and our bots run 10.6. Who knows whether Visual Studio supports it yet. In the meantime, use the old-style syntax. BUG= https://codereview.chromium.org/873443004/ R=jfb@chromium.org Review URL: https://codereview.chromium.org/865973006
parent f2e93b66
......@@ -25,7 +25,7 @@
namespace Ice {
thread_local const Cfg *Cfg::CurrentCfg = nullptr;
ICE_ATTRIBUTE_TLS const Cfg *Cfg::CurrentCfg = nullptr;
ArenaAllocator<> *getCurrentCfgAllocator() {
return Cfg::getCurrentCfgAllocator();
......
......@@ -213,7 +213,7 @@ private:
// Maintain a pointer in TLS to the current Cfg being translated.
// This is primarily for accessing its allocator statelessly, but
// other uses are possible.
thread_local static const Cfg *CurrentCfg;
ICE_ATTRIBUTE_TLS static const Cfg *CurrentCfg;
};
} // end of namespace Ice
......
......@@ -38,6 +38,15 @@
#include "llvm/Support/ELF.h"
#include "llvm/Support/raw_ostream.h"
// TODO(stichnot): Define ICE_ATTRIBUTE_TLS as thread_local after all
// compilers support that C++11 keyword. In particular, MacOS 10.6
// does not support it.
#if defined (_MSC_VER)
#define ICE_ATTRIBUTE_TLS __declspec(thread)
#else // !_MSC_VER
#define ICE_ATTRIBUTE_TLS __thread
#endif // !_MSC_VER
namespace Ice {
class Assembler;
......
......@@ -518,6 +518,6 @@ TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func)
}
}
thread_local GlobalContext::ThreadContext *GlobalContext::TLS;
ICE_ATTRIBUTE_TLS GlobalContext::ThreadContext *GlobalContext::TLS;
} // end of namespace Ice
......@@ -274,7 +274,7 @@ private:
std::vector<ThreadContext *> AllThreadContexts;
// Each thread has its own TLS pointer which is also held in
// AllThreadContexts.
thread_local static ThreadContext *TLS;
ICE_ATTRIBUTE_TLS static ThreadContext *TLS;
// Private helpers for mangleName()
typedef llvm::SmallVector<char, 32> ManglerVector;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment