summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/PrettyStackTrace.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2015-01-29 07:35:31 +0000
committerOwen Anderson <resistor@mac.com>2015-01-29 07:35:31 +0000
commit9253bb933aa5d85907f2ff20b9a56b6a4ae1722b (patch)
treef94b43d411fc02aeca3b0e429a90ec34113279e3 /llvm/lib/Support/PrettyStackTrace.cpp
parent99cd1fb0122e567810e7bb8c912e74189a5036ec (diff)
downloadbcm5719-llvm-9253bb933aa5d85907f2ff20b9a56b6a4ae1722b.tar.gz
bcm5719-llvm-9253bb933aa5d85907f2ff20b9a56b6a4ae1722b.zip
Use the existing build configuration parameter ENABLE_BACKTRACE to compile out all pretty stack trace support when backtraces are disabled.
This has the nice secondary effect of allowing LLVM to continue to build for targets without __thread or thread_local support to continue to work so long as they build without support for backtraces. llvm-svn: 227423
Diffstat (limited to 'llvm/lib/Support/PrettyStackTrace.cpp')
-rw-r--r--llvm/lib/Support/PrettyStackTrace.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Support/PrettyStackTrace.cpp b/llvm/lib/Support/PrettyStackTrace.cpp
index bf7b150b842..3f3b9d4d45f 100644
--- a/llvm/lib/Support/PrettyStackTrace.cpp
+++ b/llvm/lib/Support/PrettyStackTrace.cpp
@@ -27,6 +27,11 @@
using namespace llvm;
+// If backtrace support is not enabled, compile out support for pretty stack
+// traces. This has the secondary effect of not requiring thread local storage
+// when backtrace support is disabled.
+#if ENABLE_BACKTRACE
+
// We need a thread local pointer to manage the stack of our stack trace
// objects, but we *really* cannot tolerate destructors running and do not want
// to pay any overhead of synchronizing. As a consequence, we use a raw
@@ -103,16 +108,23 @@ static void CrashHandler(void *) {
#endif
}
+// ENABLE_BACKTRACE
+#endif
+
PrettyStackTraceEntry::PrettyStackTraceEntry() {
+#if ENABLE_BACKTRACE
// Link ourselves.
NextEntry = PrettyStackTraceHead;
PrettyStackTraceHead = this;
+#endif
}
PrettyStackTraceEntry::~PrettyStackTraceEntry() {
+#if ENABLE_BACKTRACE
assert(PrettyStackTraceHead == this &&
"Pretty stack trace entry destruction is out of order");
PrettyStackTraceHead = getNextEntry();
+#endif
}
void PrettyStackTraceString::print(raw_ostream &OS) const {
@@ -127,15 +139,19 @@ void PrettyStackTraceProgram::print(raw_ostream &OS) const {
OS << '\n';
}
+#if ENABLE_BACKTRACE
static bool RegisterCrashPrinter() {
sys::AddSignalHandler(CrashHandler, nullptr);
return false;
}
+#endif
void llvm::EnablePrettyStackTrace() {
+#if ENABLE_BACKTRACE
// The first time this is called, we register the crash printer.
static bool HandlerRegistered = RegisterCrashPrinter();
(void)HandlerRegistered;
+#endif
}
void LLVMEnablePrettyStackTrace() {
OpenPOWER on IntegriCloud