aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/SpecialCaseList.cpp28
-rw-r--r--llvm/lib/Support/Timer.cpp20
2 files changed, 36 insertions, 12 deletions
diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp
index f74e52a..3a97185 100644
--- a/llvm/lib/Support/SpecialCaseList.cpp
+++ b/llvm/lib/Support/SpecialCaseList.cpp
@@ -89,14 +89,36 @@ void SpecialCaseList::GlobMatcher::preprocess(bool BySize) {
return A.Name.size() < B.Name.size();
});
}
+
+ for (const auto &G : reverse(Globs)) {
+ StringRef Prefix = G.Pattern.prefix();
+ StringRef Suffix = G.Pattern.suffix();
+
+ auto &SToGlob = PrefixSuffixToGlob.emplace(Prefix).first->second;
+ auto &V = SToGlob.emplace(reverse(Suffix)).first->second;
+ V.emplace_back(&G);
+ }
}
void SpecialCaseList::GlobMatcher::match(
StringRef Query,
llvm::function_ref<void(StringRef Rule, unsigned LineNo)> Cb) const {
- for (const auto &G : reverse(Globs))
- if (G.Pattern.match(Query))
- return Cb(G.Name, G.LineNo);
+ if (!PrefixSuffixToGlob.empty()) {
+ for (const auto &[_, SToGlob] : PrefixSuffixToGlob.find_prefixes(Query)) {
+ for (const auto &[_, V] : SToGlob.find_prefixes(reverse(Query))) {
+ for (const auto *G : V) {
+ if (G->Pattern.match(Query)) {
+ Cb(G->Name, G->LineNo);
+ // As soon as we find a match in the vector, we can break for this
+ // vector, since the globs are already sorted by priority within the
+ // prefix group. However, we continue searching other prefix groups
+ // in the map, as they may contain a better match overall.
+ break;
+ }
+ }
+ }
+ }
+ }
}
SpecialCaseList::Matcher::Matcher(bool UseGlobs, bool RemoveDotSlash)
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 67483ba..9d45096 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -240,7 +240,8 @@ private:
getGroupEntry(StringRef GroupName, StringRef GroupDescription) {
std::pair<TimerGroup *, Name2TimerMap> &GroupEntry = Map[GroupName];
if (!GroupEntry.first)
- GroupEntry.first = new TimerGroup(GroupName, GroupDescription);
+ GroupEntry.first =
+ new TimerGroup(GroupName, GroupDescription, /*PrintOnExit=*/true);
return GroupEntry;
}
@@ -270,9 +271,10 @@ TimerGroup &NamedRegionTimer::getNamedTimerGroup(StringRef GroupName,
static TimerGroup *TimerGroupList = nullptr;
TimerGroup::TimerGroup(StringRef Name, StringRef Description,
- sys::SmartMutex<true> &lock)
+ sys::SmartMutex<true> &lock, bool PrintOnExit)
: Name(Name.begin(), Name.end()),
- Description(Description.begin(), Description.end()) {
+ Description(Description.begin(), Description.end()),
+ PrintOnExit(PrintOnExit) {
// Add the group to TimerGroupList.
sys::SmartScopedLock<true> L(lock);
if (TimerGroupList)
@@ -282,12 +284,12 @@ TimerGroup::TimerGroup(StringRef Name, StringRef Description,
TimerGroupList = this;
}
-TimerGroup::TimerGroup(StringRef Name, StringRef Description)
- : TimerGroup(Name, Description, timerLock()) {}
+TimerGroup::TimerGroup(StringRef Name, StringRef Description, bool PrintOnExit)
+ : TimerGroup(Name, Description, timerLock(), PrintOnExit) {}
TimerGroup::TimerGroup(StringRef Name, StringRef Description,
- const StringMap<TimeRecord> &Records)
- : TimerGroup(Name, Description) {
+ const StringMap<TimeRecord> &Records, bool PrintOnExit)
+ : TimerGroup(Name, Description, PrintOnExit) {
TimersToPrint.reserve(Records.size());
for (const auto &P : Records)
TimersToPrint.emplace_back(P.getValue(), std::string(P.getKey()),
@@ -301,7 +303,7 @@ TimerGroup::~TimerGroup() {
while (FirstTimer)
removeTimer(*FirstTimer);
- if (!TimersToPrint.empty()) {
+ if (!TimersToPrint.empty() && PrintOnExit) {
std::unique_ptr<raw_ostream> OutStream = CreateInfoOutputFile();
PrintQueuedTimers(*OutStream);
}
@@ -530,7 +532,7 @@ public:
sys::SmartMutex<true> TimerLock;
TimerGroup DefaultTimerGroup{"misc", "Miscellaneous Ungrouped Timers",
- TimerLock};
+ TimerLock, /*PrintOnExit=*/true};
SignpostEmitter Signposts;
// Order of these members and initialization below is important. For example