Rename BlockFrequency to BlockFrequencyInfo and MachineBlockFrequency to
[oota-llvm.git] / lib / Support / CrashRecoveryContext.cpp
index e190051e6dbe1b6793da0de79c07c1d00920e773..899c3890d78a9940b9f1e2391f375080f70b139c 100644 (file)
@@ -57,23 +57,36 @@ public:
 static sys::Mutex gCrashRecoveryContexMutex;
 static bool gCrashRecoveryEnabled = false;
 
+static sys::ThreadLocal<const CrashRecoveryContextCleanup> 
+       tlIsRecoveringFromCrash;
+
 CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {}
 
 CrashRecoveryContext::~CrashRecoveryContext() {
   // Reclaim registered resources.
   CrashRecoveryContextCleanup *i = head;
+  tlIsRecoveringFromCrash.set(head);
   while (i) {
     CrashRecoveryContextCleanup *tmp = i;
     i = tmp->next;
+    tmp->cleanupFired = true;
     tmp->recoverResources();
     delete tmp;
   }
+  tlIsRecoveringFromCrash.erase();
   
   CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *) Impl;
   delete CRCI;
 }
 
+bool CrashRecoveryContext::isRecoveringFromCrash() {
+  return tlIsRecoveringFromCrash.get() != 0;
+}
+
 CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {
+  if (!gCrashRecoveryEnabled)
+    return 0;
+
   const CrashRecoveryContextImpl *CRCI = CurrentContext.get();
   if (!CRCI)
     return 0;