[llvm-branch-commits] [llvm-branch] r197778 - Merging r197718:

Bill Wendling isanbard at gmail.com
Thu Dec 19 20:26:57 PST 2013


Author: void
Date: Thu Dec 19 22:26:57 2013
New Revision: 197778

URL: http://llvm.org/viewvc/llvm-project?rev=197778&view=rev
Log:
Merging r197718:
------------------------------------------------------------------------
r197718 | hans | 2013-12-19 12:32:44 -0800 (Thu, 19 Dec 2013) | 10 lines

Make sys::ThreadLocal<> zero-initialized on non-thread builds (PR18205)

According to the docs, ThreadLocal<>::get() should return NULL
if no object has been set. This patch makes that the case also for non-thread
builds and adds a very basic unit test to check it.

(This was causing PR18205 because PrettyStackTraceHead didn't get zero-
initialized and we'd crash trying to read past the end of that list. We didn't
notice this so much on Linux since we'd crash after printing all the entries,
but on Mac we print into a SmallString, and would crash before printing that.)
------------------------------------------------------------------------

Added:
    llvm/branches/release_34/unittests/Support/ThreadLocalTest.cpp
      - copied unchanged from r197718, llvm/trunk/unittests/Support/ThreadLocalTest.cpp
Modified:
    llvm/branches/release_34/   (props changed)
    llvm/branches/release_34/lib/Support/ThreadLocal.cpp
    llvm/branches/release_34/lib/Support/Unix/ThreadLocal.inc
    llvm/branches/release_34/unittests/Support/CMakeLists.txt

Propchange: llvm/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 19 22:26:57 2013
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195136,195138,195148,195152,195156-195157,195161-195162,195193,195272,195317-195318,195327,195330,195333,195339,195343,195355,195364,195379,195397-195399,195401,195408,195411,195421,195423-195424,195432,195439,195444,195455-195456,195469,195476-195477,195479,195491-195495,195504-195505,195514,195528,195535,195547,195567,195573-195576,195590-195591,195599,195632,195635-195636,195670,195677,195679,195682,195684,195710,195713,195716,195769,195773,195779,195782,195787-195788,195791,195803,195812,195827,195834,195843-195844,195878-195881,195887,195903,195905,195912,195915,195932,195936-195943,195972-195973,195975-195976,196004,196044-196046,196069,196100,196104,196129,196144,196151,196153,196156,196158,196172,196189-196192,196198-196199,196208-196211,196261,196267,196269,196294,196359-196362,196369,196391,196456,196493,196508,196532-196533,196535,196538,196588,196611-196612,196637-196638,196658,196668,196725,196!
 735,19675
 1,196755,196768,196806,196858,197047,197089,197178,197215-197216,197228,197449
+/llvm/trunk:155241,195092-195094,195100,195102-195103,195129,195136,195138,195148,195152,195156-195157,195161-195162,195193,195272,195317-195318,195327,195330,195333,195339,195343,195355,195364,195379,195397-195399,195401,195408,195411,195421,195423-195424,195432,195439,195444,195455-195456,195469,195476-195477,195479,195491-195495,195504-195505,195514,195528,195535,195547,195567,195573-195576,195590-195591,195599,195632,195635-195636,195670,195677,195679,195682,195684,195710,195713,195716,195769,195773,195779,195782,195787-195788,195791,195803,195812,195827,195834,195843-195844,195878-195881,195887,195903,195905,195912,195915,195932,195936-195943,195972-195973,195975-195976,196004,196044-196046,196069,196100,196104,196129,196144,196151,196153,196156,196158,196172,196189-196192,196198-196199,196208-196211,196261,196267,196269,196294,196359-196362,196369,196391,196456,196493,196508,196532-196533,196535,196538,196588,196611-196612,196637-196638,196658,196668,196725,196735,196!
 751,19675
 5,196768,196806,196858,197047,197089,197178,197215-197216,197228,197449,197718

Modified: llvm/branches/release_34/lib/Support/ThreadLocal.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Support/ThreadLocal.cpp?rev=197778&r1=197777&r2=197778&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Support/ThreadLocal.cpp (original)
+++ llvm/branches/release_34/lib/Support/ThreadLocal.cpp Thu Dec 19 22:26:57 2013
@@ -23,7 +23,7 @@
 // Define all methods as no-ops if threading is explicitly disabled
 namespace llvm {
 using namespace sys;
-ThreadLocalImpl::ThreadLocalImpl() { }
+ThreadLocalImpl::ThreadLocalImpl() : data() { }
 ThreadLocalImpl::~ThreadLocalImpl() { }
 void ThreadLocalImpl::setInstance(const void* d) {
   typedef int SIZE_TOO_BIG[sizeof(d) <= sizeof(data) ? 1 : -1];

Modified: llvm/branches/release_34/lib/Support/Unix/ThreadLocal.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Support/Unix/ThreadLocal.inc?rev=197778&r1=197777&r2=197778&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Support/Unix/ThreadLocal.inc (original)
+++ llvm/branches/release_34/lib/Support/Unix/ThreadLocal.inc Thu Dec 19 22:26:57 2013
@@ -18,7 +18,7 @@
 
 namespace llvm {
 using namespace sys;
-ThreadLocalImpl::ThreadLocalImpl() { }
+ThreadLocalImpl::ThreadLocalImpl() : data() { }
 ThreadLocalImpl::~ThreadLocalImpl() { }
 void ThreadLocalImpl::setInstance(const void* d) { data = const_cast<void*>(d);}
 const void* ThreadLocalImpl::getInstance() { return data; }

Modified: llvm/branches/release_34/unittests/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/unittests/Support/CMakeLists.txt?rev=197778&r1=197777&r2=197778&view=diff
==============================================================================
--- llvm/branches/release_34/unittests/Support/CMakeLists.txt (original)
+++ llvm/branches/release_34/unittests/Support/CMakeLists.txt Thu Dec 19 22:26:57 2013
@@ -30,6 +30,7 @@ add_llvm_unittest(SupportTests
   RegexTest.cpp
   SourceMgrTest.cpp
   SwapByteOrderTest.cpp
+  ThreadLocalTest.cpp
   TimeValueTest.cpp
   UnicodeTest.cpp
   ValueHandleTest.cpp





More information about the llvm-branch-commits mailing list