Index: lldb/include/lldb/Utility/Timer.h =================================================================== --- lldb/include/lldb/Utility/Timer.h +++ lldb/include/lldb/Utility/Timer.h @@ -15,6 +15,27 @@ #include #include +#if LLVM_SUPPORT_XCODE_SIGNPOSTS +#include +/// A macro to take advantage of the special format string handling +/// in the os_signpost API. The format string substitution is +/// deferred to the log consumer and done outside of the +/// application. +#define SIGNPOST_EMITTER_START_INTERVAL(SIGNPOST_EMITTER, O, ...) \ + do { \ + if ((SIGNPOST_EMITTER).isEnabled()) \ + if (SIGNPOSTS_AVAILABLE()) \ + os_signpost_interval_begin( \ + *(os_log_t *)(SIGNPOST_EMITTER).getLogger(), \ + *(os_signpost_id_t *)(SIGNPOST_EMITTER).getSignpostForObject(O), \ + "LLVM Timers", __VA_ARGS__); \ + } while (0) +#else +#define SIGNPOST_EMITTER_START_INTERVAL(SIGNPOST_EMITTER, O, ...) \ + do { \ + } while (0) +#endif + namespace llvm { class SignpostEmitter; } Index: llvm/include/llvm/Support/Signposts.h =================================================================== --- llvm/include/llvm/Support/Signposts.h +++ llvm/include/llvm/Support/Signposts.h @@ -22,7 +22,6 @@ #if LLVM_SUPPORT_XCODE_SIGNPOSTS #include -#include #endif #define SIGNPOSTS_AVAILABLE() \ @@ -46,27 +45,8 @@ void startInterval(const void *O, StringRef Name); #if LLVM_SUPPORT_XCODE_SIGNPOSTS - os_log_t &getLogger() const; - os_signpost_id_t getSignpostForObject(const void *O); -#endif - - /// A macro to take advantage of the special format string handling - /// in the os_signpost API. The format string substitution is - /// deferred to the log consumer and done outside of the - /// application. -#if LLVM_SUPPORT_XCODE_SIGNPOSTS -#define SIGNPOST_EMITTER_START_INTERVAL(SIGNPOST_EMITTER, O, ...) \ - do { \ - if ((SIGNPOST_EMITTER).isEnabled()) \ - if (SIGNPOSTS_AVAILABLE()) \ - os_signpost_interval_begin((SIGNPOST_EMITTER).getLogger(), \ - (SIGNPOST_EMITTER).getSignpostForObject(O), \ - "LLVM Timers", __VA_ARGS__); \ - } while (0) -#else -#define SIGNPOST_EMITTER_START_INTERVAL(SIGNPOST_EMITTER, O, ...) \ - do { \ - } while (0) + void *getLogger() const; + void *getSignpostForObject(const void *O); #endif /// End a signposted interval for a given object. Index: llvm/lib/Support/Signposts.cpp =================================================================== --- llvm/lib/Support/Signposts.cpp +++ llvm/lib/Support/Signposts.cpp @@ -12,6 +12,7 @@ #if LLVM_SUPPORT_XCODE_SIGNPOSTS #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Mutex.h" +#include #endif using namespace llvm; @@ -40,18 +41,18 @@ sys::SmartMutex Mutex; public: - os_log_t &getLogger() const { return *SignpostLog; } - os_signpost_id_t getSignpostForObject(const void *O) { + os_log_t *getLogger() const { return SignpostLog.get(); } + os_signpost_id_t* getSignpostForObject(const void *O) { sys::SmartScopedLock Lock(Mutex); const auto &I = Signposts.find(O); if (I != Signposts.end()) - return I->second; + return &I->second; os_signpost_id_t ID = {}; if (SIGNPOSTS_AVAILABLE()) { - ID = os_signpost_id_make_with_pointer(getLogger(), O); + ID = os_signpost_id_make_with_pointer(*getLogger(), O); } const auto &Inserted = Signposts.insert(std::make_pair(O, ID)); - return Inserted.first->second; + return &Inserted.first->second; } SignpostEmitterImpl() : SignpostLog(LogCreator()) {} @@ -66,7 +67,7 @@ if (isEnabled()) { if (SIGNPOSTS_AVAILABLE()) { // Both strings used here are required to be constant literal strings. - os_signpost_interval_begin(getLogger(), getSignpostForObject(O), + os_signpost_interval_begin(*getLogger(), *getSignpostForObject(O), "LLVM Timers", "%s", Name.data()); } } @@ -76,7 +77,7 @@ if (isEnabled()) { if (SIGNPOSTS_AVAILABLE()) { // Both strings used here are required to be constant literal strings. - os_signpost_interval_end(getLogger(), getSignpostForObject(O), + os_signpost_interval_end(*getLogger(), *getSignpostForObject(O), "LLVM Timers", ""); } } @@ -119,8 +120,8 @@ } #if HAVE_ANY_SIGNPOST_IMPL -os_log_t &SignpostEmitter::getLogger() const { return Impl->getLogger(); } -os_signpost_id_t SignpostEmitter::getSignpostForObject(const void *O) { +void *SignpostEmitter::getLogger() const { return Impl->getLogger(); } +void *SignpostEmitter::getSignpostForObject(const void *O) { return Impl->getSignpostForObject(O); } #endif