summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>2020-03-13 08:15:20 -0400
committerHans Wennborg <hans@chromium.org>2020-03-13 13:44:42 +0100
commit92f7aebe2d7e03d7d04b4d2f978482268b63aa7f (patch)
tree0fb9a36f20578ab1a7e39ecd0d75b4ddb4996150 /llvm/include
parentd9bd6e3c1943e03b783f11d9f2e224ff83f83a7b (diff)
downloadbcm5719-llvm-92f7aebe2d7e03d7d04b4d2f978482268b63aa7f.tar.gz
bcm5719-llvm-92f7aebe2d7e03d7d04b4d2f978482268b63aa7f.zip
[Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash
After a crash catched by the CrashRecoveryContext, this patch prevents from accessing dangling pointers in TimerGroup structures before the clang tool exits. Previously, the default TimerGroup had internal linked lists which were still pointing to old Timer or TimerGroup instances, which lived in stack frames released by the CrashRecoveryContext. Fixes PR45164. Differential Revision: https://reviews.llvm.org/D76099 (cherry picked from commit 28ad9fc20823678881baa0d723834b88ea9e8e3a)
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/Support/ManagedStatic.h6
-rw-r--r--llvm/include/llvm/Support/Timer.h5
2 files changed, 11 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/ManagedStatic.h b/llvm/include/llvm/Support/ManagedStatic.h
index e65bb051f18..bbd0d04ed04 100644
--- a/llvm/include/llvm/Support/ManagedStatic.h
+++ b/llvm/include/llvm/Support/ManagedStatic.h
@@ -102,6 +102,12 @@ public:
}
const C *operator->() const { return &**this; }
+
+ // Extract the instance, leaving the ManagedStatic uninitialized. The
+ // user is then responsible for the lifetime of the returned instance.
+ C *claim() {
+ return static_cast<C *>(Ptr.exchange(nullptr));
+ }
};
/// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
diff --git a/llvm/include/llvm/Support/Timer.h b/llvm/include/llvm/Support/Timer.h
index a298ecd9040..045ac448bdb 100644
--- a/llvm/include/llvm/Support/Timer.h
+++ b/llvm/include/llvm/Support/Timer.h
@@ -230,6 +230,11 @@ public:
/// used by the Statistic code to influence the construction and destruction
/// order of the global timer lists.
static void ConstructTimerLists();
+
+ /// This makes the default group unmanaged, and lets the user manage the
+ /// group's lifetime.
+ static std::unique_ptr<TimerGroup> aquireDefaultGroup();
+
private:
friend class Timer;
friend void PrintStatisticsJSON(raw_ostream &OS);
OpenPOWER on IntegriCloud