[clang] remove goma support from clang (PR #93942)

2024-06-02 Thread Takuto Ikuta via cfe-commits

atetubou wrote:

I don't have merge permission. Could someone merge this PR if this looks good?

https://github.com/llvm/llvm-project/pull/93942
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] remove goma support from clang (PR #93942)

2024-05-31 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou created 
https://github.com/llvm/llvm-project/pull/93942

goma is deprecated and not maintained anymore.

https://chromium.googlesource.com/infra/goma/client/

>From eb50f67d29325ded7bf49834fb9fed0d588b5529 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta 
Date: Fri, 31 May 2024 18:16:17 +0900
Subject: [PATCH] remove goma support from clang

---
 clang/lib/Tooling/JSONCompilationDatabase.cpp   | 5 ++---
 clang/unittests/Tooling/CompilationDatabaseTest.cpp | 1 -
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp 
b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index a77686996879f..5ecba5dfece3d 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -260,7 +260,7 @@ static llvm::StringRef 
stripExecutableExtension(llvm::StringRef Name) {
   return Name;
 }
 
-// There are compiler-wrappers (ccache, distcc, gomacc) that take the "real"
+// There are compiler-wrappers (ccache, distcc) that take the "real"
 // compiler as an argument, e.g. distcc gcc -O3 foo.c.
 // These end up in compile_commands.json when people set CC="distcc gcc".
 // Clang's driver doesn't understand this, so we need to unwrap.
@@ -269,8 +269,7 @@ static bool unwrapCommand(std::vector &Args) {
 return false;
   StringRef Wrapper =
   stripExecutableExtension(llvm::sys::path::filename(Args.front()));
-  if (Wrapper == "distcc" || Wrapper == "gomacc" || Wrapper == "ccache" ||
-  Wrapper == "sccache") {
+  if (Wrapper == "distcc" || Wrapper == "ccache" || Wrapper == "sccache") {
 // Most of these wrappers support being invoked 3 ways:
 // `distcc g++ file.c` This is the mode we're trying to match.
 // We need to drop `distcc`.
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp 
b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 45062cf7c16f6..2032b13726c45 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -402,7 +402,6 @@ TEST(findCompileArgsInJsonDatabase, FindsEntry) {
 TEST(findCompileArgsInJsonDatabase, ParsesCompilerWrappers) {
   std::vector> Cases = {
   {"distcc gcc foo.c", "gcc foo.c"},
-  {"gomacc clang++ foo.c", "clang++ foo.c"},
   {"sccache clang++ foo.c", "clang++ foo.c"},
   {"ccache gcc foo.c", "gcc foo.c"},
   {"ccache.exe gcc foo.c", "gcc foo.c"},

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-25 Thread Takuto Ikuta via cfe-commits

atetubou wrote:

Thank you for your review and merge!

https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-21 Thread Takuto Ikuta via cfe-commits

atetubou wrote:

@MaskRay could you review this?

https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-20 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou updated 
https://github.com/llvm/llvm-project/pull/83961

>From e61cf0ec2caa594fe915711477083875dc8bf449 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta 
Date: Mon, 4 Mar 2024 17:02:05 +0900
Subject: [PATCH] Use timeTraceAsyncProfilerBegin for Source span

---
 clang/lib/Sema/Sema.cpp | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index cd0c42d5ffbacd..36762b217c9faa 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -135,6 +135,7 @@ namespace sema {
 class SemaPPCallbacks : public PPCallbacks {
   Sema *S = nullptr;
   llvm::SmallVector IncludeStack;
+  llvm::SmallVector ProfilerStack;
 
 public:
   void set(Sema &S) { this->S = &S; }
@@ -153,8 +154,8 @@ class SemaPPCallbacks : public PPCallbacks {
   if (IncludeLoc.isValid()) {
 if (llvm::timeTraceProfilerEnabled()) {
   OptionalFileEntryRef FE = SM.getFileEntryRefForID(SM.getFileID(Loc));
-  llvm::timeTraceProfilerBegin("Source", FE ? FE->getName()
-: StringRef(""));
+  ProfilerStack.push_back(llvm::timeTraceAsyncProfilerBegin(
+  "Source", FE ? FE->getName() : StringRef("")));
 }
 
 IncludeStack.push_back(IncludeLoc);
@@ -166,8 +167,9 @@ class SemaPPCallbacks : public PPCallbacks {
 }
 case ExitFile:
   if (!IncludeStack.empty()) {
-if (llvm::timeTraceProfilerEnabled())
-  llvm::timeTraceProfilerEnd();
+if (llvm::timeTraceProfilerEnabled()) {
+  llvm::timeTraceProfilerEnd(ProfilerStack.pop_back_val());
+}
 
 S->DiagnoseNonDefaultPragmaAlignPack(
 Sema::PragmaAlignPackDiagnoseKind::ChangedStateAtExit,

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-18 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou updated 
https://github.com/llvm/llvm-project/pull/83961

>From 6e2521733cdc49971529977cb81c731dd2816b42 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta 
Date: Mon, 18 Mar 2024 18:03:00 +0900
Subject: [PATCH 1/2] git squash commit for support_new_trace.

90ebde07f7fa426a37dd4bdc362e1a809aaf0844
Expose TimeTraceProfiler for Async Events

8bf598f71d37f5404671dbb1840c7bed0ed87b42
assert
---
 llvm/include/llvm/Support/TimeProfiler.h|  34 +--
 llvm/lib/Support/TimeProfiler.cpp   | 101 ++--
 llvm/unittests/Support/TimeProfilerTest.cpp |  11 +++
 3 files changed, 107 insertions(+), 39 deletions(-)

diff --git a/llvm/include/llvm/Support/TimeProfiler.h 
b/llvm/include/llvm/Support/TimeProfiler.h
index 454a65f70231f4..31f7df10916db9 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -86,6 +86,8 @@ class raw_pwrite_stream;
 struct TimeTraceProfiler;
 TimeTraceProfiler *getTimeTraceProfilerInstance();
 
+struct TimeTraceProfilerEntry;
+
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
@@ -120,19 +122,30 @@ Error timeTraceProfilerWrite(StringRef PreferredFileName,
 /// Profiler copies the string data, so the pointers can be given into
 /// temporaries. Time sections can be hierarchical; every Begin must have a
 /// matching End pair but they can nest.
-void timeTraceProfilerBegin(StringRef Name, StringRef Detail);
-void timeTraceProfilerBegin(StringRef Name,
-llvm::function_ref Detail);
+TimeTraceProfilerEntry *timeTraceProfilerBegin(StringRef Name,
+   StringRef Detail);
+TimeTraceProfilerEntry *
+timeTraceProfilerBegin(StringRef Name,
+   llvm::function_ref Detail);
+
+/// Manually begin a time section, with the given \p Name and \p Detail.
+/// This starts Async Events having \p Name as a category which is shown
+/// separately from other traces. See
+/// 
https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1
+/// for more details.
+TimeTraceProfilerEntry *timeTraceAsyncProfilerBegin(StringRef Name,
+StringRef Detail);
 
 /// Manually end the last time section.
 void timeTraceProfilerEnd();
+void timeTraceProfilerEnd(TimeTraceProfilerEntry *E);
 
 /// The TimeTraceScope is a helper class to call the begin and end functions
 /// of the time trace profiler.  When the object is constructed, it begins
 /// the section; and when it is destroyed, it stops it. If the time profiler
 /// is not initialized, the overhead is a single branch.
-struct TimeTraceScope {
-
+class TimeTraceScope {
+public:
   TimeTraceScope() = delete;
   TimeTraceScope(const TimeTraceScope &) = delete;
   TimeTraceScope &operator=(const TimeTraceScope &) = delete;
@@ -141,20 +154,23 @@ struct TimeTraceScope {
 
   TimeTraceScope(StringRef Name) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, StringRef(""));
+  Entry = timeTraceProfilerBegin(Name, StringRef(""));
   }
   TimeTraceScope(StringRef Name, StringRef Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   TimeTraceScope(StringRef Name, llvm::function_ref Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   ~TimeTraceScope() {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerEnd();
+  timeTraceProfilerEnd(Entry);
   }
+
+private:
+  TimeTraceProfilerEntry *Entry = nullptr;
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4d625b3eb5b170..092028dd2a5b34 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/JSON.h"
@@ -20,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -64,17 +66,19 @@ using CountAndDurationType = std::pair;
 using NameAndCountAndDurationType =
 std::pair;
 
+} // anonymous namespace
+
 /// Represents an open or completed time section entry to be captured.
-struct TimeTraceProfilerEntry {
+struct llvm::TimeTraceProfilerEntry {
   const TimePointType Start;
   TimePointType End;
   const std::string Name;
   const std::string Detail;
-
+  const bool AsyncEvent = false;
   TimeTraceProfilerEntry(TimePointType &&S, TimePointType &&E, std::string &&N,
-

[clang] [llvm] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-13 Thread Takuto Ikuta via cfe-commits

atetubou wrote:

> > > IIUC, the approach you choose here is to let `SemaPPCallbacks` control 
> > > the "entered file stack" and allow it to remove element (which is file) 
> > > from middle of the internal stack in `TimeTraceProfiler`, but this 
> > > creates async event which is not designed for this purpose.
> > > Can we let `SemaPPCallbacks` track the last push file into the stack and 
> > > when exit file, pop all the elements from the stack until we popped the 
> > > last pushed file?
> > 
> > 
> > As I wrote in [#56554 
> > (comment)](https://github.com/llvm/llvm-project/issues/56554#issuecomment-1975812398),
> >  file level span and syntax tree level span should be handled 
> > asynchronously. So using such implementation produces incorrect trace in 
> > other edge cases.
> 
> Can we choose to expose a handle (maybe an unique id for each entry) from 
> `TimeTraceProfiler` instead of exposing the internal entry?

I think pointer to `TimeTraceProfilerEntry` is already like handle as 
definition of the struct is not written in header file. Having another handle 
for that seems unnecessary indirection layer to me. Or better to change the 
name of struct?

https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-13 Thread Takuto Ikuta via cfe-commits


@@ -102,23 +104,24 @@ struct llvm::TimeTraceProfiler {
 llvm::get_thread_name(ThreadName);
   }
 
-  void begin(std::string Name, llvm::function_ref Detail) {
-Stack.emplace_back(ClockType::now(), TimePointType(), std::move(Name),
-   Detail());
+  TimeTraceProfilerEntry *begin(std::string Name,
+llvm::function_ref Detail,
+bool AsyncEvent = false) {
+Stack.emplace_back(std::make_unique(
+ClockType::now(), TimePointType(), std::move(Name), Detail(),
+AsyncEvent));
+return Stack.back().get();
   }
 
   void end() {
+TimeTraceProfilerEntry *E = Stack.back().get();

atetubou wrote:

`Stack.back()` doesn't mutate `Stack`?

https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-11 Thread Takuto Ikuta via cfe-commits


@@ -102,23 +104,24 @@ struct llvm::TimeTraceProfiler {
 llvm::get_thread_name(ThreadName);
   }
 
-  void begin(std::string Name, llvm::function_ref Detail) {
-Stack.emplace_back(ClockType::now(), TimePointType(), std::move(Name),
-   Detail());
+  TimeTraceProfilerEntry *begin(std::string Name,
+llvm::function_ref Detail,
+bool AsyncEvent = false) {
+Stack.emplace_back(std::make_unique(
+ClockType::now(), TimePointType(), std::move(Name), Detail(),
+AsyncEvent));
+return Stack.back().get();
   }
 
   void end() {
+TimeTraceProfilerEntry *E = Stack.back().get();

atetubou wrote:

But this function calls `end(TimeTraceProfilerEntry &E)` and that covers the 
assertion?

https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-11 Thread Takuto Ikuta via cfe-commits

atetubou wrote:

> IIUC, the approach you choose here is to let `SemaPPCallbacks` control the 
> "entered file stack" and allow it to remove element (which is file) from 
> middle of the internal stack in `TimeTraceProfiler`, but this creates async 
> event which is not designed for this purpose.
> 
> Can we let `SemaPPCallbacks` track the last push file into the stack and when 
> exit file, pop all the elements from the stack until we popped the last 
> pushed file?

As I wrote in 
https://github.com/llvm/llvm-project/issues/56554#issuecomment-1975812398, file 
level span and syntax tree level span should be handled asynchronously. So 
using such implementation produces incorrect trace in other edge cases.

https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-11 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou updated 
https://github.com/llvm/llvm-project/pull/83961

>From 90ebde07f7fa426a37dd4bdc362e1a809aaf0844 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta 
Date: Mon, 4 Mar 2024 19:12:31 +0900
Subject: [PATCH 1/3] Expose TimeTraceProfiler for Async Events

---
 llvm/include/llvm/Support/TimeProfiler.h|  34 +--
 llvm/lib/Support/TimeProfiler.cpp   | 101 ++--
 llvm/unittests/Support/TimeProfilerTest.cpp |  11 +++
 3 files changed, 107 insertions(+), 39 deletions(-)

diff --git a/llvm/include/llvm/Support/TimeProfiler.h 
b/llvm/include/llvm/Support/TimeProfiler.h
index 454a65f70231f4..31f7df10916db9 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -86,6 +86,8 @@ class raw_pwrite_stream;
 struct TimeTraceProfiler;
 TimeTraceProfiler *getTimeTraceProfilerInstance();
 
+struct TimeTraceProfilerEntry;
+
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
@@ -120,19 +122,30 @@ Error timeTraceProfilerWrite(StringRef PreferredFileName,
 /// Profiler copies the string data, so the pointers can be given into
 /// temporaries. Time sections can be hierarchical; every Begin must have a
 /// matching End pair but they can nest.
-void timeTraceProfilerBegin(StringRef Name, StringRef Detail);
-void timeTraceProfilerBegin(StringRef Name,
-llvm::function_ref Detail);
+TimeTraceProfilerEntry *timeTraceProfilerBegin(StringRef Name,
+   StringRef Detail);
+TimeTraceProfilerEntry *
+timeTraceProfilerBegin(StringRef Name,
+   llvm::function_ref Detail);
+
+/// Manually begin a time section, with the given \p Name and \p Detail.
+/// This starts Async Events having \p Name as a category which is shown
+/// separately from other traces. See
+/// 
https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1
+/// for more details.
+TimeTraceProfilerEntry *timeTraceAsyncProfilerBegin(StringRef Name,
+StringRef Detail);
 
 /// Manually end the last time section.
 void timeTraceProfilerEnd();
+void timeTraceProfilerEnd(TimeTraceProfilerEntry *E);
 
 /// The TimeTraceScope is a helper class to call the begin and end functions
 /// of the time trace profiler.  When the object is constructed, it begins
 /// the section; and when it is destroyed, it stops it. If the time profiler
 /// is not initialized, the overhead is a single branch.
-struct TimeTraceScope {
-
+class TimeTraceScope {
+public:
   TimeTraceScope() = delete;
   TimeTraceScope(const TimeTraceScope &) = delete;
   TimeTraceScope &operator=(const TimeTraceScope &) = delete;
@@ -141,20 +154,23 @@ struct TimeTraceScope {
 
   TimeTraceScope(StringRef Name) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, StringRef(""));
+  Entry = timeTraceProfilerBegin(Name, StringRef(""));
   }
   TimeTraceScope(StringRef Name, StringRef Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   TimeTraceScope(StringRef Name, llvm::function_ref Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   ~TimeTraceScope() {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerEnd();
+  timeTraceProfilerEnd(Entry);
   }
+
+private:
+  TimeTraceProfilerEntry *Entry = nullptr;
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4d625b3eb5b170..3114f8e7ded598 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/JSON.h"
@@ -20,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -64,17 +66,19 @@ using CountAndDurationType = std::pair;
 using NameAndCountAndDurationType =
 std::pair;
 
+} // anonymous namespace
+
 /// Represents an open or completed time section entry to be captured.
-struct TimeTraceProfilerEntry {
+struct llvm::TimeTraceProfilerEntry {
   const TimePointType Start;
   TimePointType End;
   const std::string Name;
   const std::string Detail;
-
+  const bool AsyncEvent = false;
   TimeTraceProfilerEntry(TimePointType &&S, TimePointType &&E, std::string &&N,
- std::string &&Dt)
+ std::string &&Dt, bool Ae)
   : Start(std::move(S)), End(std::move(E)),

[clang] [llvm] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-10 Thread Takuto Ikuta via cfe-commits

atetubou wrote:

@ZequanWu could you take a look this?

https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-05 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou ready_for_review 
https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use timeTraceAsyncProfilerBegin for Source span (PR #83961)

2024-03-05 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou edited 
https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use TimeTraceProfilerEntry for Source span (PR #83961)

2024-03-05 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou edited 
https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use TimeTraceProfilerEntry for Source span (PR #83961)

2024-03-05 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou updated 
https://github.com/llvm/llvm-project/pull/83961

>From 90ebde07f7fa426a37dd4bdc362e1a809aaf0844 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta 
Date: Mon, 4 Mar 2024 19:12:31 +0900
Subject: [PATCH 1/2] Expose TimeTraceProfiler for Async Events

---
 llvm/include/llvm/Support/TimeProfiler.h|  34 +--
 llvm/lib/Support/TimeProfiler.cpp   | 101 ++--
 llvm/unittests/Support/TimeProfilerTest.cpp |  11 +++
 3 files changed, 107 insertions(+), 39 deletions(-)

diff --git a/llvm/include/llvm/Support/TimeProfiler.h 
b/llvm/include/llvm/Support/TimeProfiler.h
index 454a65f70231f4..31f7df10916db9 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -86,6 +86,8 @@ class raw_pwrite_stream;
 struct TimeTraceProfiler;
 TimeTraceProfiler *getTimeTraceProfilerInstance();
 
+struct TimeTraceProfilerEntry;
+
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
@@ -120,19 +122,30 @@ Error timeTraceProfilerWrite(StringRef PreferredFileName,
 /// Profiler copies the string data, so the pointers can be given into
 /// temporaries. Time sections can be hierarchical; every Begin must have a
 /// matching End pair but they can nest.
-void timeTraceProfilerBegin(StringRef Name, StringRef Detail);
-void timeTraceProfilerBegin(StringRef Name,
-llvm::function_ref Detail);
+TimeTraceProfilerEntry *timeTraceProfilerBegin(StringRef Name,
+   StringRef Detail);
+TimeTraceProfilerEntry *
+timeTraceProfilerBegin(StringRef Name,
+   llvm::function_ref Detail);
+
+/// Manually begin a time section, with the given \p Name and \p Detail.
+/// This starts Async Events having \p Name as a category which is shown
+/// separately from other traces. See
+/// 
https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1
+/// for more details.
+TimeTraceProfilerEntry *timeTraceAsyncProfilerBegin(StringRef Name,
+StringRef Detail);
 
 /// Manually end the last time section.
 void timeTraceProfilerEnd();
+void timeTraceProfilerEnd(TimeTraceProfilerEntry *E);
 
 /// The TimeTraceScope is a helper class to call the begin and end functions
 /// of the time trace profiler.  When the object is constructed, it begins
 /// the section; and when it is destroyed, it stops it. If the time profiler
 /// is not initialized, the overhead is a single branch.
-struct TimeTraceScope {
-
+class TimeTraceScope {
+public:
   TimeTraceScope() = delete;
   TimeTraceScope(const TimeTraceScope &) = delete;
   TimeTraceScope &operator=(const TimeTraceScope &) = delete;
@@ -141,20 +154,23 @@ struct TimeTraceScope {
 
   TimeTraceScope(StringRef Name) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, StringRef(""));
+  Entry = timeTraceProfilerBegin(Name, StringRef(""));
   }
   TimeTraceScope(StringRef Name, StringRef Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   TimeTraceScope(StringRef Name, llvm::function_ref Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   ~TimeTraceScope() {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerEnd();
+  timeTraceProfilerEnd(Entry);
   }
+
+private:
+  TimeTraceProfilerEntry *Entry = nullptr;
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4d625b3eb5b170..3114f8e7ded598 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/JSON.h"
@@ -20,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -64,17 +66,19 @@ using CountAndDurationType = std::pair;
 using NameAndCountAndDurationType =
 std::pair;
 
+} // anonymous namespace
+
 /// Represents an open or completed time section entry to be captured.
-struct TimeTraceProfilerEntry {
+struct llvm::TimeTraceProfilerEntry {
   const TimePointType Start;
   TimePointType End;
   const std::string Name;
   const std::string Detail;
-
+  const bool AsyncEvent = false;
   TimeTraceProfilerEntry(TimePointType &&S, TimePointType &&E, std::string &&N,
- std::string &&Dt)
+ std::string &&Dt, bool Ae)
   : Start(std::move(S)), End(std::move(E)),

[clang] [clang][NFC] Format clang/lib/Sema/Sema.cpp (PR #83974)

2024-03-05 Thread Takuto Ikuta via cfe-commits

atetubou wrote:

Oh, I found 
https://code.visualstudio.com/docs/getstarted/settings#:~:text=modificationsIfAvailable.
 
So let me use that instead. Thank you for your comments.

https://github.com/llvm/llvm-project/pull/83974
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Format clang/lib/Sema/Sema.cpp (PR #83974)

2024-03-05 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou closed 
https://github.com/llvm/llvm-project/pull/83974
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Format clang/lib/Sema/Sema.cpp (PR #83974)

2024-03-05 Thread Takuto Ikuta via cfe-commits

atetubou wrote:

Thank you for references both.

Actually, I'd like to have PR like 
https://github.com/llvm/llvm-project/pull/83961.
Is it acceptable to merge this kind of PR in that case then?

https://github.com/llvm/llvm-project/pull/83974
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Format clang/lib/Sema/Sema.cpp (PR #83974)

2024-03-05 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou edited 
https://github.com/llvm/llvm-project/pull/83974
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] NFC: format clang/lib/Sema/Sema.cpp (PR #83974)

2024-03-05 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou ready_for_review 
https://github.com/llvm/llvm-project/pull/83974
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] NFC: format clang/lib/Sema/Sema.cpp (PR #83974)

2024-03-05 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou created 
https://github.com/llvm/llvm-project/pull/83974

This is to avoid modifying unrelated code when auto format is on in our editor.

>From 8d660f8a15b04285a4218a22944aef902d645b27 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta 
Date: Tue, 5 Mar 2024 17:34:15 +0900
Subject: [PATCH] NFC: format clang/lib/Sema/Sema.cpp

---
 clang/lib/Sema/Sema.cpp | 223 +---
 1 file changed, 118 insertions(+), 105 deletions(-)

diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index cfb653e665ea03..fe00dc3198fdc0 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -269,8 +269,8 @@ void Sema::Initialize() {
 SC->InitializeSema(*this);
 
   // Tell the external Sema source about this Sema object.
-  if (ExternalSemaSource *ExternalSema
-  = dyn_cast_or_null(Context.getExternalSource()))
+  if (ExternalSemaSource *ExternalSema =
+  dyn_cast_or_null(Context.getExternalSource()))
 ExternalSema->InitializeSema(*this);
 
   // This needs to happen after ExternalSemaSource::InitializeSema(this) or we
@@ -295,7 +295,6 @@ void Sema::Initialize() {
   PushOnScopeChains(Context.getUInt128Decl(), TUScope);
   }
 
-
   // Initialize predefined Objective-C types:
   if (getLangOpts().ObjC) {
 // If 'SEL' does not yet refer to any declarations, make it refer to the
@@ -361,7 +360,6 @@ void Sema::Initialize() {
   // 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide.
   addImplicitTypedef("atomic_flag", Context.getAtomicType(Context.IntTy));
 
-
   // OpenCL v2.0 s6.13.11.6:
   // - The atomic_long and atomic_ulong types are supported if the
   //   cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics
@@ -410,7 +408,6 @@ void Sema::Initialize() {
 addImplicitTypedef("atomic_long", AtomicLongT);
 addImplicitTypedef("atomic_ulong", AtomicULongT);
 
-
 if (Context.getTypeSize(Context.getSizeType()) == 64) {
   AddPointerSizeDependentTypes();
 }
@@ -425,17 +422,17 @@ void Sema::Initialize() {
   }
 
   if (Context.getTargetInfo().hasAArch64SVETypes()) {
-#define SVE_TYPE(Name, Id, SingletonId) \
-addImplicitTypedef(Name, Context.SingletonId);
+#define SVE_TYPE(Name, Id, SingletonId)
\
+  addImplicitTypedef(Name, Context.SingletonId);
 #include "clang/Basic/AArch64SVEACLETypes.def"
   }
 
   if (Context.getTargetInfo().getTriple().isPPC64()) {
-#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
-  addImplicitTypedef(#Name, Context.Id##Ty);
+#define PPC_VECTOR_MMA_TYPE(Name, Id, Size)
\
+  addImplicitTypedef(#Name, Context.Id##Ty);
 #include "clang/Basic/PPCTypes.def"
-#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
-addImplicitTypedef(#Name, Context.Id##Ty);
+#define PPC_VECTOR_VSX_TYPE(Name, Id, Size)
\
+  addImplicitTypedef(#Name, Context.Id##Ty);
 #include "clang/Basic/PPCTypes.def"
   }
 
@@ -467,7 +464,8 @@ Sema::~Sema() {
   assert(InstantiatingSpecializations.empty() &&
  "failed to clean up an InstantiatingTemplate?");
 
-  if (VisContext) FreeVisContext();
+  if (VisContext)
+FreeVisContext();
 
   // Kill all the active scopes.
   for (sema::FunctionScopeInfo *FSI : FunctionScopes)
@@ -478,8 +476,8 @@ Sema::~Sema() {
 SC->ForgetSema();
 
   // Detach from the external Sema source.
-  if (ExternalSemaSource *ExternalSema
-= dyn_cast_or_null(Context.getExternalSource()))
+  if (ExternalSemaSource *ExternalSema =
+  dyn_cast_or_null(Context.getExternalSource()))
 ExternalSema->ForgetSema();
 
   // Delete cached satisfactions.
@@ -517,11 +515,12 @@ void Sema::runWithSufficientStackSpace(SourceLocation Loc,
 /// context.  If we're still in a system header, and we can plausibly
 /// make the relevant declaration unavailable instead of erroring, do
 /// so and return true.
-bool Sema::makeUnavailableInSystemHeader(SourceLocation loc,
-  UnavailableAttr::ImplicitReason reason) {
+bool Sema::makeUnavailableInSystemHeader(
+SourceLocation loc, UnavailableAttr::ImplicitReason reason) {
   // If we're not in a function, it's an error.
   FunctionDecl *fn = dyn_cast(CurContext);
-  if (!fn) return false;
+  if (!fn)
+return false;
 
   // If we're in template instantiation, it's an error.
   if (inTemplateInstantiation())
@@ -532,7 +531,8 @@ bool Sema::makeUnavailableInSystemHeader(SourceLocation loc,
 return false;
 
   // If the function is already unavailable, it's not an error.
-  if (fn->hasAttr()) return true;
+  if (fn->hasAttr())
+return true;
 
   fn->addAttr(UnavailableAttr::CreateImplicit(Context, "", reason, loc));
   return true;
@@ -542,8 +542,8 @@ ASTMutationListener *Sema::getASTMutationListener() const {
   return getASTConsumer().GetASTMutationListener();
 }
 
-///Registers an external source. If an external source already 

[clang] [llvm] Use TimeTraceProfilerEntry for Source span (PR #83961)

2024-03-04 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou edited 
https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use TimeTraceProfilerEntry for Source span (PR #83961)

2024-03-04 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou edited 
https://github.com/llvm/llvm-project/pull/83961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use TimeTraceProfilerEntry for Source span (PR #83961)

2024-03-04 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou updated 
https://github.com/llvm/llvm-project/pull/83961

>From 9a4911ee0732abbe770b98396e166a4d95bc0c95 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta 
Date: Mon, 4 Mar 2024 19:12:31 +0900
Subject: [PATCH 1/2] Expose TimeTraceProfiler for overlapping spans

---
 llvm/include/llvm/Support/TimeProfiler.h | 22 ++---
 llvm/lib/Support/TimeProfiler.cpp| 63 ++--
 2 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/llvm/include/llvm/Support/TimeProfiler.h 
b/llvm/include/llvm/Support/TimeProfiler.h
index 454a65f70231f4..941af7e3126c11 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -86,6 +86,8 @@ class raw_pwrite_stream;
 struct TimeTraceProfiler;
 TimeTraceProfiler *getTimeTraceProfilerInstance();
 
+struct TimeTraceProfilerEntry;
+
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
@@ -120,12 +122,15 @@ Error timeTraceProfilerWrite(StringRef PreferredFileName,
 /// Profiler copies the string data, so the pointers can be given into
 /// temporaries. Time sections can be hierarchical; every Begin must have a
 /// matching End pair but they can nest.
-void timeTraceProfilerBegin(StringRef Name, StringRef Detail);
-void timeTraceProfilerBegin(StringRef Name,
-llvm::function_ref Detail);
+TimeTraceProfilerEntry *timeTraceProfilerBegin(StringRef Name,
+   StringRef Detail);
+TimeTraceProfilerEntry *
+timeTraceProfilerBegin(StringRef Name,
+   llvm::function_ref Detail);
 
 /// Manually end the last time section.
 void timeTraceProfilerEnd();
+void timeTraceProfilerEnd(TimeTraceProfilerEntry *E);
 
 /// The TimeTraceScope is a helper class to call the begin and end functions
 /// of the time trace profiler.  When the object is constructed, it begins
@@ -141,20 +146,23 @@ struct TimeTraceScope {
 
   TimeTraceScope(StringRef Name) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, StringRef(""));
+  Entry = timeTraceProfilerBegin(Name, StringRef(""));
   }
   TimeTraceScope(StringRef Name, StringRef Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   TimeTraceScope(StringRef Name, llvm::function_ref Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   ~TimeTraceScope() {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerEnd();
+  timeTraceProfilerEnd(Entry);
   }
+
+private:
+  TimeTraceProfilerEntry *Entry = nullptr;
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4d625b3eb5b170..b195214cb52960 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/JSON.h"
@@ -20,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -64,8 +66,10 @@ using CountAndDurationType = std::pair;
 using NameAndCountAndDurationType =
 std::pair;
 
+} // anonymous namespace
+
 /// Represents an open or completed time section entry to be captured.
-struct TimeTraceProfilerEntry {
+struct llvm::TimeTraceProfilerEntry {
   const TimePointType Start;
   TimePointType End;
   const std::string Name;
@@ -92,8 +96,6 @@ struct TimeTraceProfilerEntry {
   }
 };
 
-} // anonymous namespace
-
 struct llvm::TimeTraceProfiler {
   TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
   : BeginningOfTime(system_clock::now()), StartTime(ClockType::now()),
@@ -102,23 +104,22 @@ struct llvm::TimeTraceProfiler {
 llvm::get_thread_name(ThreadName);
   }
 
-  void begin(std::string Name, llvm::function_ref Detail) {
-Stack.emplace_back(ClockType::now(), TimePointType(), std::move(Name),
-   Detail());
+  TimeTraceProfilerEntry *begin(std::string Name,
+llvm::function_ref Detail) {
+Stack.emplace_back(std::make_unique(
+ClockType::now(), TimePointType(), std::move(Name), Detail()));
+return Stack.back().get();
   }
 
   void end() {
+TimeTraceProfilerEntry *E = Stack.back().get();
+end(*E);
+  }
+
+  void end(TimeTraceProfilerEntry &E) {
 assert(!Stack.empty() && "Must call begin() first");
-TimeTraceProfilerEntry &E = Stack.back();
 E.End = ClockType::now();
 
-// Check that end times monotonically increase.
-assert((

[clang] [llvm] Use TimeTraceProfilerEntry for Source span (PR #83961)

2024-03-04 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou created 
https://github.com/llvm/llvm-project/pull/83961

This fixes incorrect trace for 
https://github.com/llvm/llvm-project/issues/56554.

https://github.com/llvm/llvm-project/pull/83778 is preparing PR.

>From 9a4911ee0732abbe770b98396e166a4d95bc0c95 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta 
Date: Mon, 4 Mar 2024 19:12:31 +0900
Subject: [PATCH 1/2] Expose TimeTraceProfiler for overlapping spans

---
 llvm/include/llvm/Support/TimeProfiler.h | 22 ++---
 llvm/lib/Support/TimeProfiler.cpp| 63 ++--
 2 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/llvm/include/llvm/Support/TimeProfiler.h 
b/llvm/include/llvm/Support/TimeProfiler.h
index 454a65f70231f4..941af7e3126c11 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -86,6 +86,8 @@ class raw_pwrite_stream;
 struct TimeTraceProfiler;
 TimeTraceProfiler *getTimeTraceProfilerInstance();
 
+struct TimeTraceProfilerEntry;
+
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
@@ -120,12 +122,15 @@ Error timeTraceProfilerWrite(StringRef PreferredFileName,
 /// Profiler copies the string data, so the pointers can be given into
 /// temporaries. Time sections can be hierarchical; every Begin must have a
 /// matching End pair but they can nest.
-void timeTraceProfilerBegin(StringRef Name, StringRef Detail);
-void timeTraceProfilerBegin(StringRef Name,
-llvm::function_ref Detail);
+TimeTraceProfilerEntry *timeTraceProfilerBegin(StringRef Name,
+   StringRef Detail);
+TimeTraceProfilerEntry *
+timeTraceProfilerBegin(StringRef Name,
+   llvm::function_ref Detail);
 
 /// Manually end the last time section.
 void timeTraceProfilerEnd();
+void timeTraceProfilerEnd(TimeTraceProfilerEntry *E);
 
 /// The TimeTraceScope is a helper class to call the begin and end functions
 /// of the time trace profiler.  When the object is constructed, it begins
@@ -141,20 +146,23 @@ struct TimeTraceScope {
 
   TimeTraceScope(StringRef Name) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, StringRef(""));
+  Entry = timeTraceProfilerBegin(Name, StringRef(""));
   }
   TimeTraceScope(StringRef Name, StringRef Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   TimeTraceScope(StringRef Name, llvm::function_ref Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   ~TimeTraceScope() {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerEnd();
+  timeTraceProfilerEnd(Entry);
   }
+
+private:
+  TimeTraceProfilerEntry *Entry = nullptr;
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4d625b3eb5b170..b195214cb52960 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/JSON.h"
@@ -20,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -64,8 +66,10 @@ using CountAndDurationType = std::pair;
 using NameAndCountAndDurationType =
 std::pair;
 
+} // anonymous namespace
+
 /// Represents an open or completed time section entry to be captured.
-struct TimeTraceProfilerEntry {
+struct llvm::TimeTraceProfilerEntry {
   const TimePointType Start;
   TimePointType End;
   const std::string Name;
@@ -92,8 +96,6 @@ struct TimeTraceProfilerEntry {
   }
 };
 
-} // anonymous namespace
-
 struct llvm::TimeTraceProfiler {
   TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
   : BeginningOfTime(system_clock::now()), StartTime(ClockType::now()),
@@ -102,23 +104,22 @@ struct llvm::TimeTraceProfiler {
 llvm::get_thread_name(ThreadName);
   }
 
-  void begin(std::string Name, llvm::function_ref Detail) {
-Stack.emplace_back(ClockType::now(), TimePointType(), std::move(Name),
-   Detail());
+  TimeTraceProfilerEntry *begin(std::string Name,
+llvm::function_ref Detail) {
+Stack.emplace_back(std::make_unique(
+ClockType::now(), TimePointType(), std::move(Name), Detail()));
+return Stack.back().get();
   }
 
   void end() {
+TimeTraceProfilerEntry *E = Stack.back().get();
+end(*E);
+  }
+
+  void end(TimeTraceProfilerEntry &E) {
 assert(!Stack.empty() && "Must call begin() first

r346733 - [clang-cl] Do not allow using both /Zc:dllexportInlines- and /fallback flag

2018-11-12 Thread Takuto Ikuta via cfe-commits
Author: tikuta
Date: Mon Nov 12 20:14:09 2018
New Revision: 346733

URL: http://llvm.org/viewvc/llvm-project?rev=346733&view=rev
Log:
[clang-cl] Do not allow using both /Zc:dllexportInlines- and /fallback flag

Summary: /Zc:dllexportInlines with /fallback may cause unexpected linker error. 
It is better to disallow compile rather than warn for this combination.

Reviewers: hans, thakis

Reviewed By: hans

Subscribers: cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D54426

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=346733&r1=346732&r2=346733&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Nov 12 20:14:09 
2018
@@ -161,9 +161,8 @@ def warn_drv_yc_multiple_inputs_clang_cl
   "support for '/Yc' with more than one source file not implemented yet; flag 
ignored">,
   InGroup;
 
-def warn_drv_non_fallback_argument_clang_cl : Warning<
-  "option '%0' is ignored when /fallback happens">,
-  InGroup;
+def err_drv_dllexport_inlines_and_fallback : Error<
+  "option '/Zc:dllexportInlines-' is ABI-changing and not compatible with 
'/fallback'">;
 
 def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
 def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=346733&r1=346732&r2=346733&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Nov 12 20:14:09 2018
@@ -5502,8 +5502,13 @@ void Clang::AddClangCLArgs(const ArgList
 
  if (Args.hasFlag(options::OPT__SLASH_Zc_dllexportInlines_,
   options::OPT__SLASH_Zc_dllexportInlines,
-  false))
+  false)) {
+   if (Args.hasArg(options::OPT__SLASH_fallback)) {
+ D.Diag(clang::diag::err_drv_dllexport_inlines_and_fallback);
+   } else {
 CmdArgs.push_back("-fno-dllexport-inlines");
+   }
+ }
 
   Arg *MostGeneralArg = Args.getLastArg(options::OPT__SLASH_vmg);
   Arg *BestCaseArg = Args.getLastArg(options::OPT__SLASH_vmb);

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=346733&r1=346732&r2=346733&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Mon Nov 12 20:14:09 2018
@@ -669,12 +669,6 @@ std::unique_ptr visualstudio::C
   // them too.
   Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN);
 
-  // Warning for ignored flag.
-  if (const Arg *dllexportInlines =
-  Args.getLastArg(options::OPT__SLASH_Zc_dllexportInlines_))
-C.getDriver().Diag(clang::diag::warn_drv_non_fallback_argument_clang_cl)
-  << dllexportInlines->getAsString(Args);
-
   // Input filename.
   assert(Inputs.size() == 1);
   const InputInfo &II = Inputs[0];

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=346733&r1=346732&r2=346733&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon Nov 12 20:14:09 2018
@@ -495,7 +495,7 @@
 // RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck 
-check-prefix=DllExportInlines %s
 // DllExportInlines-NOT: "-fno-dllexport-inlines"
 // RUN: %clang_cl /fallback /Zc:dllexportInlines- /c -### -- %s 2>&1 | 
FileCheck -check-prefix=DllExportInlinesFallback %s
-// DllExportInlinesFallback: warning: option '/Zc:dllexportInlines-' is 
ignored when /fallback happens [-Woption-ignored]
+// DllExportInlinesFallback: error: option '/Zc:dllexportInlines-' is 
ABI-changing and not compatible with '/fallback'
 
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r346491 - [clang-cl] Add warning for /Zc:dllexportInlines- when the flag is used with /fallback

2018-11-09 Thread Takuto Ikuta via cfe-commits
Author: tikuta
Date: Fri Nov  9 05:25:45 2018
New Revision: 346491

URL: http://llvm.org/viewvc/llvm-project?rev=346491&view=rev
Log:
[clang-cl] Add warning for /Zc:dllexportInlines- when the flag is used with 
/fallback

Summary:
This is followup of
https://reviews.llvm.org/D51340

Reviewers: hans, thakis

Reviewed By: hans

Subscribers: cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D54298

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=346491&r1=346490&r2=346491&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Nov  9 05:25:45 
2018
@@ -161,6 +161,10 @@ def warn_drv_yc_multiple_inputs_clang_cl
   "support for '/Yc' with more than one source file not implemented yet; flag 
ignored">,
   InGroup;
 
+def warn_drv_non_fallback_argument_clang_cl : Warning<
+  "option '%0' is ignored when /fallback happens">,
+  InGroup;
+
 def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
 def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;
 def err_drv_invalid_remap_file : Error<

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=346491&r1=346490&r2=346491&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Fri Nov  9 05:25:45 2018
@@ -669,6 +669,12 @@ std::unique_ptr visualstudio::C
   // them too.
   Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN);
 
+  // Warning for ignored flag.
+  if (const Arg *dllexportInlines =
+  Args.getLastArg(options::OPT__SLASH_Zc_dllexportInlines_))
+C.getDriver().Diag(clang::diag::warn_drv_non_fallback_argument_clang_cl)
+  << dllexportInlines->getAsString(Args);
+
   // Input filename.
   assert(Inputs.size() == 1);
   const InputInfo &II = Inputs[0];

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=346491&r1=346490&r2=346491&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Fri Nov  9 05:25:45 2018
@@ -494,6 +494,8 @@
 // NoDllExportInlines: "-fno-dllexport-inlines"
 // RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck 
-check-prefix=DllExportInlines %s
 // DllExportInlines-NOT: "-fno-dllexport-inlines"
+// RUN: %clang_cl /fallback /Zc:dllexportInlines- /c -### -- %s 2>&1 | 
FileCheck -check-prefix=DllExportInlinesFallback %s
+// DllExportInlinesFallback: warning: option '/Zc:dllexportInlines-' is 
ignored when /fallback happens [-Woption-ignored]
 
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r346069 - Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Takuto Ikuta via cfe-commits
Author: tikuta
Date: Fri Nov  2 23:45:00 2018
New Revision: 346069

URL: http://llvm.org/viewvc/llvm-project?rev=346069&view=rev
Log:
Add /Zc:DllexportInlines option to clang-cl

Summary:
This CL adds /Zc:DllexportInlines flag to clang-cl.
When Zc:DllexportInlines- is specified, inline class member function is not 
exported if the function does not have local static variables.

By not exporting inline function, code for those functions are not generated 
and that reduces both compile time and obj size. Also this flag does not import 
inline functions from dllimported class if the function does not have local 
static variables.

On my 24C48T windows10 machine, build performance of chrome target in chromium 
repository is like below.
These stats are come with 'target_cpu="x86" enable_nacl = false 
is_component_build=true dcheck_always_on=true` build config and applied
* https://chromium-review.googlesource.com/c/chromium/src/+/1212379
* https://chromium-review.googlesource.com/c/v8/v8/+/1186017

Below stats were taken with this patch applied on 
https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e

| config  | build time | speedup | build dir size |
| with patch, PCH on, debug   | 1h10m0s| x1.13   | 35.6GB |
| without patch, PCH on, debug| 1h19m17s   | | 49.0GB |
| with patch, PCH off, debug  | 1h15m45s   | x1.16   | 33.7GB |
| without patch, PCH off, debug   | 1h28m10s   | | 52.3GB |
| with patch, PCH on, release | 1h13m13s   | x1.22   | 26.2GB |
| without patch, PCH on, release  | 1h29m57s   | | 37.5GB |
| with patch, PCH off, release| 1h23m38s   | x1.32   | 23.7GB |
| without patch, PCH off, release | 1h50m50s   | | 38.7GB |

This patch reduced obj size and the number of exported symbols largely, that 
improved link time too.
e.g. link time stats of blink_core.dll become like below
|  | cold disk cache | warm disk cache |
| with patch, PCH on, debug| 71s | 30s |
| without patch, PCH on, debug | 111s| 48s |

This patch's implementation is based on Nico Weber's patch. I modified to 
support static local variable, added tests and took stats.

Bug: https://bugs.llvm.org/show_bug.cgi?id=33628

Reviewers: hans, thakis, rnk, javed.absar

Reviewed By: hans

Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman

Differential Revision: https://reviews.llvm.org/D51340

Added:
cfe/trunk/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=346069&r1=346068&r2=346069&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Nov  2 23:45:00 2018
@@ -2683,6 +2683,17 @@ def DLLExport : InheritableAttr, TargetS
   let Documentation = [DLLExportDocs];
 }
 
+def DLLExportStaticLocal : InheritableAttr, TargetSpecificAttr {
+  // This attribute is used internally only when -fno-dllexport-inlines is
+  // passed. This attribute is added to inline function of class having
+  // dllexport attribute. And if the function has static local variables, this
+  // attribute is used to whether the variables are exported or not. Also if
+  // function has local static variables, the function is dllexported too.
+  let Spellings = [];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}
+
 def DLLImport : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
   let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
@@ -2699,6 +2710,16 @@ public:
   }];
 }
 
+def DLLImportStaticLocal : InheritableAttr, TargetSpecificAttr {
+  // This attribute is used internally only when -fno-dllexport-inlines is
+  // passed. This attribute is added to inline function of class having
+  // dllimport attribute. And if the function has static local variables, this
+  // attribute is used to whether the variables are imported or not.
+  let Spellings = [];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}
+
 def SelectAny : InheritableAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
   let Documentation = [SelectAnyDocs];

Modified: cfe/trunk/include/clan

r345576 - Remove trailing space from clang/Basic/LangOptions.h

2018-10-30 Thread Takuto Ikuta via cfe-commits
Author: tikuta
Date: Tue Oct 30 02:42:49 2018
New Revision: 345576

URL: http://llvm.org/viewvc/llvm-project?rev=345576&view=rev
Log:
Remove trailing space from clang/Basic/LangOptions.h

Modified:
cfe/trunk/include/clang/Basic/LangOptions.h

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=345576&r1=345575&r2=345576&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Tue Oct 30 02:42:49 2018
@@ -298,7 +298,7 @@ public:
 /// Floating point control options
 class FPOptions {
 public:
-  FPOptions() : fp_contract(LangOptions::FPC_Off), 
+  FPOptions() : fp_contract(LangOptions::FPC_Off),
 fenv_access(LangOptions::FEA_Off) {}
 
   // Used for serializing.
@@ -344,7 +344,7 @@ public:
   unsigned getInt() const { return fp_contract | (fenv_access << 2); }
 
 private:
-  /// Adjust BinaryOperator::FPFeatures to match the total bit-field size 
+  /// Adjust BinaryOperator::FPFeatures to match the total bit-field size
   /// of these two.
   unsigned fp_contract : 2;
   unsigned fenv_access : 1;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r344668 - NFC: Remove trailing space from CodeGenModule.cpp

2018-10-16 Thread Takuto Ikuta via cfe-commits
Author: tikuta
Date: Tue Oct 16 21:29:56 2018
New Revision: 344668

URL: http://llvm.org/viewvc/llvm-project?rev=344668&view=rev
Log:
NFC: Remove trailing space from CodeGenModule.cpp

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=344668&r1=344667&r2=344668&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Oct 16 21:29:56 2018
@@ -4106,17 +4106,17 @@ CodeGenModule::GetAddrOfConstantCFString
 
   llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
   llvm::Constant *Zeros[] = { Zero, Zero };
-  
+
   // If we don't already have it, get __CFConstantStringClassReference.
   if (!CFConstantStringClassRef) {
 llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
 Ty = llvm::ArrayType::get(Ty, 0);
 llvm::Constant *C =
 CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
-
+
 if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) {
   llvm::GlobalValue *GV = nullptr;
-  
+
   if ((GV = dyn_cast(C))) {
 IdentifierInfo &II = getContext().Idents.get(GV->getName());
 TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
@@ -4126,7 +4126,7 @@ CodeGenModule::GetAddrOfConstantCFString
 for (const auto &Result : DC->lookup(&II))
   if ((VD = dyn_cast(Result)))
 break;
-  
+
 if (getTriple().isOSBinFormatELF()) {
   if (!VD)
 GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
@@ -4140,11 +4140,11 @@ CodeGenModule::GetAddrOfConstantCFString
 GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
   }
 }
-
+
 setDSOLocal(GV);
   }
 }
-  
+
 // Decay array -> ptr
 CFConstantStringClassRef =
 llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros);
@@ -4197,7 +4197,7 @@ CodeGenModule::GetAddrOfConstantCFString
   // the static linker to adjust permissions to read-only later on.
   else if (getTriple().isOSBinFormatELF())
 GV->setSection(".rodata");
-  
+
   // String.
   llvm::Constant *Str =
   llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);
@@ -4876,7 +4876,7 @@ void CodeGenModule::EmitTopLevelDecl(Dec
   case Decl::OMPDeclareReduction:
 EmitOMPDeclareReduction(cast(D));
 break;
- 
+
   case Decl::OMPRequires:
 EmitOMPRequiresDecl(cast(D));
 break;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits