From 92f7aebe2d7e03d7d04b4d2f978482268b63aa7f Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Fri, 13 Mar 2020 08:15:20 -0400 Subject: [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) --- llvm/lib/Support/Timer.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Support') diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index 613d2eaae6d..2d3d0081282 100644 --- a/llvm/lib/Support/Timer.cpp +++ b/llvm/lib/Support/Timer.cpp @@ -441,3 +441,7 @@ const char *TimerGroup::printAllJSONValues(raw_ostream &OS, const char *delim) { void TimerGroup::ConstructTimerLists() { (void)*NamedGroupedTimers; } + +std::unique_ptr TimerGroup::aquireDefaultGroup() { + return std::unique_ptr(DefaultTimerGroup.claim()); +} -- cgit v1.2.3