summaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Signposts.cpp
AgeCommit message (Collapse)Author
2022-04-05Change the LLVM signpost categoryJonas Devlieghere
Currently, the LLVM/LLDB timers are visible in Instruments for all apps. The developer-visible "PointsOfInterest" category is reserved for runtime issues and developer-authored "important" logging. These logs are visible to developer almost always in Instruments The LLVM/LLDB timers do not belong there. Having these present in the system is noisy and confusing to developers. This patch moves them under a new "toolchain" category. rdar://91266582 Differential revision: https://reviews.llvm.org/D123149
2022-02-02Signposts.h - move unnecessary StringRef include down to Signposts.cppSimon Pilgrim
2022-01-21[llvm] Cleanup header dependencies in ADT and Supportserge-sans-paille
The cleanup was manual, but assisted by "include-what-you-use". It consists in 1. Removing unused forward declaration. No impact expected. 2. Removing unused headers in .cpp files. No impact expected. 3. Removing unused headers in .h files. This removes implicit dependencies and is generally considered a good thing, but this may break downstream builds. I've updated llvm, clang, lld, lldb and mlir deps, and included a list of the modification in the second part of the commit. 4. Replacing header inclusion by forward declaration. This has the same impact as 3. Notable changes: - llvm/Support/TargetParser.h no longer includes llvm/Support/AArch64TargetParser.h nor llvm/Support/ARMTargetParser.h - llvm/Support/TypeSize.h no longer includes llvm/Support/WithColor.h - llvm/Support/YAMLTraits.h no longer includes llvm/Support/Regex.h - llvm/ADT/SmallVector.h no longer includes llvm/Support/MemAlloc.h nor llvm/Support/ErrorHandling.h You may need to add some of these headers in your compilation units, if needs be. As an hint to the impact of the cleanup, running clang++ -E -Iinclude -I../llvm/include ../llvm/lib/Support/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l before: 8000919 lines after: 7917500 lines Reduced dependencies also helps incremental rebuilds and is more ccache friendly, something not shown by the above metric :-) Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup/5831
2021-10-11Revert "Allow signposts to take advantage of deferred string substitution"Jonas Devlieghere
This reverts commits f9aba9a5afe09788eceb9879aa5c3ad345e0f1e9 and 035217ff515b8ecdc871e39fa840f3cba1b9cec7. As explained in the original commit message, this didn't have the intended effect of improving the common LLDB use case, but still provided a marginal improvement for the places where LLDB creates a scoped time with a string literal. The reason for the revert is that this change pulls in the os/signpost.h header in Signposts.h. The former transitively includes loader.h, which contains a series of macro defines that conflict with MachO.h. There are ways to work around that, but Adrian and I concluded that none of them are worth the trade-off in complicating Signposts.h even further.
2021-08-11[llvm][clang][NFC] updates inline licence infoChristopher Di Bella
Some files still contained the old University of Illinois Open Source Licence header. This patch replaces that with the Apache 2 with LLVM Exception licence. Differential Revision: https://reviews.llvm.org/D107528
2021-06-16Move the definition of LLVM_SUPPORT_XCODE_SIGNPOSTS into llvm-config.hAdrian Prantl
since it is now used by a public header file (Signposts.h). This fixes the standalone LLDB build.
2021-06-14Allow signposts to take advantage of deferred string substitutionAdrian Prantl
One nice feature of the os_signpost API is that format string substitutions happen in the consumer, not the logging application. LLVM's current Signpost class doesn't take advantage of this though and instead always uses a static "Begin/End %s" format string. This patch uses variadic macros to allow the API to be used as intended. Unfortunately, the primary use-case I had in mind (the LLDB_SCOPED_TIMER() macro) does not get much better from this, because __PRETTY_FUNCTION__ is *not* a macro, but a static string, so signposts created by LLDB_SCOPED_TIMER() still use a static "%s" format string. At least LLDB_SCOPED_TIMERF() works as intended. This reapplies the previously reverted patch with additional include order fixes for non-modular builds of LLDB. Differential Revision: https://reviews.llvm.org/D103575
2021-06-14Revert "Allow signposts to take advantage of deferred string substitution"Adrian Prantl
This reverts commit 03841edde7eee21d1d450041ab9a113a7e1be869. Unfortunately this still breaks the LLDB standalone bot.
2021-06-14Allow signposts to take advantage of deferred string substitutionAdrian Prantl
One nice feature of the os_signpost API is that format string substitutions happen in the consumer, not the logging application. LLVM's current Signpost class doesn't take advantage of this though and instead always uses a static "Begin/End %s" format string. This patch uses variadic macros to allow the API to be used as intended. Unfortunately, the primary use-case I had in mind (the LLDB_SCOPED_TIMER() macro) does not get much better from this, because __PRETTY_FUNCTION__ is *not* a macro, but a static string, so signposts created by LLDB_SCOPED_TIMER() still use a static "%s" format string. At least LLDB_SCOPED_TIMERF() works as intended. This reapplies the previsously reverted patch with additional MachO.h macro #undefs. Differential Revision: https://reviews.llvm.org/D103575
2021-06-12Revert "Allow signposts to take advantage of deferred string substitution"Florian Hahn
This reverts commit 4fc93a3a1f95ef5a0a57750fc621f2411ea445a8 because it breaks LLDB builds on certain macOS platform & SDK combinations, e.g. http://green.lab.llvm.org/green/job/lldb-cmake-standalone/3288/consoleFull#-195476041949ba4694-19c4-4d7e-bec5-911270d8a58c
2021-06-11Allow signposts to take advantage of deferred string substitutionAdrian Prantl
One nice feature of the os_signpost API is that format string substitutions happen in the consumer, not the logging application. LLVM's current Signpost class doesn't take advantage of this though and instead always uses a static "Begin/End %s" format string. This patch uses variadic macros to allow the API to be used as intended. Unfortunately, the primary use-case I had in mind (the LLDB_SCOPED_TIMER() macro) does not get much better from this, because __PRETTY_FUNCTION__ is *not* a macro, but a static string, so signposts created by LLDB_SCOPED_TIMER() still use a static "%s" format string. At least LLDB_SCOPED_TIMERF() works as intended. This reapplies the previsously reverted patch with support for platforms where signposts are unavailable. Differential Revision: https://reviews.llvm.org/D103575
2021-06-11Revert "Allow signposts to take advantage of deferred string substitution"Adrian Prantl
I forgot to make the LLDB macro conditional on Linux. This reverts commit 541ccd1c1bb23e1e20a382844b35312c0caffd79.
2021-06-11Allow signposts to take advantage of deferred string substitutionAdrian Prantl
One nice feature of the os_signpost API is that format string substitutions happen in the consumer, not the logging application. LLVM's current Signpost class doesn't take advantage of this though and instead always uses a static "Begin/End %s" format string. This patch uses variadic macros to allow the API to be used as intended. Unfortunately, the primary use-case I had in mind (the LLDB_SCOPED_TIMER() macro) does not get much better from this, because __PRETTY_FUNCTION__ is *not* a macro, but a static string, so signposts created by LLDB_SCOPED_TIMER() still use a static "%s" format string. At least LLDB_SCOPED_TIMERF() works as intended. Differential Revision: https://reviews.llvm.org/D103575
2021-06-03Remove redundant Begin/End form signpost format strings.Adrian Prantl
The os_signpost API already captures the begin/end part and in Instruments, this just adds visual noise that gets in the way of the interesting data. By removing the redundant end text, the display in Instruments gets even less cluttered. rdar://78636200 Differential Revision: https://reviews.llvm.org/D103577
2021-04-08Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC, 3rd attemptDuncan P. N. Exon Smith
This reverts commit e35afbe535f96086141f57a5ce7d679429b4405f, reapplying 022ccedde8877e877b45e49641544b5e4fff0b42 and e7ed5c920db3f537a85d962c1c918a1bb6de99fd. - The first attempt missed defining `SignpostEmitterImpl`. - The second attempt missed defining `llvm::SignpostEmitterImpl`. Not sure how I failed to test both versions locally before; I thought I'd turned the feature off via rerunning `cmake` but it must have been stuck in place. This time I confirmed via `clang -E` that I was testing both build configurations. Original commit message: Replace some manual memory management with std::unique_ptr. Differential Revision: https://reviews.llvm.org/D100151
2021-04-08Revert "Revert "Revert "Support: Use std::unique_ptr for ↵Duncan P. N. Exon Smith
SignpostEmitter::Impl, NFC""" This reverts commit e7ed5c920db3f537a85d962c1c918a1bb6de99fd again, due to more buildbot failures: https://lab.llvm.org/buildbot/#/builders/131/builds/8191
2021-04-08Revert "Revert "Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC""Duncan P. N. Exon Smith
This reverts commit 078072285d3fbdaa94f9a91140eb5c1223b548af, reapplying 022ccedde8877e877b45e49641544b5e4fff0b42. I figured out why this was failing in other environments: it's not a problem with std::unique_ptr, but that SignpostEmitterImpl only has a forward declaration. Adding an empty definition should do the trick. Original commit message: Replace some manual memory management with std::unique_ptr. Differential Revision: https://reviews.llvm.org/D100151
2021-04-08Revert "Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC"Duncan P. N. Exon Smith
This reverts commit 022ccedde8877e877b45e49641544b5e4fff0b42. Looks like some hosts need a definition of SignpostEmitterImpl to put it in a unique_ptr: https://lab.llvm.org/buildbot/#/builders/92/builds/7733
2021-04-08Support: Avoid unnecessary std::function for SignpostEmitterImpl::SignpostLogDuncan P. N. Exon Smith
The destructor for SignPostEmitterImpl::SignpostLog is known statically. Avoid the unnecessary vtable indirection through std::function in the std::unique_ptr by turning LogDeleter into a struct. No real functionality change here. Differential Revision: https://reviews.llvm.org/D100154
2021-04-08Support: Drop the no-op initializer for SignpostEmitterImpl::Signposts, NFCDuncan P. N. Exon Smith
This is a DenseMap, which has its own initializer; we don't need to explicitly call the default constructor here. Differential Revision: https://reviews.llvm.org/D100152
2021-04-08Support: Use std::unique_ptr for SignpostEmitter::Impl, NFCDuncan P. N. Exon Smith
Replace some manual memory management with std::unique_ptr. Differential Revision: https://reviews.llvm.org/D100151
2021-02-24[llvm] Check availability for os_signpostJonas Devlieghere
Add availability checks to the os_signpost code so this can be used with an older deployment target. Differential revision: https://reviews.llvm.org/D97410
2021-01-19[llvm] Protect signpost map with a mutexJonas Devlieghere
Use a mutex to protect concurrent access to the signpost map. This fixes nondeterministic crashes in LLDB that appeared after using signposts in the timer implementation. Differential revision: https://reviews.llvm.org/D94285
2021-01-06[Support] Untie the llvm::Signpost interface from llvm::TimerJonas Devlieghere
Make llvm::Signpost more generic by untying from llvm::Timer. This allows signposts to be used in a different context. My motivation for doing this is being able to use signposts in LLDB. Differential revision: https://reviews.llvm.org/D93655
2019-08-15[Support] Fix Wundef warningSven van Haastregt
llvm-svn: 368984
2019-02-19Annotate timeline in Instruments with passes and other timed regions.Daniel Sanders
Summary: Instruments is a useful tool for finding performance issues in LLVM but it can be difficult to identify regions of interest on the timeline that we can use to filter the profiler or allocations instrument. Xcode 10 and the latest macOS/iOS/etc. added support for the os_signpost() API which allows us to annotate the timeline with information that's meaningful to LLVM. This patch causes timer start and end events to emit signposts. When used with -time-passes, this causes the passes to be annotated on the Instruments timeline. In addition to visually showing the duration of passes on the timeline, it also allows us to filter the profile and allocations instrument down to an individual pass allowing us to find the issues within that pass without being drowned out by the noise from other parts of the compiler. Using this in conjunction with the Time Profiler (in high frequency mode) and the Allocations instrument is how I found the SparseBitVector that should have been a BitVector and the DenseMap that could be replaced by a sorted vector a couple months ago. I added NamedRegionTimers to TableGen and used the resulting annotations to identify the slow portions of the Register Info Emitter. Some of these were placed according to educated guesses while others were placed according to hot functions from a previous profile. From there I filtered the profile to a slow portion and the aforementioned issues stood out in the profile. To use this feature enable LLVM_SUPPORT_XCODE_SIGNPOSTS in CMake and run the compiler under Instruments with -time-passes like so: instruments -t 'Time Profiler' bin/llc -time-passes -o - input.ll' Then open the resulting trace in Instruments. There was a talk at WWDC 2018 that explained the feature which can be found at https://developer.apple.com/videos/play/wwdc2018/405/ if you'd like to know more about it. Reviewers: bogner Reviewed By: bogner Subscribers: jdoerfert, mgorny, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D52954 llvm-svn: 354365